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 | |
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')
-rw-r--r-- | ui/qt5/horizon.qrc | 6 | ||||
-rw-r--r-- | ui/qt5/horizonwizardpage.cc | 28 | ||||
-rw-r--r-- | ui/qt5/horizonwizardpage.hh | 1 |
3 files changed, 19 insertions, 16 deletions
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 @@ <file>resources/network-high.png</file> <file>resources/software-high.png</file> <file>resources/software-low.png</file> + <file alias="resources/status-current-high.svg">../../assets/status-current-high.svg</file> + <file alias="resources/status-current-low.svg">../../assets/status-current-low.svg</file> + <file alias="resources/status-issue-high.svg">../../assets/status-issue-high.svg</file> + <file alias="resources/status-issue-low.svg">../../assets/status-issue-low.svg</file> + <file alias="resources/status-success-high.svg">../../assets/status-success-high.svg</file> + <file alias="resources/status-success-low.svg">../../assets/status-success-low.svg</file> </qresource> <qresource prefix="/wizard_help"> <file>resources/intro-help.txt</file> 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; }; |