Changeset View
Changeset View
Standalone View
Standalone View
src/avatargallery.cpp
Show First 20 Lines • Show All 46 Lines • ▼ Show 20 Line(s) | 46 | const QStringList &locations = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, | |||
---|---|---|---|---|---|
47 | QStringLiteral("user-manager/avatars"), | 47 | QStringLiteral("user-manager/avatars"), | ||
48 | QStandardPaths::LocateDirectory); | 48 | QStandardPaths::LocateDirectory); | ||
49 | 49 | | |||
50 | if (locations.isEmpty()) { | 50 | if (locations.isEmpty()) { | ||
51 | return; | 51 | return; | ||
52 | } | 52 | } | ||
53 | 53 | | |||
54 | const QString &systemFacesPath = locations.last() + QLatin1Char('/'); | 54 | const QString &systemFacesPath = locations.last() + QLatin1Char('/'); | ||
55 | QDir avatarsDir(systemFacesPath); | 55 | const QDir avatarsDir(systemFacesPath); | ||
56 | 56 | | |||
57 | foreach(const QString &avatarStyle, avatarsDir.entryList(QDir::Dirs | QDir::NoDotDot)) { | 57 | for (const QString &avatarStyle : avatarsDir.entryList(QDir::Dirs | QDir::NoDotDot)) { | ||
58 | QDir facesDir = (avatarsDir.filePath(avatarStyle)); | 58 | QDir facesDir = (avatarsDir.filePath(avatarStyle)); | ||
59 | const QStringList &avatarList = facesDir.entryList(QDir::Files); | 59 | const QStringList &avatarList = facesDir.entryList(QDir::Files); | ||
60 | for (auto it = avatarList.constBegin(), end = avatarList.constEnd(); it != end; ++it) { | 60 | for (auto it = avatarList.constBegin(), end = avatarList.constEnd(); it != end; ++it) { | ||
61 | const QString iconPath = (facesDir.absoluteFilePath(*it)); | 61 | const QString iconPath = (facesDir.absoluteFilePath(*it)); | ||
62 | auto *item = new QListWidgetItem(QIcon(iconPath), it->section(QLatin1Char('.'), 0, 0), ui.m_FacesWidget); | 62 | auto *item = new QListWidgetItem(QIcon(iconPath), it->section(QLatin1Char('.'), 0, 0), ui.m_FacesWidget); | ||
63 | item->setData(Qt::UserRole, iconPath); | 63 | item->setData(Qt::UserRole, iconPath); | ||
64 | } | 64 | } | ||
65 | } | 65 | } | ||
66 | 66 | | |||
67 | resize(420, 400); // FIXME | 67 | resize(420, 400); // FIXME | ||
68 | } | 68 | } | ||
69 | 69 | | |||
70 | QUrl AvatarGallery::url() const | 70 | QUrl AvatarGallery::url() const | ||
71 | { | 71 | { | ||
72 | return QUrl::fromLocalFile(ui.m_FacesWidget->currentItem()->data(Qt::UserRole).toString()); | 72 | return QUrl::fromLocalFile(ui.m_FacesWidget->currentItem()->data(Qt::UserRole).toString()); | ||
73 | } | 73 | } |