summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Edmundson <[email protected]>2017-01-13 15:27:04 +0000
committerDavid Edmundson <[email protected]>2017-01-13 15:27:04 +0000
commit0d43e0379a16fe5f2c58a69ff2db1cf14c28197e (patch)
tree0dbbdfb0bbab7496f1899abd778c19197586ed01
parent1155c3a337607f22cd36e434e6527fb14ac9c513 (diff)
When updating another user's avatar don't save icon into our home
Summary: We want to save the face using AccountsService, but for backwards compatibility we also save the icon into ~/.face for old apps/DisplayManagers that still expect that. This works when setting a face as the current user, but doesn't make sense when setting the icon of another user. We can't fix it to write into another user's home, so instead of trying just skip that step and only update AccountsService. BUG: 365662 BUG: 360005 BUG: 371663 Test Plan: Changed my user's avatar. AccountsService updated ~/.face updated Changed another user's avatar from my account. Accounts service updated, ~/.face was unchanged Reviewers: #plasma, mart Reviewed By: mart Subscribers: plasma-devel Tags: #plasma Differential Revision: https://phabricator.kde.org/D4036
-rw-r--r--src/accountinfo.cpp39
1 files changed, 25 insertions, 14 deletions
diff --git a/src/accountinfo.cpp b/src/accountinfo.cpp
index 0ad6624..e384103 100644
--- a/src/accountinfo.cpp
+++ b/src/accountinfo.cpp
@@ -38,6 +38,7 @@
#include <KJob>
#include <KIO/CopyJob>
#include <KIconLoader>
+#include <KUser>
AccountInfo::AccountInfo(AccountModel* model, QWidget* parent, Qt::WindowFlags f)
: QWidget(parent, f)
@@ -174,20 +175,30 @@ bool AccountInfo::save()
}
if (m_infoToSave.contains(AccountModel::Face)) {
const QString path = m_infoToSave[AccountModel::Face].toString();
- QString faceFile = QStandardPaths::writableLocation(QStandardPaths::HomeLocation);
- faceFile.append(QLatin1String("/.face"));
-
- QFile::remove(faceFile);
- KIO::CopyJob* moveJob = KIO::move(QUrl::fromLocalFile(path), QUrl::fromLocalFile(faceFile), KIO::HideProgressInfo);
- connect(moveJob, SIGNAL(finished(KJob*)), SLOT(avatarModelChanged(KJob*)));
- moveJob->setUiDelegate(0);
- moveJob->setUiDelegateExtension(0);
- moveJob->start();
-
- QString faceFile2 = QStandardPaths::writableLocation(QStandardPaths::HomeLocation);
- faceFile2.append(QLatin1String("/.face.icon"));
- QFile::remove(faceFile2);
- QFile::link(faceFile, faceFile2);
+
+ //we want to save the face using AccountsService, but for backwards compatibility we also
+ //save the icon into ~/.face for old apps/DisplayManagers that still expect that
+ //This works when setting a face as the current user, but doesn't make sense when setting the icon
+ //of another user.
+ const QString username = m_model->data(m_index, AccountModel::Username).toString();
+ if (username != KUser().loginName()) {
+ m_model->setData(m_index, QVariant(path), AccountModel::Face);
+ } else {
+ QString faceFile = QStandardPaths::writableLocation(QStandardPaths::HomeLocation);
+ faceFile.append(QLatin1String("/.face"));
+ QFile::remove(faceFile);
+
+ KIO::CopyJob* moveJob = KIO::move(QUrl::fromLocalFile(path), QUrl::fromLocalFile(faceFile), KIO::HideProgressInfo);
+ connect(moveJob, SIGNAL(finished(KJob*)), SLOT(avatarModelChanged(KJob*)));
+ moveJob->setUiDelegate(0);
+ moveJob->setUiDelegateExtension(0);
+ moveJob->start();
+
+ QString faceFile2 = QStandardPaths::writableLocation(QStandardPaths::HomeLocation);
+ faceFile2.append(QLatin1String("/.face.icon"));
+ QFile::remove(faceFile2);
+ QFile::link(faceFile, faceFile2);
+ }
}
if (!failed.isEmpty()) {