[kcms/users] Disable avatar cache

User picture path doesn't change after updating. If cache is enabled,
KCM will show the old picture until the cache expire.

Depends on
https://invent.kde.org/frameworks/kirigami/-/merge_requests/148

BUG: 428669
FIXED-IN: 5.21
wilder-5.24
Guo Yunhe 5 years ago committed by Devin Lin
parent 819348b71b
commit a1c70fac9f
  1. 1
      kcms/users/package/contents/ui/UserDetailsPage.qml
  2. 14
      kcms/users/package/contents/ui/main.qml

@ -130,6 +130,7 @@ SimpleKCM {
Kirigami.Avatar {
source: usersDetailPage.user.face
cache: false // user picture path doesn't change after updating
name: user.realName
anchors {
fill: parent

@ -41,6 +41,17 @@ KCM.ScrollViewKCM {
implicitWidth: Kirigami.Units.gridUnit * 30
implicitHeight: Kirigami.Units.gridUnit * 20
// QML cannot update avatar image when override. By increasing this number and
// appending it to image source with '?', we force avatar to reload
property int avatarVersion: 0
Connections {
target: kcm
onApply: {
avatarVersion += 1
}
}
Component.onCompleted: {
kcm.columnWidth = Kirigami.Units.gridUnit * 15
kcm.push("UserDetailsPage.qml", {user: kcm.userModel.getLoggedInUser()})
@ -73,7 +84,8 @@ KCM.ScrollViewKCM {
radius: height/2
Kirigami.Avatar {
source: model.decoration
source: model.decoration + '?' + avatarVersion // force reload after saving
cache: false // avoid caching
name: model.display
anchors {
fill: parent

Loading…
Cancel
Save