Commit 5613b329 authored by Tomi Leppänen's avatar Tomi Leppänen

Increase maximumCount by one if guest user exists

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's avatarTomi Leppänen <tomi.leppanen@jolla.com>
parent 447639c7
......@@ -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);
......@@ -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
......
......@@ -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:
......@@ -125,6 +125,7 @@ public:
signals:
void placeholderChanged();
void countChanged();
void maximumCountChanged();
void guestEnabledChanged();
void userGroupsChanged(int row);
void userAddFailed(int error);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment