diff options
author | A. Wilcox <AWilcox@Wilcox-Tech.com> | 2019-11-15 10:55:45 -0600 |
---|---|---|
committer | A. Wilcox <AWilcox@Wilcox-Tech.com> | 2019-11-15 10:55:45 -0600 |
commit | 56740b68ea97d8d30ba92a505d74f0a9ddc4d50b (patch) | |
tree | 48891e002a2313f7b63201c4aa37f10cc9e3b9f0 /ui/qt5/horizonwizardpage.cc | |
parent | ff8d9e8fcecc3cc8ace64b6cdeafdb11cf9854f3 (diff) | |
download | horizon-56740b68ea97d8d30ba92a505d74f0a9ddc4d50b.tar.gz horizon-56740b68ea97d8d30ba92a505d74f0a9ddc4d50b.tar.bz2 horizon-56740b68ea97d8d30ba92a505d74f0a9ddc4d50b.tar.xz horizon-56740b68ea97d8d30ba92a505d74f0a9ddc4d50b.zip |
Qt UI: Add status assets, factor DPI-aware pixmap loader into fn
Diffstat (limited to 'ui/qt5/horizonwizardpage.cc')
-rw-r--r-- | ui/qt5/horizonwizardpage.cc | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/ui/qt5/horizonwizardpage.cc b/ui/qt5/horizonwizardpage.cc index f707876..352de0e 100644 --- a/ui/qt5/horizonwizardpage.cc +++ b/ui/qt5/horizonwizardpage.cc @@ -14,41 +14,37 @@ using std::string; -void HorizonWizardPage::loadWatermark(string page) { - QPixmap pixmap; - qreal pixelRatio = 0; +QPixmap HorizonWizardPage::loadDPIAwarePixmap(string pixmap, string type) { string path = ":/wizard_pixmaps/resources/"; - path += page; + path += pixmap; path += "-"; - if(window()->devicePixelRatioF() == 2.0) { - path += "high"; - pixelRatio = 2.0; - } else if(window()->devicePixelRatioF() == 1.0) { + if(window()->devicePixelRatioF() <= 1.0) { path += "low"; - pixelRatio = 1.0; } else { path += "high"; } - path += ".png"; + path += type; + return QPixmap(path.c_str()); +} - pixmap = QPixmap(path.c_str()); +void HorizonWizardPage::loadWatermark(string page) { + QPixmap pixmap = loadDPIAwarePixmap(page); + qreal pixelRatio = window()->devicePixelRatioF(); // Handle cases where ratio is not exactly 1.0 or 2.0 // Wizard machinary automatically uses FastTransformation, which is // ugly as sin. if(pixelRatio > 1.0) { - qreal width = 232 * window()->devicePixelRatioF(); - qreal height = 380 * window()->devicePixelRatioF(); + qreal width = 232 * pixelRatio; + qreal height = 380 * pixelRatio; QSize newSize = QSize(width, height); pixmap = pixmap.scaled(newSize, Qt::KeepAspectRatio, Qt::SmoothTransformation); - pixmap.setDevicePixelRatio(window()->devicePixelRatioF()); - } else { - pixmap.setDevicePixelRatio(pixelRatio); } + pixmap.setDevicePixelRatio(pixelRatio); setPixmap(QWizard::WatermarkPixmap, pixmap); } |