summaryrefslogtreecommitdiffstats
path: root/application/MultiMC.cpp
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2017-01-21 18:18:53 +0100
committerPetr Mrázek <peterix@gmail.com>2017-01-21 18:27:16 +0100
commit782384f185720699c5105271bfc78275bdc78054 (patch)
treeff34b04d183ffa856bb757b06f82a0a652083aa3 /application/MultiMC.cpp
parentceb5fc6d755cdcb263edc27386db38de9499048f (diff)
downloadMultiMC-782384f185720699c5105271bfc78275bdc78054.tar
MultiMC-782384f185720699c5105271bfc78275bdc78054.tar.gz
MultiMC-782384f185720699c5105271bfc78275bdc78054.tar.lz
MultiMC-782384f185720699c5105271bfc78275bdc78054.tar.xz
MultiMC-782384f185720699c5105271bfc78275bdc78054.zip
GH-1793 rearrange setup wizard logic to only check if they are needed once
Diffstat (limited to 'application/MultiMC.cpp')
-rw-r--r--application/MultiMC.cpp71
1 files changed, 68 insertions, 3 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)