diff options
author | Erik Verbruggen <erik.verbruggen@digia.com> | 2013-12-10 12:53:20 +0100 |
---|---|---|
committer | Erik Verbruggen <erik.verbruggen@digia.com> | 2013-12-10 12:53:20 +0100 |
commit | 9f831dde07cb2411808534e76669b28a1b76e21d (patch) | |
tree | ed6252d64c9a3ab27aa93786272cda1b6008f3c7 /src/libs/utils/detailsbutton.cpp | |
parent | cdac81f896ef4b052d76f96485a08e6ec13696b8 (diff) | |
parent | ea1a92484ac99057b06130a012164bf9788650e9 (diff) | |
download | qt-creator-9f831dde07cb2411808534e76669b28a1b76e21d.tar.gz |
Merge remote-tracking branch 'origin/master' into wip/clangwip/clang
Change-Id: I8a2c8068a3f2b15034fb1bf6304c9a0f3f0e3c8f
Diffstat (limited to 'src/libs/utils/detailsbutton.cpp')
-rw-r--r-- | src/libs/utils/detailsbutton.cpp | 24 |
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); |