┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/views
diff options
context:
space:
mode:
authorKai Uwe Broulik <[email protected]>2023-11-20 14:16:18 +0100
committerKai Uwe Broulik <[email protected]>2023-11-21 13:53:54 +0100
commitecd3675aaa55b8224f1fa81b031471d834a18fad (patch)
tree11722acc75ab4f5c2a345b0b7880c24957d3ee2d /src/views
parent26adfe689a70af60933809c6106723ff5962b67e (diff)
views: Use scene devicePixelRatio rather than qApp
When possible, use the devicePixelRatio from the scene which on Wayland unlike the QApplication will properly support fractional scaling. A KItemViewsUtils class is introduced that can be reused elsewhere.
Diffstat (limited to 'src/views')
-rw-r--r--src/views/dolphinfileitemlistwidget.cpp6
-rw-r--r--src/views/dolphinfileitemlistwidget.h2
2 files changed, 5 insertions, 3 deletions
diff --git a/src/views/dolphinfileitemlistwidget.cpp b/src/views/dolphinfileitemlistwidget.cpp
index 921baf73f..11c88d402 100644
--- a/src/views/dolphinfileitemlistwidget.cpp
+++ b/src/views/dolphinfileitemlistwidget.cpp
@@ -5,6 +5,7 @@
*/
#include "dolphinfileitemlistwidget.h"
+#include "../kitemviews/private/kitemviewsutils.h"
#include "dolphindebug.h"
@@ -77,7 +78,7 @@ void DolphinFileItemListWidget::refreshCache()
setTextColor(color);
}
-QPixmap DolphinFileItemListWidget::overlayForState(KVersionControlPlugin::ItemVersion version, int size)
+QPixmap DolphinFileItemListWidget::overlayForState(KVersionControlPlugin::ItemVersion version, int size) const
{
int overlayHeight = KIconLoader::SizeSmall;
if (size >= KIconLoader::SizeEnormous) {
@@ -122,7 +123,8 @@ QPixmap DolphinFileItemListWidget::overlayForState(KVersionControlPlugin::ItemVe
break;
}
- return QIcon::fromTheme(iconName).pixmap(QSize(overlayHeight, overlayHeight));
+ const qreal dpr = KItemViewsUtils::devicePixelRatio(this);
+ return QIcon::fromTheme(iconName).pixmap(QSize(overlayHeight, overlayHeight), dpr);
}
#include "moc_dolphinfileitemlistwidget.cpp"
diff --git a/src/views/dolphinfileitemlistwidget.h b/src/views/dolphinfileitemlistwidget.h
index ac98666c8..92fc66fcc 100644
--- a/src/views/dolphinfileitemlistwidget.h
+++ b/src/views/dolphinfileitemlistwidget.h
@@ -29,7 +29,7 @@ protected:
void refreshCache() override;
private:
- static QPixmap overlayForState(KVersionControlPlugin::ItemVersion version, int size);
+ QPixmap overlayForState(KVersionControlPlugin::ItemVersion version, int size) const;
};
#endif