]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/kitemviews/private/kpixmapmodifier.cpp
review comments
[dolphin.git] / src / kitemviews / private / kpixmapmodifier.cpp
index 29aceb66b65a9521ec986ec6fc506684f4efc2aa..4693b313abde034edb6cf13d388297c7171a31e4 100644 (file)
@@ -38,8 +38,8 @@
 #include <QPainter>
 #include <QPixmap>
 #include <QSize>
 #include <QPainter>
 #include <QPixmap>
 #include <QSize>
+#include <QGuiApplication>
 
 
-#include <KDebug>
 
 #include <config-X11.h> // for HAVE_XRENDER
 #if defined(Q_WS_X11) && defined(HAVE_XRENDER)
 
 #include <config-X11.h> // for HAVE_XRENDER
 #if defined(Q_WS_X11) && defined(HAVE_XRENDER)
@@ -348,6 +348,7 @@ void KPixmapModifier::scale(QPixmap& pixmap, const QSize& scaledSize)
         }};
 
         QPixmap scaledPixmap(scaledPixmapSize);
         }};
 
         QPixmap scaledPixmap(scaledPixmapSize);
+        scaledPixmap.setDevicePixelRatio(pixmap.devicePixelRatio());
         scaledPixmap.fill(Qt::transparent);
 
         Display* dpy = QX11Info::display();
         scaledPixmap.fill(Qt::transparent);
 
         Display* dpy = QX11Info::display();
@@ -365,27 +366,32 @@ void KPixmapModifier::scale(QPixmap& pixmap, const QSize& scaledSize)
         pixmap = pixmap.scaled(scaledSize, Qt::KeepAspectRatio, Qt::SmoothTransformation);
     }
 #else
         pixmap = pixmap.scaled(scaledSize, Qt::KeepAspectRatio, Qt::SmoothTransformation);
     }
 #else
+    qreal dpr = pixmap.devicePixelRatio();
     pixmap = pixmap.scaled(scaledSize, Qt::KeepAspectRatio, Qt::SmoothTransformation);
     pixmap = pixmap.scaled(scaledSize, Qt::KeepAspectRatio, Qt::SmoothTransformation);
+    pixmap.setDevicePixelRatio(dpr);
 #endif
 }
 
 void KPixmapModifier::applyFrame(QPixmap& icon, const QSize& scaledSize)
 {
     static TileSet tileSet;
 #endif
 }
 
 void KPixmapModifier::applyFrame(QPixmap& icon, const QSize& scaledSize)
 {
     static TileSet tileSet;
+    qreal dpr = qApp->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);
 
     // 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);
-    scale(icon, size);
+    scale(icon, size * dpr);
+    icon.setDevicePixelRatio(dpr);
 
 
-    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;
     painter.begin(&framedIcon);
     painter.setCompositionMode(QPainter::CompositionMode_Source);
     framedIcon.fill(Qt::transparent);
 
     QPainter painter;
     painter.begin(&framedIcon);
     painter.setCompositionMode(QPainter::CompositionMode_Source);
-    tileSet.paint(&painter, framedIcon.rect());
+    tileSet.paint(&painter, QRect(QPoint(0,0), framedIcon.size() / dpr));
     painter.setCompositionMode(QPainter::CompositionMode_SourceOver);
     painter.drawPixmap(TileSet::LeftMargin, TileSet::TopMargin, icon);
 
     painter.setCompositionMode(QPainter::CompositionMode_SourceOver);
     painter.drawPixmap(TileSet::LeftMargin, TileSet::TopMargin, icon);