Skip to content

Commit

Permalink
Increase maximumCount by one if guest user exists
Browse files Browse the repository at this point in the history
Guest user doesn't limit the number of users that can be created. It is,
however, an actual user so it is counted in count. Change maximumCount
to depend on whether guest user is enabled or not.

Signed-off-by: Tomi Leppänen <tomi.leppanen@jolla.com>
  • Loading branch information
Tomin1 committed Aug 12, 2020
1 parent 447639c commit 5613b32
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/usermodel.cpp
Expand Up @@ -83,6 +83,8 @@ UserModel::UserModel(QObject *parent)
QDBusServiceWatcher::WatchForRegistration | QDBusServiceWatcher::WatchForUnregistration, this))
, m_guestEnabled(getpwuid((uid_t)SAILFISH_USERMANAGER_GUEST_UID))
{
connect(this, &UserModel::guestEnabledChanged,
this, &UserModel::maximumCountChanged);
qDBusRegisterMetaType<SailfishUserManagerEntry>();
connect(m_dBusWatcher, &QDBusServiceWatcher::serviceRegistered,
this, &UserModel::createInterface);
Expand Down Expand Up @@ -154,7 +156,7 @@ int UserModel::count() const
*/
int UserModel::maximumCount() const
{
return SAILFISH_USERMANAGER_MAX_USERS;
return m_guestEnabled ? SAILFISH_USERMANAGER_MAX_USERS+1 : SAILFISH_USERMANAGER_MAX_USERS;
}

QHash<int, QByteArray> UserModel::roleNames() const
Expand Down
3 changes: 2 additions & 1 deletion src/usermodel.h
Expand Up @@ -51,7 +51,7 @@ class SYSTEMSETTINGS_EXPORT UserModel: public QAbstractListModel
Q_OBJECT
Q_PROPERTY(bool placeholder READ placeholder WRITE setPlaceholder NOTIFY placeholderChanged)
Q_PROPERTY(int count READ count NOTIFY countChanged)
Q_PROPERTY(int maximumCount READ maximumCount CONSTANT)
Q_PROPERTY(int maximumCount READ maximumCount NOTIFY maximumCountChanged)
Q_PROPERTY(bool guestEnabled READ guestEnabled WRITE setGuestEnabled NOTIFY guestEnabledChanged)

public:
Expand Down Expand Up @@ -125,6 +125,7 @@ class SYSTEMSETTINGS_EXPORT UserModel: public QAbstractListModel
signals:
void placeholderChanged();
void countChanged();
void maximumCountChanged();
void guestEnabledChanged();
void userGroupsChanged(int row);
void userAddFailed(int error);
Expand Down

0 comments on commit 5613b32

Please sign in to comment.