diff --git a/src/blackgui/components/configurationwizard.ui b/src/blackgui/components/configurationwizard.ui index ccbfbce7c..accc818e3 100644 --- a/src/blackgui/components/configurationwizard.ui +++ b/src/blackgui/components/configurationwizard.ui @@ -25,6 +25,9 @@ true + + QWizard::ClassicStyle + QWizard::HaveCustomButton1 @@ -140,8 +143,8 @@ 0 0 - 98 - 28 + 90 + 20 @@ -243,7 +246,7 @@ 0 0 - 98 + 89 64 @@ -268,7 +271,7 @@ 0 0 - 98 + 75 64 diff --git a/src/blackgui/guiutility.cpp b/src/blackgui/guiutility.cpp index 17377544f..616e4454a 100644 --- a/src/blackgui/guiutility.cpp +++ b/src/blackgui/guiutility.cpp @@ -572,6 +572,29 @@ namespace BlackGui return QSizeF(w, h); } + void CGuiUtility::centerWidget(QWidget *widget) + { + const QRect screenGeometry = QApplication::desktop()->screenGeometry(); + const int x = (screenGeometry.width() - widget->width()) / 2; + const int y = (screenGeometry.height() - widget->height()) / 2; + widget->move(x, y); + } + + void CGuiUtility::centerWidget(QWidget *widget, QWidget *host) + { + if (!host) { host = widget->parentWidget(); } + + if (host) + { + const QRect hostRect = host->geometry(); + widget->move(hostRect.center() - widget->rect().center()); + } + else + { + CGuiUtility::centerWidget(widget); + } + } + QString CGuiUtility::metricsInfo() { static const QString s("%1 %2 %3 | 80 chars: w%4 h%5 | 43 chars: w%6 h%7"); diff --git a/src/blackgui/guiutility.h b/src/blackgui/guiutility.h index 1a2e8de7d..101cc4d6f 100644 --- a/src/blackgui/guiutility.h +++ b/src/blackgui/guiutility.h @@ -218,6 +218,12 @@ namespace BlackGui //! Estimate size based on current font static QSizeF fontMetricsEstimateSize(int xCharacters, int yCharacters, bool withRatio = false); + //! Center widget to host or screen + static void centerWidget(QWidget *widget); + + //! Center widget to screen + static void centerWidget(QWidget *widget, QWidget *host); + //! Some info about font metrics static QString metricsInfo(); diff --git a/src/swiftlauncher/swiftlauncher.cpp b/src/swiftlauncher/swiftlauncher.cpp index dbb8b5443..18155c72d 100644 --- a/src/swiftlauncher/swiftlauncher.cpp +++ b/src/swiftlauncher/swiftlauncher.cpp @@ -506,6 +506,7 @@ void CSwiftLauncher::startWizard() m_wizard.reset(new CConfigurationWizard(this)); } m_wizard->show(); + CGuiUtility::centerWidget(m_wizard.data(), this); } void CSwiftLauncher::onStyleSheetsChanged()