From c9bbd46209e4802864b973131aacad6c42bc6ce0 Mon Sep 17 00:00:00 2001 From: "A. Wilcox" Date: Wed, 28 Sep 2016 07:03:36 -0500 Subject: HiDPI fixes --- horizonwizardpage.cc | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 horizonwizardpage.cc (limited to 'horizonwizardpage.cc') diff --git a/horizonwizardpage.cc b/horizonwizardpage.cc new file mode 100644 index 0000000..97cdbef --- /dev/null +++ b/horizonwizardpage.cc @@ -0,0 +1,45 @@ +#include "horizonwizardpage.hh" + +using std::string; + +void HorizonWizardPage::loadWatermark(string page) +{ + QPixmap pixmap; + qreal pixelRatio = 0; + string path = ":/wizard_pixmaps/resources/"; + path += page; + path += "-"; + + if(window()->devicePixelRatioF() == 2.0) + { + path += "high"; + pixelRatio = 2.0; + } else if(window()->devicePixelRatioF() == 1.0) { + path += "low"; + pixelRatio = 1.0; + } else { + path += "high"; + } + + path += ".png"; + + pixmap = QPixmap(path.c_str()); + + // Handle cases where ratio is not exactly 1.0 or 2.0 + // Wizard machinary automatically uses FastTransformation, which is + // ugly as sin. + if(pixelRatio == 0) + { + qreal width = 232 * window()->devicePixelRatioF(); + qreal height = 380 * window()->devicePixelRatioF(); + QSize newSize = QSize(width, height); + + pixmap = pixmap.scaled(newSize, Qt::KeepAspectRatio, + Qt::SmoothTransformation); + pixmap.setDevicePixelRatio(window()->devicePixelRatioF()); + } else { + pixmap.setDevicePixelRatio(pixelRatio); + } + + setPixmap(QWizard::WatermarkPixmap, pixmap); +} -- cgit v1.2.3-70-g09d2