diff options
author | Eike Ziller <eike.ziller@digia.com> | 2013-11-28 11:10:39 +0100 |
---|---|---|
committer | Eike Ziller <eike.ziller@digia.com> | 2013-11-29 10:43:05 +0100 |
commit | b08bf8488c65f5411e12da1d97a35a70fc3ed785 (patch) | |
tree | 775238dcaedea2f863cc8659cfb91618c8212284 /src/libs/utils/detailsbutton.cpp | |
parent | 60406e92fb1d8bb3796d73bb0b267a3301530898 (diff) |
Mac/Retina: Fix painting of "Details" button
For example in the projects mode
Task-number: QTCREATORBUG-10917
Change-Id: Ic6bcc10f9794451101d56b1871b37768641bac35
Reviewed-by: Daniel Teske <daniel.teske@digia.com>
Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
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 66bf24172ed..43fbd74d6ef 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); |