Commit a6f37349 authored by Méven Car's avatar Méven Car
Browse files

Make avatar icon dpr aware aka HiDPI rendered

Test Plan: Locally tested under Wayland : couldn't make a screenshot because of https://bugs.kde.org/show_bug.cgi?id=409762

Reviewers: #plasma, ngraham

Reviewed By: ngraham

Subscribers: crossi, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D25395
parent 66cdd068
...@@ -47,6 +47,10 @@ AccountInfo::AccountInfo(AccountModel* model, QWidget* parent, Qt::WindowFlags f ...@@ -47,6 +47,10 @@ AccountInfo::AccountInfo(AccountModel* model, QWidget* parent, Qt::WindowFlags f
{ {
m_info->setupUi(this); m_info->setupUi(this);
// ensure avatar user icon use correct device pixel ratio
const qreal dpr = qApp->devicePixelRatio();
m_model->setDpr(dpr);
connect(m_info->username, &QLineEdit::textEdited, this, &AccountInfo::hasChanged); connect(m_info->username, &QLineEdit::textEdited, this, &AccountInfo::hasChanged);
connect(m_info->realName, &QLineEdit::textEdited, this, &AccountInfo::hasChanged); connect(m_info->realName, &QLineEdit::textEdited, this, &AccountInfo::hasChanged);
connect(m_info->email, &QLineEdit::textEdited, this, &AccountInfo::hasChanged); connect(m_info->email, &QLineEdit::textEdited, this, &AccountInfo::hasChanged);
......
...@@ -149,7 +149,9 @@ QVariant AccountModel::data(const QModelIndex& index, int role) const ...@@ -149,7 +149,9 @@ QVariant AccountModel::data(const QModelIndex& index, int role) const
if (!file.exists()) { if (!file.exists()) {
return QIcon::fromTheme(QStringLiteral("user-identity")).pixmap(size, size); return QIcon::fromTheme(QStringLiteral("user-identity")).pixmap(size, size);
} }
return QPixmap(file.fileName()).scaled(size, size, Qt::KeepAspectRatio, Qt::SmoothTransformation); auto pixMap = QPixmap(file.fileName()).scaled(static_cast<int>(size * m_dpr), static_cast<int>(size * m_dpr), Qt::KeepAspectRatio, Qt::SmoothTransformation);
pixMap.setDevicePixelRatio(m_dpr);
return pixMap;
} }
case AccountModel::RealName: case AccountModel::RealName:
return acc->realName(); return acc->realName();
...@@ -539,4 +541,8 @@ QDebug operator<<(QDebug debug, AccountModel::Role role) ...@@ -539,4 +541,8 @@ QDebug operator<<(QDebug debug, AccountModel::Role role)
return debug; return debug;
} }
void AccountModel::setDpr(qreal dpr) {
m_dpr = dpr;
}
...@@ -65,6 +65,7 @@ class AccountModel : public QAbstractListModel ...@@ -65,6 +65,7 @@ class AccountModel : public QAbstractListModel
bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) override; bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) override;
bool removeRows(int row, int count, const QModelIndex& parent = QModelIndex()) override; bool removeRows(int row, int count, const QModelIndex& parent = QModelIndex()) override;
bool removeAccountKeepingFiles(int row, bool keepFile = false); bool removeAccountKeepingFiles(int row, bool keepFile = false);
void setDpr(qreal dpr);
QVariant newUserData(int role) const; QVariant newUserData(int role) const;
bool newUserSetData(const QModelIndex& index, const QVariant& value, int roleInt); bool newUserSetData(const QModelIndex& index, const QVariant& value, int roleInt);
...@@ -91,6 +92,7 @@ class AccountModel : public QAbstractListModel ...@@ -91,6 +92,7 @@ class AccountModel : public QAbstractListModel
QHash<QString, bool> m_loggedAccounts; QHash<QString, bool> m_loggedAccounts;
KEMailSettings m_kEmailSettings; KEMailSettings m_kEmailSettings;
AutomaticLoginSettings m_autoLoginSettings; AutomaticLoginSettings m_autoLoginSettings;
qreal m_dpr = 1;
}; };
QDebug operator<<(QDebug debug, AccountModel::Role role); QDebug operator<<(QDebug debug, AccountModel::Role role);
......
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