summaryrefslogtreecommitdiff
path: root/ui/qt/qcustomplot.cpp
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2015-02-17 16:01:39 -0800
committerGerald Combs <gerald@wireshark.org>2015-02-18 01:19:46 +0000
commitb10bad126a7bb605216badebce6f4ba30eef0106 (patch)
tree1489e1902f8971e364efcf494ffc6badfd55e5c9 /ui/qt/qcustomplot.cpp
parent9d1ea65f3fbcba86e1e3dfdaab52bd6a680574cd (diff)
downloadwireshark-b10bad126a7bb605216badebce6f4ba30eef0106.tar.gz
Fix QCustmPlot retina problems.
Make sure our intermediate pixmaps have the same number of pixels as the screen. A merge request with the same changes has been made upstream. Change-Id: I19950181d52f347e3aa7f5abb6e9ad33a4097abf Reviewed-on: https://code.wireshark.org/review/7224 Reviewed-by: Gerald Combs <gerald@wireshark.org>
Diffstat (limited to 'ui/qt/qcustomplot.cpp')
-rw-r--r--ui/qt/qcustomplot.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/ui/qt/qcustomplot.cpp b/ui/qt/qcustomplot.cpp
index c92382e2de..398bdacee0 100644
--- a/ui/qt/qcustomplot.cpp
+++ b/ui/qt/qcustomplot.cpp
@@ -6398,7 +6398,14 @@ void QCPAxisPainterPrivate::placeTickLabel(QCPPainter *painter, double position,
CachedLabel *newCachedLabel = new CachedLabel;
TickLabelData labelData = getTickLabelData(painter->font(), text);
newCachedLabel->offset = getTickLabelDrawOffset(labelData)+labelData.rotatedTotalBounds.topLeft();
+#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
+ QSize clSize = labelData.rotatedTotalBounds.size();
+ clSize *= painter->device()->devicePixelRatio();
+ newCachedLabel->pixmap = QPixmap(clSize);
+ newCachedLabel->pixmap.setDevicePixelRatio(painter->device()->devicePixelRatio());
+#else
newCachedLabel->pixmap = QPixmap(labelData.rotatedTotalBounds.size());
+#endif
newCachedLabel->pixmap.fill(Qt::transparent);
QCPPainter cachePainter(&newCachedLabel->pixmap);
cachePainter.setPen(painter->pen());
@@ -9064,6 +9071,13 @@ QCustomPlot::QCustomPlot(QWidget *parent) :
currentLocale.setNumberOptions(QLocale::OmitGroupSeparator);
setLocale(currentLocale);
+#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
+ QSize pbSize = mPaintBuffer.size();
+ pbSize *= devicePixelRatio();
+ mPaintBuffer = QPixmap(pbSize);
+ mPaintBuffer.setDevicePixelRatio(devicePixelRatio());
+#endif
+
// create initial layers:
mLayers.append(new QCPLayer(this, QLatin1String("background")));
mLayers.append(new QCPLayer(this, QLatin1String("grid")));
@@ -10683,7 +10697,14 @@ void QCustomPlot::paintEvent(QPaintEvent *event)
void QCustomPlot::resizeEvent(QResizeEvent *event)
{
// resize and repaint the buffer:
+#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
+ QSize pbSize = event->size();
+ pbSize *= devicePixelRatio();
+ mPaintBuffer = QPixmap(pbSize);
+ mPaintBuffer.setDevicePixelRatio(devicePixelRatio());
+#else
mPaintBuffer = QPixmap(event->size());
+#endif
setViewport(rect());
replot(rpQueued); // queued update is important here, to prevent painting issues in some contexts
}