summaryrefslogtreecommitdiff
path: root/src/libs/utils/detailsbutton.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs/utils/detailsbutton.cpp')
-rw-r--r--src/libs/utils/detailsbutton.cpp24
1 files changed, 21 insertions, 3 deletions
diff --git a/src/libs/utils/detailsbutton.cpp b/src/libs/utils/detailsbutton.cpp
index 66bf24172e..43fbd74d6e 100644
--- a/src/libs/utils/detailsbutton.cpp
+++ b/src/libs/utils/detailsbutton.cpp
@@ -37,6 +37,10 @@
#include <QPainter>
#include <QStyleOption>
+#if QT_VERSION >= 0x050100
+#include <QGuiApplication>
+#endif
+
using namespace Utils;
FadingWidget::FadingWidget(QWidget *parent) :
@@ -123,12 +127,19 @@ void DetailsButton::paintEvent(QPaintEvent *e)
if (!HostOsInfo::isMacHost() && !isDown() && m_fader > 0)
p.fillRect(rect().adjusted(1, 1, -2, -2), QColor(255, 255, 255, int(m_fader*180)));
+ qreal checkedPixmapRatio = 1.0;
+ qreal uncheckedPixmapRatio = 1.0;
+#if QT_VERSION >= 0x050100
+ checkedPixmapRatio = m_checkedPixmap.devicePixelRatio();
+ uncheckedPixmapRatio = m_uncheckedPixmap.devicePixelRatio();
+#endif
+
if (isChecked()) {
- if (m_checkedPixmap.isNull() || m_checkedPixmap.size() != contentsRect().size())
+ if (m_checkedPixmap.isNull() || m_checkedPixmap.size() / checkedPixmapRatio != contentsRect().size())
m_checkedPixmap = cacheRendering(contentsRect().size(), true);
p.drawPixmap(contentsRect(), m_checkedPixmap);
} else {
- if (m_uncheckedPixmap.isNull() || m_uncheckedPixmap.size() != contentsRect().size())
+ if (m_uncheckedPixmap.isNull() || m_uncheckedPixmap.size() / uncheckedPixmapRatio != contentsRect().size())
m_uncheckedPixmap = cacheRendering(contentsRect().size(), false);
p.drawPixmap(contentsRect(), m_uncheckedPixmap);
}
@@ -145,7 +156,14 @@ QPixmap DetailsButton::cacheRendering(const QSize &size, bool checked)
lg.setCoordinateMode(QGradient::ObjectBoundingMode);
lg.setFinalStop(0, 1);
- QPixmap pixmap(size);
+ qreal pixelRatio = 1.0;
+#if QT_VERSION >= 0x050100
+ pixelRatio = devicePixelRatio();
+#endif
+ QPixmap pixmap(size * pixelRatio);
+#if QT_VERSION >= 0x050100
+ pixmap.setDevicePixelRatio(pixelRatio);
+#endif
pixmap.fill(Qt::transparent);
QPainter p(&pixmap);
p.setRenderHint(QPainter::Antialiasing, true);