diff options
Diffstat (limited to 'application')
-rw-r--r-- | application/MultiMC.cpp | 71 | ||||
-rw-r--r-- | application/MultiMC.h | 1 | ||||
-rw-r--r-- | application/setupwizard/AnalyticsWizardPage.cpp | 19 | ||||
-rw-r--r-- | application/setupwizard/AnalyticsWizardPage.h | 1 | ||||
-rw-r--r-- | application/setupwizard/JavaWizardPage.cpp | 18 | ||||
-rw-r--r-- | application/setupwizard/JavaWizardPage.h | 1 | ||||
-rw-r--r-- | application/setupwizard/LanguageWizardPage.cpp | 8 | ||||
-rw-r--r-- | application/setupwizard/LanguageWizardPage.h | 2 | ||||
-rw-r--r-- | application/setupwizard/SetupWizard.cpp | 32 | ||||
-rw-r--r-- | application/setupwizard/SetupWizard.h | 3 |
10 files changed, 69 insertions, 87 deletions
diff --git a/application/MultiMC.cpp b/application/MultiMC.cpp index 2f752904..081de41c 100644 --- a/application/MultiMC.cpp +++ b/application/MultiMC.cpp @@ -18,6 +18,9 @@ #include "themes/CustomTheme.h" #include "setupwizard/SetupWizard.h" +#include "setupwizard/LanguageWizardPage.h" +#include "setupwizard/JavaWizardPage.h" +#include "setupwizard/AnalyticsWizardPage.h" #include <iostream> #include <QDir> @@ -359,14 +362,76 @@ MultiMC::MultiMC(int &argc, char **argv) : QApplication(argc, argv) initAnalytics(); - if(SetupWizard::isRequired()) + if(createSetupWizard()) + { + return; + } + performMainStartupAction(); +} + +bool MultiMC::createSetupWizard() +{ + bool javaRequired = [&]() + { + QString currentHostName = QHostInfo::localHostName(); + QString oldHostName = settings()->get("LastHostname").toString(); + if (currentHostName != oldHostName) + { + settings()->set("LastHostname", currentHostName); + return true; + } + QString currentJavaPath = settings()->get("JavaPath").toString(); + QString actualPath = FS::ResolveExecutable(currentJavaPath); + if (actualPath.isNull()) + { + return true; + } + return false; + }(); + bool analyticsRequired = [&]() + { + if(BuildConfig.ANALYTICS_ID.isEmpty()) + { + return false; + } + if (!settings()->get("Analytics").toBool()) + { + return false; + } + if (settings()->get("AnalyticsSeen").toInt() < analytics()->version()) + { + return true; + } + return false; + }(); + bool languageRequired = [&]() + { + if (settings()->get("Language").toString().isEmpty()) + return true; + return false; + }(); + bool wizardRequired = javaRequired || analyticsRequired || languageRequired; + + if(wizardRequired) { m_setupWizard = new SetupWizard(nullptr); + if (languageRequired) + { + m_setupWizard->addPage(new LanguageWizardPage(m_setupWizard)); + } + if (javaRequired) + { + m_setupWizard->addPage(new JavaWizardPage(m_setupWizard)); + } + if(analyticsRequired) + { + m_setupWizard->addPage(new AnalyticsWizardPage(m_setupWizard)); + } connect(m_setupWizard, &QDialog::finished, this, &MultiMC::setupWizardFinished); m_setupWizard->show(); - return; + return true; } - performMainStartupAction(); + return false; } void MultiMC::setupWizardFinished(int status) diff --git a/application/MultiMC.h b/application/MultiMC.h index 98a6d780..d8062bb5 100644 --- a/application/MultiMC.h +++ b/application/MultiMC.h @@ -186,6 +186,7 @@ private: void initMCEdit(); void initAnalytics(); void shutdownAnalytics(); + bool createSetupWizard(); void performMainStartupAction(); // sets the fatal error message and m_status to Failed. diff --git a/application/setupwizard/AnalyticsWizardPage.cpp b/application/setupwizard/AnalyticsWizardPage.cpp index ee834db9..f32bfcf6 100644 --- a/application/setupwizard/AnalyticsWizardPage.cpp +++ b/application/setupwizard/AnalyticsWizardPage.cpp @@ -41,25 +41,6 @@ bool AnalyticsWizardPage::validatePage() return true; } -bool AnalyticsWizardPage::isRequired() -{ - if(BuildConfig.ANALYTICS_ID.isEmpty()) - { - return false; - } - auto settings = MMC->settings(); - auto analytics = MMC->analytics(); - if (!settings->get("Analytics").toBool()) - { - return false; - } - if (settings->get("AnalyticsSeen").toInt() < analytics->version()) - { - return true; - } - return false; -} - void AnalyticsWizardPage::retranslate() { setTitle(tr("Analytics")); diff --git a/application/setupwizard/AnalyticsWizardPage.h b/application/setupwizard/AnalyticsWizardPage.h index 88fbed01..03de9cb0 100644 --- a/application/setupwizard/AnalyticsWizardPage.h +++ b/application/setupwizard/AnalyticsWizardPage.h @@ -14,7 +14,6 @@ public: virtual ~AnalyticsWizardPage(); bool validatePage() override; - static bool isRequired(); protected: void retranslate() override; diff --git a/application/setupwizard/JavaWizardPage.cpp b/application/setupwizard/JavaWizardPage.cpp index d0357504..46b6ee3f 100644 --- a/application/setupwizard/JavaWizardPage.cpp +++ b/application/setupwizard/JavaWizardPage.cpp @@ -197,24 +197,6 @@ bool JavaWizardPage::validatePage() return true; } -bool JavaWizardPage::isRequired() -{ - QString currentHostName = QHostInfo::localHostName(); - QString oldHostName = MMC->settings()->get("LastHostname").toString(); - if (currentHostName != oldHostName) - { - MMC->settings()->set("LastHostname", currentHostName); - return true; - } - QString currentJavaPath = MMC->settings()->get("JavaPath").toString(); - QString actualPath = FS::ResolveExecutable(currentJavaPath); - if (actualPath.isNull()) - { - return true; - } - return false; -} - bool JavaWizardPage::wantsRefreshButton() { return true; diff --git a/application/setupwizard/JavaWizardPage.h b/application/setupwizard/JavaWizardPage.h index 7b0d8830..f240217e 100644 --- a/application/setupwizard/JavaWizardPage.h +++ b/application/setupwizard/JavaWizardPage.h @@ -31,7 +31,6 @@ public: void refresh() override; void initializePage() override; bool validatePage() override; - static bool isRequired(); enum class JavaStatus { diff --git a/application/setupwizard/LanguageWizardPage.cpp b/application/setupwizard/LanguageWizardPage.cpp index 0613938d..b884c91a 100644 --- a/application/setupwizard/LanguageWizardPage.cpp +++ b/application/setupwizard/LanguageWizardPage.cpp @@ -47,14 +47,6 @@ bool LanguageWizardPage::validatePage() return true; } -bool LanguageWizardPage::isRequired() -{ - auto settings = MMC->settings(); - if (settings->get("Language").toString().isEmpty()) - return true; - return false; -} - void LanguageWizardPage::retranslate() { setTitle(tr("Language")); diff --git a/application/setupwizard/LanguageWizardPage.h b/application/setupwizard/LanguageWizardPage.h index 9c24b29d..8b55d57f 100644 --- a/application/setupwizard/LanguageWizardPage.h +++ b/application/setupwizard/LanguageWizardPage.h @@ -19,8 +19,6 @@ public: bool validatePage() override; - static bool isRequired(); - protected: void retranslate() override; diff --git a/application/setupwizard/SetupWizard.cpp b/application/setupwizard/SetupWizard.cpp index ef16c2bf..c13f15ee 100644 --- a/application/setupwizard/SetupWizard.cpp +++ b/application/setupwizard/SetupWizard.cpp @@ -11,13 +11,6 @@ #include <QAbstractButton> -enum Page -{ - Language, - Java, - Analytics, -}; - SetupWizard::SetupWizard(QWidget *parent) : QWizard(parent) { setObjectName(QStringLiteral("SetupWizard")); @@ -29,19 +22,6 @@ SetupWizard::SetupWizard(QWidget *parent) : QWizard(parent) retranslate(); connect(this, &QWizard::currentIdChanged, this, &SetupWizard::pageChanged); - - if (LanguageWizardPage::isRequired()) - { - setPage(Page::Language, new LanguageWizardPage(this)); - } - if (JavaWizardPage::isRequired()) - { - setPage(Page::Java, new JavaWizardPage(this)); - } - if(AnalyticsWizardPage::isRequired()) - { - setPage(Page::Analytics, new AnalyticsWizardPage(this)); - } } void SetupWizard::retranslate() @@ -106,15 +86,3 @@ void SetupWizard::changeEvent(QEvent *event) SetupWizard::~SetupWizard() { } - -bool SetupWizard::isRequired() -{ - if (LanguageWizardPage::isRequired()) - return true; - if (JavaWizardPage::isRequired()) - return true; - if (AnalyticsWizardPage::isRequired()) - return true; - return false; -} - diff --git a/application/setupwizard/SetupWizard.h b/application/setupwizard/SetupWizard.h index 51b0f1a3..a336f575 100644 --- a/application/setupwizard/SetupWizard.h +++ b/application/setupwizard/SetupWizard.h @@ -39,9 +39,6 @@ public: /* con/destructors */ private slots: void pageChanged(int id); -public: /* methods */ - static bool isRequired(); - private: /* methods */ void retranslate(); }; |