Changeset View
Changeset View
Standalone View
Standalone View
src/lib/accountmodel.cpp
Show All 17 Lines | |||||
18 | 18 | | |||
19 | 19 | | |||
20 | #include "accountmodel.h" | 20 | #include "accountmodel.h" | ||
21 | #include "usersessions.h" | 21 | #include "usersessions.h" | ||
22 | 22 | | |||
23 | #include "accounts_interface.h" | 23 | #include "accounts_interface.h" | ||
24 | #include "user_interface.h" | 24 | #include "user_interface.h" | ||
25 | 25 | | |||
26 | #include <QApplication> | ||||
26 | #include <QIcon> | 27 | #include <QIcon> | ||
28 | #include <QStyle> | ||||
27 | 29 | | |||
28 | #include "user_manager_debug.h" | 30 | #include "user_manager_debug.h" | ||
29 | #include <KLocalizedString> | 31 | #include <KLocalizedString> | ||
30 | #include <kiconloader.h> | | |||
31 | 32 | | |||
32 | #include <KAuth/KAuthActionReply> | 33 | #include <KAuth/KAuthActionReply> | ||
33 | #include <KAuth/KAuthExecuteJob> | 34 | #include <KAuth/KAuthExecuteJob> | ||
34 | 35 | | |||
35 | #include <sys/types.h> | 36 | #include <sys/types.h> | ||
36 | #include <unistd.h> | 37 | #include <unistd.h> | ||
37 | 38 | | |||
38 | #include <KConfig> | 39 | #include <KConfig> | ||
▲ Show 20 Lines • Show All 101 Lines • ▼ Show 20 Line(s) | 140 | switch(role) { | |||
140 | case Qt::DisplayRole || AccountModel::FriendlyName: | 141 | case Qt::DisplayRole || AccountModel::FriendlyName: | ||
141 | if (!acc->realName().isEmpty()) { | 142 | if (!acc->realName().isEmpty()) { | ||
142 | return acc->realName(); | 143 | return acc->realName(); | ||
143 | } | 144 | } | ||
144 | return acc->userName(); | 145 | return acc->userName(); | ||
145 | case Qt::DecorationRole || AccountModel::Face: | 146 | case Qt::DecorationRole || AccountModel::Face: | ||
146 | { | 147 | { | ||
147 | QFile file(acc->iconFile()); | 148 | QFile file(acc->iconFile()); | ||
148 | int size = IconSize(KIconLoader::Dialog); | 149 | int size = QApplication::style()->pixelMetric(QStyle::PM_LargeIconSize); | ||
149 | if (!file.exists()) { | 150 | if (!file.exists()) { | ||
150 | return QIcon::fromTheme(QStringLiteral("user-identity")).pixmap(size, size); | 151 | return QIcon::fromTheme(QStringLiteral("user-identity")).pixmap(size, size); | ||
151 | } | 152 | } | ||
152 | auto pixMap = QPixmap(file.fileName()).scaled(static_cast<int>(size * m_dpr), static_cast<int>(size * m_dpr), Qt::KeepAspectRatio, Qt::SmoothTransformation); | 153 | auto pixMap = QPixmap(file.fileName()).scaled(static_cast<int>(size * m_dpr), static_cast<int>(size * m_dpr), Qt::KeepAspectRatio, Qt::SmoothTransformation); | ||
153 | pixMap.setDevicePixelRatio(m_dpr); | 154 | pixMap.setDevicePixelRatio(m_dpr); | ||
154 | return pixMap; | 155 | return pixMap; | ||
155 | } | 156 | } | ||
156 | case AccountModel::RealName: | 157 | case AccountModel::RealName: | ||
▲ Show 20 Lines • Show All 135 Lines • ▼ Show 20 Line(s) | |||||
292 | } | 293 | } | ||
293 | 294 | | |||
294 | QVariant AccountModel::newUserData(int role) const | 295 | QVariant AccountModel::newUserData(int role) const | ||
295 | { | 296 | { | ||
296 | switch(role) { | 297 | switch(role) { | ||
297 | case Qt::DisplayRole || AccountModel::FriendlyName: | 298 | case Qt::DisplayRole || AccountModel::FriendlyName: | ||
298 | return i18n("New User"); | 299 | return i18n("New User"); | ||
299 | case Qt::DecorationRole || AccountModel::Face: | 300 | case Qt::DecorationRole || AccountModel::Face: | ||
300 | return QIcon::fromTheme(QStringLiteral("list-add-user")).pixmap(IconSize(KIconLoader::Dialog), IconSize(KIconLoader::Dialog)); | 301 | return QIcon::fromTheme(QStringLiteral("list-add-user")); | ||
301 | case AccountModel::Created: | 302 | case AccountModel::Created: | ||
302 | return false; | 303 | return false; | ||
303 | } | 304 | } | ||
304 | return QVariant(); | 305 | return QVariant(); | ||
305 | } | 306 | } | ||
306 | 307 | | |||
307 | bool AccountModel::newUserSetData(const QModelIndex &index, const QVariant& value, int roleInt) | 308 | bool AccountModel::newUserSetData(const QModelIndex &index, const QVariant& value, int roleInt) | ||
308 | { | 309 | { | ||
▲ Show 20 Lines • Show All 241 Lines • Show Last 20 Lines |