-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Better ImageProvider->ThumbnailProvider
The class handles avatars in a special way now - when passed a room id and, optionally, a user id for a member of that room, it spawns a newly introduced AvatarResponse that can retrieve the possibly already cached avatar from the respective Room/User object. This required some changes in QML, with common code moved out to the special Avatar specialisation of Image component. What warranted a dedicated QML component is that Quotient::Avatar returns the first (possibly empty or smaller resolution) image immediately while requesting the right one behind the scenes; so QML Avatar listens on the respective signals from the library and updates the image when the new avatar arrives - which (i.e. updating) is in turn somewhat "idiomatic" because of QTBUG-14900. QML Avatar encapsulates these two peculiarities.
- Loading branch information
1 parent
44d0acb
commit 7eac2e5
Showing
12 changed files
with
294 additions
and
216 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import QtQuick 2.15 | ||
|
||
Image { | ||
readonly property var forRoom: root.room | ||
/* readonly */ property var forMember | ||
|
||
property string sourceId: forRoom ? "image://thumbnail/" + forRoom.id | ||
+ (forMember ? '/' + forMember.id : "") | ||
: "" | ||
source: sourceId | ||
cache: false // Quotient::Avatar takes care of caching | ||
fillMode: Image.PreserveAspectFit | ||
|
||
function reload() { | ||
source = "" | ||
source = Qt.binding(function() { return sourceId }) | ||
} | ||
|
||
Connections { | ||
target: forRoom | ||
function onAvatarChanged() { parent.reload() } | ||
function onMemberAvatarChanged(member) { | ||
if (member === parent.forMember) | ||
parent.reload() | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.