From 56740b68ea97d8d30ba92a505d74f0a9ddc4d50b Mon Sep 17 00:00:00 2001 From: "A. Wilcox" Date: Fri, 15 Nov 2019 10:55:45 -0600 Subject: Qt UI: Add status assets, factor DPI-aware pixmap loader into fn --- ui/qt5/horizon.qrc | 6 ++++++ ui/qt5/horizonwizardpage.cc | 28 ++++++++++++---------------- ui/qt5/horizonwizardpage.hh | 1 + 3 files changed, 19 insertions(+), 16 deletions(-) (limited to 'ui') diff --git a/ui/qt5/horizon.qrc b/ui/qt5/horizon.qrc index 5e740b6..9af8207 100644 --- a/ui/qt5/horizon.qrc +++ b/ui/qt5/horizon.qrc @@ -6,6 +6,12 @@ resources/network-high.png resources/software-high.png resources/software-low.png + ../../assets/status-current-high.svg + ../../assets/status-current-low.svg + ../../assets/status-issue-high.svg + ../../assets/status-issue-low.svg + ../../assets/status-success-high.svg + ../../assets/status-success-low.svg resources/intro-help.txt 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); } diff --git a/ui/qt5/horizonwizardpage.hh b/ui/qt5/horizonwizardpage.hh index 4ddb160..6ed8a6e 100644 --- a/ui/qt5/horizonwizardpage.hh +++ b/ui/qt5/horizonwizardpage.hh @@ -22,6 +22,7 @@ class HorizonWizardPage : public QWizardPage { public: HorizonWizardPage(QWidget *parent = 0) : QWizardPage(parent) {} + QPixmap loadDPIAwarePixmap(std::string pixmap, std::string type = ".png"); void loadWatermark(std::string page); HorizonWizard *horizonWizard() const; }; -- cgit v1.2.3-60-g2f50