Changeset View
Changeset View
Standalone View
Standalone View
src/qmlcontrols/kcoreaddons/kuserproxy.cpp
Show All 25 Lines | |||||
26 | #include <QTextStream> | 26 | #include <QTextStream> | ||
27 | #include <QUrl> | 27 | #include <QUrl> | ||
28 | 28 | | |||
29 | #include <KDirWatch> | 29 | #include <KDirWatch> | ||
30 | 30 | | |||
31 | #include <QDebug> | 31 | #include <QDebug> | ||
32 | 32 | | |||
33 | const QString etcPasswd = QStringLiteral("/etc/passwd"); | 33 | const QString etcPasswd = QStringLiteral("/etc/passwd"); | ||
34 | const QString accountsServiceIconPath = QStringLiteral("/var/lib/AccountsService/icons"); | ||||
34 | 35 | | |||
35 | KUserProxy::KUserProxy (QObject *parent) | 36 | KUserProxy::KUserProxy (QObject *parent) | ||
36 | : QObject(parent), | 37 | : QObject(parent), | ||
37 | m_temporaryEmptyFaceIconPath(false) | 38 | m_temporaryEmptyFaceIconPath(false) | ||
38 | { | 39 | { | ||
39 | QString pathToFaceIcon(m_user.faceIconPath()); | 40 | QString pathToFaceIcon(m_user.faceIconPath()); | ||
40 | if (pathToFaceIcon.isEmpty()) { | 41 | if (pathToFaceIcon.isEmpty()) { | ||
41 | //KUser returns null if the current faceIconPath is empty | 42 | //KUser returns null if the current faceIconPath is empty | ||
42 | //so we should explicitly watch ~/.face.icon rather than faceIconPath() | 43 | //so we should explicitly watch ~/.face.icon rather than faceIconPath() | ||
43 | //as we want to watch for this file being created | 44 | //as we want to watch for this file being created | ||
44 | pathToFaceIcon = QDir::homePath() + QStringLiteral("/.face.icon"); | 45 | pathToFaceIcon = QDir::homePath() + QStringLiteral("/.face.icon"); | ||
45 | } | 46 | } | ||
46 | 47 | | |||
47 | m_dirWatch.addFile(pathToFaceIcon); | 48 | m_dirWatch.addFile(pathToFaceIcon); | ||
49 | m_dirWatch.addFile(accountsServiceIconPath + QLatin1Char('/') + m_user.loginName()); | ||||
48 | if (QFile::exists(etcPasswd)) { | 50 | if (QFile::exists(etcPasswd)) { | ||
49 | m_dirWatch.addFile(etcPasswd); | 51 | m_dirWatch.addFile(etcPasswd); | ||
50 | } | 52 | } | ||
51 | 53 | | |||
52 | connect(&m_dirWatch, &KDirWatch::dirty, this, &KUserProxy::update); | 54 | connect(&m_dirWatch, &KDirWatch::dirty, this, &KUserProxy::update); | ||
53 | connect(&m_dirWatch, &KDirWatch::created, this, &KUserProxy::update); | 55 | connect(&m_dirWatch, &KDirWatch::created, this, &KUserProxy::update); | ||
56 | connect(&m_dirWatch, &KDirWatch::deleted, this, &KUserProxy::update); | ||||
54 | } | 57 | } | ||
55 | 58 | | |||
56 | KUserProxy::~KUserProxy() | 59 | KUserProxy::~KUserProxy() | ||
57 | { | 60 | { | ||
58 | } | 61 | } | ||
59 | 62 | | |||
60 | void KUserProxy::update(const QString &path) | 63 | void KUserProxy::update(const QString &path) | ||
61 | { | 64 | { | ||
62 | if (path == m_user.faceIconPath()) { | 65 | if (path == m_user.faceIconPath() || path == QDir::homePath() + QLatin1String("/.face.icon") | ||
66 | || path == accountsServiceIconPath + QLatin1Char('/') + m_user.loginName()) { | ||||
apol: QLatin1Char('/') | |||||
63 | // we need to force updates, even when the path doesn't change, | 67 | // we need to force updates, even when the path doesn't change, | ||
64 | // but the underlying image does. Change path temporarily, to | 68 | // but the underlying image does. Change path temporarily, to | ||
65 | // make the Image reload. | 69 | // make the Image reload. | ||
66 | // Needs cache: false in the Image item to actually reload | 70 | // Needs cache: false in the Image item to actually reload | ||
67 | m_temporaryEmptyFaceIconPath = true; | 71 | m_temporaryEmptyFaceIconPath = true; | ||
68 | emit faceIconUrlChanged(); | 72 | emit faceIconUrlChanged(); | ||
69 | m_temporaryEmptyFaceIconPath = false; | 73 | m_temporaryEmptyFaceIconPath = false; | ||
70 | emit faceIconUrlChanged(); | 74 | emit faceIconUrlChanged(); | ||
▲ Show 20 Lines • Show All 67 Lines • Show Last 20 Lines |
QLatin1Char('/')