Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[nemo-systemsettings] Allow setting UserInfo uid from QML. Contribute…
…s to JB#49640

Signed-off-by: Tomi Leppänen <tomi.leppanen@jolla.com>
  • Loading branch information
Tomin1 committed Apr 23, 2020
1 parent 54a20b0 commit fafdffc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/userinfo.cpp
Expand Up @@ -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
*/
Expand Down
3 changes: 2 additions & 1 deletion src/userinfo.h
Expand Up @@ -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;
Expand All @@ -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();
Expand Down

0 comments on commit fafdffc

Please sign in to comment.