summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorA. Wilcox <AWilcox@Wilcox-Tech.com>2016-09-28 07:03:36 -0500
committerA. Wilcox <AWilcox@Wilcox-Tech.com>2016-09-28 07:03:36 -0500
commitc9bbd46209e4802864b973131aacad6c42bc6ce0 (patch)
treef3064870df123a2fdca202c1e306d866223ac546
parentca8ac59c94ca6131f35c0789d65601d7a9609be8 (diff)
downloadhorizon-qt5-c9bbd46209e4802864b973131aacad6c42bc6ce0.tar.gz
horizon-qt5-c9bbd46209e4802864b973131aacad6c42bc6ce0.tar.bz2
horizon-qt5-c9bbd46209e4802864b973131aacad6c42bc6ce0.tar.xz
horizon-qt5-c9bbd46209e4802864b973131aacad6c42bc6ce0.zip
HiDPI fixes
-rw-r--r--horizon-qt5.pro6
-rw-r--r--horizonwizard.cc4
-rw-r--r--horizonwizardpage.cc45
-rw-r--r--horizonwizardpage.hh15
-rw-r--r--networkingpage.cc2
-rw-r--r--networkingpage.hh4
-rw-r--r--welcomepage.cc5
-rw-r--r--welcomepage.hh4
8 files changed, 72 insertions, 13 deletions
diff --git a/horizon-qt5.pro b/horizon-qt5.pro
index e1f68ba..7d96e3a 100644
--- a/horizon-qt5.pro
+++ b/horizon-qt5.pro
@@ -9,12 +9,14 @@ TEMPLATE = app
SOURCES += main.cc \
horizonwizard.cc \
welcomepage.cc \
- networkingpage.cc
+ networkingpage.cc \
+ horizonwizardpage.cc
HEADERS += \
horizonwizard.hh \
welcomepage.hh \
- networkingpage.hh
+ networkingpage.hh \
+ horizonwizardpage.hh
RESOURCES += \
horizon.qrc
diff --git a/horizonwizard.cc b/horizonwizard.cc
index 4e8e89a..d956694 100644
--- a/horizonwizard.cc
+++ b/horizonwizard.cc
@@ -5,11 +5,9 @@
HorizonWizard::HorizonWizard(QWidget *parent) : QWizard(parent)
{
- int scaleFactor = window()->devicePixelRatio();
-
setWindowTitle(tr("Adélie Linux System Installation"));
- setFixedSize(QSize(600 * scaleFactor, 450 * scaleFactor));
+ setFixedSize(QSize(600, 450));
setOption(DisabledBackButtonOnLastPage);
setOption(HaveHelpButton);
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);
+}
diff --git a/horizonwizardpage.hh b/horizonwizardpage.hh
new file mode 100644
index 0000000..65b292c
--- /dev/null
+++ b/horizonwizardpage.hh
@@ -0,0 +1,15 @@
+#ifndef HORIZONWIZARDPAGE_HH
+#define HORIZONWIZARDPAGE_HH
+
+#include <QWizardPage>
+#include <string>
+
+class HorizonWizardPage : public QWizardPage
+{
+public:
+ HorizonWizardPage(QWidget *parent = 0) : QWizardPage(parent) {}
+
+ void loadWatermark(std::string page);
+};
+
+#endif // HORIZONWIZARDPAGE_HH
diff --git a/networkingpage.cc b/networkingpage.cc
index 9d33cc8..cc3aeb3 100644
--- a/networkingpage.cc
+++ b/networkingpage.cc
@@ -1,6 +1,6 @@
#include "networkingpage.hh"
-NetworkingPage::NetworkingPage(QWidget *parent) : QWizardPage(parent)
+NetworkingPage::NetworkingPage(QWidget *parent) : HorizonWizardPage(parent)
{
setTitle(tr("Network Setup"));
}
diff --git a/networkingpage.hh b/networkingpage.hh
index 03e1210..bf517f8 100644
--- a/networkingpage.hh
+++ b/networkingpage.hh
@@ -1,9 +1,9 @@
#ifndef NETWORKINGPAGE_HH
#define NETWORKINGPAGE_HH
-#include <QWizardPage>
+#include "horizonwizardpage.hh"
-class NetworkingPage : public QWizardPage
+class NetworkingPage : public HorizonWizardPage
{
public:
NetworkingPage(QWidget *parent = 0);
diff --git a/welcomepage.cc b/welcomepage.cc
index c41b7c5..1fee9c5 100644
--- a/welcomepage.cc
+++ b/welcomepage.cc
@@ -3,14 +3,13 @@
#include <QLabel>
#include <QVBoxLayout>
-WelcomePage::WelcomePage(QWidget *parent) : QWizardPage(parent)
+WelcomePage::WelcomePage(QWidget *parent) : HorizonWizardPage(parent)
{
QLabel *descLabel;
+ loadWatermark("welcome");
setTitle(tr("Welcome to Adélie Linux"));
- setPixmap(QWizard::WatermarkPixmap,
- QPixmap(":/wizard_pixmaps/resources/welcome-low.png"));
descLabel = new QLabel(
tr("This process will only take about 10-15 minutes of "
"your time. After you're done, your computer will "
diff --git a/welcomepage.hh b/welcomepage.hh
index c9d4981..344ac33 100644
--- a/welcomepage.hh
+++ b/welcomepage.hh
@@ -1,9 +1,9 @@
#ifndef WELCOMEPAGE_HH
#define WELCOMEPAGE_HH
-#include <QWizardPage>
+#include "horizonwizardpage.hh"
-class WelcomePage : public QWizardPage
+class WelcomePage : public HorizonWizardPage
{
public:
WelcomePage(QWidget *parent = 0);