15const QString etcPasswd = QStringLiteral(
"/etc/passwd");
16const QString accountsServiceIconPath = QStringLiteral(
"/var/lib/AccountsService/icons");
18KUserProxy::KUserProxy(
QObject *parent)
20 , m_temporaryEmptyFaceIconPath(false)
22 QString pathToFaceIcon(m_user.faceIconPath());
23 if (pathToFaceIcon.isEmpty()) {
30 m_dirWatch.addFile(pathToFaceIcon);
31 m_dirWatch.addFile(accountsServiceIconPath +
QLatin1Char(
'/') + m_user.loginName());
33 m_dirWatch.addFile(etcPasswd);
41KUserProxy::~KUserProxy()
45void KUserProxy::update(
const QString &path)
47 if (path == m_user.faceIconPath() || path ==
QDir::homePath() + QLatin1String(
"/.face.icon")
48 || path == accountsServiceIconPath + QLatin1Char(
'/') + m_user.loginName()) {
53 m_temporaryEmptyFaceIconPath =
true;
55 m_temporaryEmptyFaceIconPath =
false;
57 }
else if (path == etcPasswd) {
65 QString fullName = m_user.property(KUser::FullName).toString();
66 if (!fullName.isEmpty()) {
74 return m_user.loginName();
77QUrl KUserProxy::faceIconUrl()
const
79 if (m_temporaryEmptyFaceIconPath) {
82 const QString u = m_user.faceIconPath();
94 QFile osfile(QStringLiteral(
"/etc/os-release"));
95 if (osfile.exists()) {
100 QTextStream in(&osfile);
101 while (!in.atEnd()) {
102 QString line = in.readLine();
103 if (line.
startsWith(QLatin1String(
"PRETTY_NAME"))) {
104 QStringList fields = line.
split(QLatin1String(
"PRETTY_NAME=\""));
105 if (fields.
count() == 2) {
107 QString pretty = fields.
at(1);
124#include "moc_kuserproxy.cpp"
void deleted(const QString &path)
Emitted when a file or directory is deleted.
void dirty(const QString &path)
Emitted when a watched object is changed.
void created(const QString &path)
Emitted when a file or directory (being watched explicitly) is created.
void faceIconUrlChanged()
signal that the user image changed
void nameChanged()
signal that the user's name or login name changed
bool exists(const QString &fileName)
const_reference at(qsizetype i) const const
qsizetype count() const const
bool isEmpty() const const
QStringList split(QChar sep, Qt::SplitBehavior behavior, Qt::CaseSensitivity cs) const const
bool startsWith(QChar c, Qt::CaseSensitivity cs) const const
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
QUrl fromLocalFile(const QString &localFile)