From fafdffc3278adbe29ed503652c3bda803947c57c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomi=20Lepp=C3=A4nen?= Date: Wed, 22 Apr 2020 17:31:36 +0300 Subject: [PATCH] [nemo-systemsettings] Allow setting UserInfo uid from QML. Contributes to JB#49640 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tomi Leppänen --- src/userinfo.cpp | 7 +++++++ src/userinfo.h | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/userinfo.cpp b/src/userinfo.cpp index 291191d..7502488 100644 --- a/src/userinfo.cpp +++ b/src/userinfo.cpp @@ -292,6 +292,13 @@ int UserInfo::uid() const return (int)d->m_uid; } +void UserInfo::setUid(int uid) +{ + Q_D(const UserInfo); + if ((uid_t)uid != d->m_uid) + replace(UserInfo(uid).d_ptr); +} + /** * Returs true if user is logged in on seat0 and is the active user, i.e. the current user */ diff --git a/src/userinfo.h b/src/userinfo.h index 004c518..756ae2a 100644 --- a/src/userinfo.h +++ b/src/userinfo.h @@ -50,7 +50,7 @@ class SYSTEMSETTINGS_EXPORT UserInfo: public QObject Q_PROPERTY(QString username READ username NOTIFY usernameChanged) Q_PROPERTY(QString name READ name NOTIFY nameChanged) Q_PROPERTY(UserType type READ type CONSTANT) - Q_PROPERTY(int uid READ uid NOTIFY uidChanged) + Q_PROPERTY(int uid READ uid WRITE setUid NOTIFY uidChanged) Q_PROPERTY(bool current READ current NOTIFY currentChanged) friend class UserModel; @@ -75,6 +75,7 @@ class SYSTEMSETTINGS_EXPORT UserInfo: public QObject QString name() const; UserType type() const; int uid() const; + void setUid(int uid); bool current() const; Q_INVOKABLE void reset();