┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/kitemviews/private
diff options
context:
space:
mode:
authorDavid Edmundson <[email protected]>2015-03-26 16:06:52 +0100
committerDavid Edmundson <[email protected]>2015-03-26 16:06:52 +0100
commit35c0972671c1f90f76d8d86b002b2e1f8bac79dd (patch)
treebf2e413b7a7cf01baadec42ef2c779f6523e2a4b /src/kitemviews/private
parent00b00d2371e0f65da0c6bf30775ae43f536ab807 (diff)
Make KPixmapModifier::applyFrame handle high DPI images
Diffstat (limited to 'src/kitemviews/private')
-rw-r--r--src/kitemviews/private/kpixmapmodifier.cpp10
-rw-r--r--src/kitemviews/private/kpixmapmodifier.h17
2 files changed, 23 insertions, 4 deletions
diff --git a/src/kitemviews/private/kpixmapmodifier.cpp b/src/kitemviews/private/kpixmapmodifier.cpp
index ee1f84366..3e0edf02c 100644
--- a/src/kitemviews/private/kpixmapmodifier.cpp
+++ b/src/kitemviews/private/kpixmapmodifier.cpp
@@ -374,14 +374,16 @@ void KPixmapModifier::scale(QPixmap& pixmap, const QSize& scaledSize)
void KPixmapModifier::applyFrame(QPixmap& icon, const QSize& scaledSize)
{
static TileSet tileSet;
+ qreal dpr = icon.devicePixelRatio();
// Resize the icon to the maximum size minus the space required for the frame
- const QSize size(scaledSize.width() - TileSet::LeftMargin - TileSet::RightMargin,
- scaledSize.height() - TileSet::TopMargin - TileSet::BottomMargin);
+ const QSize size(scaledSize.width() - (TileSet::LeftMargin + TileSet::RightMargin) * dpr,
+ scaledSize.height() - (TileSet::TopMargin + TileSet::BottomMargin) * dpr);
scale(icon, size);
- QPixmap framedIcon(icon.size().width() + TileSet::LeftMargin + TileSet::RightMargin,
- icon.size().height() + TileSet::TopMargin + TileSet::BottomMargin);
+ QPixmap framedIcon(icon.size().width() + (TileSet::LeftMargin + TileSet::RightMargin) * dpr,
+ icon.size().height() + (TileSet::TopMargin + TileSet::BottomMargin * dpr) );
+ framedIcon.setDevicePixelRatio(dpr);
framedIcon.fill(Qt::transparent);
QPainter painter;
diff --git a/src/kitemviews/private/kpixmapmodifier.h b/src/kitemviews/private/kpixmapmodifier.h
index e8ca11ac1..9089a1001 100644
--- a/src/kitemviews/private/kpixmapmodifier.h
+++ b/src/kitemviews/private/kpixmapmodifier.h
@@ -28,8 +28,25 @@ class QSize;
class DOLPHIN_EXPORT KPixmapModifier
{
public:
+ /**
+ * Scale a pixmap to a given size.
+ * @arg scaledSize is assumed to be the scaled to the same device pixel ratio as the source pixmap
+ * @arg scaledSize is in device pixels
+ */
static void scale(QPixmap& pixmap, const QSize& scaledSize);
+
+ /**
+ * Resize and paint a frame round an icon
+ * @arg scaledSize is assumed to be the scaled to the same device pixel ratio as the source icon
+ */
static void applyFrame(QPixmap& icon, const QSize& scaledSize);
+
+ /**
+ * return and paint a frame round an icon
+ * @arg framesize is in device-independent pixels
+ * @return is in device-indepent pixels
+ */
+
static QSize sizeInsideFrame(const QSize& frameSize);
};