Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
Please login to access the resource
home:yukoff:openSUSE:Leap:42.1:Backports
sddm.4247
add-threshold-to-disable-avatars.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File add-threshold-to-disable-avatars.patch of Package sddm.4247
Index: sddm-0.13.0/src/greeter/UserModel.cpp =================================================================== --- sddm-0.13.0.orig/src/greeter/UserModel.cpp +++ sddm-0.13.0/src/greeter/UserModel.cpp @@ -51,6 +51,9 @@ namespace SDDM { }; UserModel::UserModel(QObject *parent) : QAbstractListModel(parent), d(new UserModelPrivate()) { + const QString facesDir = mainConfig.Theme.FacesDir.get(); + const QString defaultFace = QStringLiteral("%1/.face.icon").arg(facesDir); + struct passwd *current_pw; while ((current_pw = getpwent()) != nullptr) { @@ -81,23 +84,7 @@ namespace SDDM { user->needsPassword = strcmp(current_pw->pw_passwd, "") != 0; // search for face icon - QString facesDir = mainConfig.Theme.FacesDir.get(); - QString defaultFace = QStringLiteral("%1/.face.icon").arg(facesDir); - bool avatarsEnabled = mainConfig.Theme.EnableAvatars.get(); - - if (avatarsEnabled) { - QString userFace = QStringLiteral("%1/.face.icon").arg(user->homeDir); - QString systemFace = QStringLiteral("%1/%2.face.icon").arg(facesDir).arg(user->name); - - if (QFile::exists(userFace)) - user->icon = userFace; - else if (QFile::exists(systemFace)) - user->icon = systemFace; - else - user->icon = defaultFace; - } else { - user->icon = defaultFace; - } + user->icon = defaultFace; // add user d->users << user; @@ -108,10 +95,26 @@ namespace SDDM { // sort users by username std::sort(d->users.begin(), d->users.end(), [&](const UserPtr &u1, const UserPtr &u2) { return u1->name < u2->name; }); + bool avatarsEnabled = mainConfig.Theme.EnableAvatars.get(); + if (avatarsEnabled && mainConfig.Theme.EnableAvatars.isDefault()) { + if (d->users.count() > mainConfig.Theme.UsersThresholdToDisableAvatars.get()) avatarsEnabled=false; + } + // find out index of the last user for (int i = 0; i < d->users.size(); ++i) { - if (d->users.at(i)->name == stateConfig.Last.User.get()) + UserPtr user { d->users.at(i) }; + if (user->name == stateConfig.Last.User.get()) d->lastIndex = i; + + if (avatarsEnabled) { + const QString userFace = QStringLiteral("%1/.face.icon").arg(user->homeDir); + const QString systemFace = QStringLiteral("%1/%2.face.icon").arg(facesDir).arg(user->name); + + if (QFile::exists(userFace)) + user->icon = userFace; + else if (QFile::exists(systemFace)) + user->icon = systemFace; + } } } @@ -165,4 +168,8 @@ namespace SDDM { // return empty value return QVariant(); } + + int UserModel::usersThresholdToDisableAvatars() const { + return mainConfig.Theme.UsersThresholdToDisableAvatars.get(); + } } Index: sddm-0.13.0/src/common/Configuration.h =================================================================== --- sddm-0.13.0.orig/src/common/Configuration.h +++ sddm-0.13.0/src/common/Configuration.h @@ -50,6 +50,9 @@ namespace SDDM { "The files should be in username.face.icon format")); Entry(CursorTheme, QString, QString(), _S("Cursor theme")); Entry(EnableAvatars, bool, true, _S("Enable display of custom user avatars")); + Entry(UsersThresholdToDisableAvatars,int,7, _S("Number of users to use as threshold\n" + "above which avatars are disabled\n" + "unless explicitly enabled with EnableAvatars")); ); // TODO: Not absolutely sure if everything belongs here. Xsessions, VT and probably some more seem universal Section(XDisplay, Index: sddm-0.13.0/src/greeter/UserModel.h =================================================================== --- sddm-0.13.0.orig/src/greeter/UserModel.h +++ sddm-0.13.0/src/greeter/UserModel.h @@ -33,6 +33,7 @@ namespace SDDM { Q_PROPERTY(int lastIndex READ lastIndex CONSTANT) Q_PROPERTY(QString lastUser READ lastUser CONSTANT) Q_PROPERTY(int count READ rowCount CONSTANT) + Q_PROPERTY(int usersThresholdToDisableAvatars READ usersThresholdToDisableAvatars CONSTANT) public: enum UserRoles { NameRole = Qt::UserRole + 1, @@ -53,6 +54,7 @@ namespace SDDM { int rowCount(const QModelIndex &parent = QModelIndex()) const override; QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; + int usersThresholdToDisableAvatars() const; private: UserModelPrivate *d { nullptr }; };
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor