diff --git a/src/accountinfo.cpp b/src/accountinfo.cpp --- a/src/accountinfo.cpp +++ b/src/accountinfo.cpp @@ -47,6 +47,10 @@ { 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->realName, &QLineEdit::textEdited, this, &AccountInfo::hasChanged); connect(m_info->email, &QLineEdit::textEdited, this, &AccountInfo::hasChanged); diff --git a/src/lib/accountmodel.h b/src/lib/accountmodel.h --- a/src/lib/accountmodel.h +++ b/src/lib/accountmodel.h @@ -65,6 +65,7 @@ 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 removeAccountKeepingFiles(int row, bool keepFile = false); + void setDpr(qreal dpr); QVariant newUserData(int role) const; bool newUserSetData(const QModelIndex& index, const QVariant& value, int roleInt); @@ -91,6 +92,7 @@ QHash m_loggedAccounts; KEMailSettings m_kEmailSettings; AutomaticLoginSettings m_autoLoginSettings; + qreal dpr = 1; }; QDebug operator<<(QDebug debug, AccountModel::Role role); diff --git a/src/lib/accountmodel.cpp b/src/lib/accountmodel.cpp --- a/src/lib/accountmodel.cpp +++ b/src/lib/accountmodel.cpp @@ -149,7 +149,9 @@ if (!file.exists()) { 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(size * dpr), static_cast(size * dpr), Qt::KeepAspectRatio, Qt::SmoothTransformation); + pixMap.setDevicePixelRatio(dpr); + return pixMap; } case AccountModel::RealName: return acc->realName(); @@ -539,4 +541,8 @@ return debug; } +void AccountModel::setDpr(qreal dpr) { + this->dpr = dpr; +} +