Skip to content

Commit

Permalink
fix: DciIcon's size too large
Browse files Browse the repository at this point in the history
  DciIcon's size is too large when app doesn't set AA_UseHighDpiPixmaps,
but pixmap will be blur when factor is greater than 1.0,
so app should set AA_UseHighDpiPixmaps.
  HighDpiPixmaps is used default in qt6.

Issue: linuxdeepin/developer-center#6246
  • Loading branch information
18202781743 committed Nov 28, 2023
1 parent 9efe9db commit 66778f2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/private/dquickiconimage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ DQUICK_BEGIN_NAMESPACE

bool DQuickIconImagePrivate::updateDevicePixelRatio(qreal targetDevicePixelRatio)
{
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
if (!qApp->testAttribute(Qt::AA_UseHighDpiPixmaps)) {
devicePixelRatio = 1.0;
return true;
}
#endif
devicePixelRatio = targetDevicePixelRatio > 1.0 ? targetDevicePixelRatio : calculateDevicePixelRatio();
return true;
}
Expand Down
4 changes: 4 additions & 0 deletions src/private/dquickimageprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,13 @@ QImage DQuickDciIconProvider::requestImage(const QString &id, QSize *size, const
// the boundingSize should typically divide by devicePixelRatio,
// see Qt::AA_UseHighDpiPixmaps.
int boundingSize = qMax(requestedSize.width(), requestedSize.height());
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
if (qApp->testAttribute(Qt::AA_UseHighDpiPixmaps)) {
boundingSize = qRound(boundingSize / devicePixelRatio);
}
#else
boundingSize = qRound(boundingSize / devicePixelRatio);
#endif

const auto currentTheme = toDciTheme(theme);
auto currentMode = mode;
Expand Down

0 comments on commit 66778f2

Please sign in to comment.