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\")
add_subdirectory(src)
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",
"Katie.png",
"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",
"photos/Astronaut.png",
"photos/Books.png",
"photos/Brushes.png",
"photos/Bulb.png",
"photos/Car.png",
"photos/Cat.png",
"photos/Chameleon.png",
"photos/Cocktail.png",
"photos/Dog.png",
"photos/Fish.png",
"photos/Gamepad.png",
"photos/Owl.png",
"photos/Pancakes.png",
"photos/Parrot.png",
"photos/Pencils.png",
"photos/Shuttle.png",
"photos/Soccer.png",
"photos/Sunflower.png",
"photos/Sushi.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);
setColumnWidth(fm.capHeight()*30);
const auto dirs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QStringLiteral("plasma-avatars"), QStandardPaths::LocateDirectory);
for (const auto& dir : dirs) {
QDirIterator it(
dir,
QStringList{ QStringLiteral("*.jpg"), QStringLiteral("*.png") },
QDir::Files,
QDirIterator::Subdirectories
);
while (it.hasNext()) {
m_avatarFiles << it.next();
}
}
}
bool KCMUser::createUser(const QString& name, const QString& realName, const QString& password, bool isAdmin)
......
......@@ -31,10 +31,12 @@ class KCMUser : public KQuickAddons::ConfigModule
{
Q_OBJECT
Q_PROPERTY(UserModel* userModel MEMBER m_model CONSTANT)
Q_PROPERTY(QStringList avatarFiles MEMBER m_avatarFiles CONSTANT)
private:
OrgFreedesktopAccountsInterface* m_dbusInterface;
UserModel* m_model;
QStringList m_avatarFiles;
public:
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