diff options
author | Gerald Combs <gerald@wireshark.org> | 2015-02-17 16:01:39 -0800 |
---|---|---|
committer | Gerald Combs <gerald@wireshark.org> | 2015-02-18 01:19:46 +0000 |
commit | b10bad126a7bb605216badebce6f4ba30eef0106 (patch) | |
tree | 1489e1902f8971e364efcf494ffc6badfd55e5c9 | |
parent | 9d1ea65f3fbcba86e1e3dfdaab52bd6a680574cd (diff) |
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>
-rw-r--r-- | ui/qt/io_graph_dialog.cpp | 3 | ||||
-rw-r--r-- | ui/qt/qcustomplot.cpp | 21 |
2 files changed, 24 insertions, 0 deletions
diff --git a/ui/qt/io_graph_dialog.cpp b/ui/qt/io_graph_dialog.cpp index 9aa5abbe56..972eb2921a 100644 --- a/ui/qt/io_graph_dialog.cpp +++ b/ui/qt/io_graph_dialog.cpp @@ -183,6 +183,7 @@ static void io_graph_free_cb(void* p) { } // extern "C" +#include <QDebug> Q_DECLARE_METATYPE(IOGraph *) IOGraphDialog::IOGraphDialog(QWidget &parent, CaptureFile &cf) : @@ -209,6 +210,7 @@ IOGraphDialog::IOGraphDialog(QWidget &parent, CaptureFile &cf) : setWindowSubtitle(tr("IO Graphs")); setAttribute(Qt::WA_DeleteOnClose, true); QCustomPlot *iop = ui->ioPlot; + qDebug() << "=iop" << iop->rect() << iop->geometry() << iop->devicePixelRatio(); QPushButton *save_bt = ui->buttonBox->button(QDialogButtonBox::Save); save_bt->setText(tr("Save As...")); @@ -259,6 +261,7 @@ IOGraphDialog::IOGraphDialog(QWidget &parent, CaptureFile &cf) : iop->plotLayout()->insertRow(0); iop->plotLayout()->addElement(0, 0, title); title->setText(tr("Wireshark IO Graphs: %1").arg(cap_file_.fileTitle())); + title->setAntialiased(false); tracer_ = new QCPItemTracer(iop); iop->addItem(tracer_); 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 } |