Commit 27b98746 authored by Jan Blackquill's avatar Jan Blackquill 🌈 Committed by Jan Blackquill

[kcms/users]: Don't hardcode the list of avatars

This replaces a hardcoded list of avatars with searching in $DATA_DIRS/plasma-avatars, which allows distros to ship their own avatars

BUG: 426777
parent b11347f7
......@@ -3,4 +3,5 @@ add_definitions(-DTRANSLATION_DOMAIN=\"kcm_users\")
install( FILES kcm_users.desktop DESTINATION ${SERVICES_INSTALL_DIR})
install( DIRECTORY avatars/ DESTINATION ${DATA_INSTALL_DIR}/plasma-avatars )
kpackage_install_package(package kcm_users kcms)
......@@ -306,45 +306,7 @@ SimpleKCM {
Repeater {
model: [
"Artist Konqi.png",
"Bookworm Konqi.png",
"Boss Konqi.png",
"Bug Catcher Konqi.png",
"Card Shark Konqi.png",
"Hacker Konqi.png",
"Journalist Konqi.png",
"Mechanic Konqi.png",
"Messenger Konqi.png",
"Musician Konqi.png",
"Office Worker Konqi.png",
"PC Builder Konqi.png",
"Scientist Konqi.png",
"Teacher Konqi.png",
"Virtual Reality Konqi.png",
"photos/Air Balloon.png",
model: kcm.avatarFiles
QQC2.Button {
Layout.preferredHeight: Kirigami.Units.gridUnit * 6
Layout.preferredWidth: Layout.preferredHeight
......@@ -359,7 +321,7 @@ SimpleKCM {
mipmap: true
anchors.fill: parent
source: "../img/%1".arg(modelData)
source: modelData
Accessible.ignored: true
......@@ -57,6 +57,20 @@ KCMUser::KCMUser(QObject *parent, const QVariantList &args)
auto font = QApplication::font("QLabel");
auto fm = QFontMetrics(font);
const auto dirs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QStringLiteral("plasma-avatars"), QStandardPaths::LocateDirectory);
for (const auto& dir : dirs) {
QDirIterator it(
QStringList{ QStringLiteral("*.jpg"), QStringLiteral("*.png") },
while (it.hasNext()) {
m_avatarFiles <<;
bool KCMUser::createUser(const QString& name, const QString& realName, const QString& password, bool isAdmin)
......@@ -31,10 +31,12 @@ class KCMUser : public KQuickAddons::ConfigModule
Q_PROPERTY(UserModel* userModel MEMBER m_model CONSTANT)
Q_PROPERTY(QStringList avatarFiles MEMBER m_avatarFiles CONSTANT)
OrgFreedesktopAccountsInterface* m_dbusInterface;
UserModel* m_model;
QStringList m_avatarFiles;
KCMUser(QObject *parent = nullptr, const QVariantList &args = QVariantList());
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