Commit b08bf848 authored by Eike Ziller's avatar Eike Ziller
Browse files

Mac/Retina: Fix painting of "Details" button



For example in the projects mode

Task-number: QTCREATORBUG-10917
Change-Id: Ic6bcc10f9794451101d56b1871b37768641bac35
Reviewed-by: default avatarDaniel Teske <daniel.teske@digia.com>
Reviewed-by: default avatarTobias Hunger <tobias.hunger@digia.com>
Reviewed-by: default avatarErik Verbruggen <erik.verbruggen@digia.com>
parent 60406e92
......@@ -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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment