From 20b9f2b42a3b58b6081af271774fbcc34025dccb Mon Sep 17 00:00:00 2001 From: Petr Mrázek Date: Sun, 25 Jul 2021 19:11:59 +0200 Subject: NOISSUE Flatten gui and logic libraries into MultiMC --- application/setupwizard/AnalyticsWizardPage.cpp | 63 ---------------- application/setupwizard/AnalyticsWizardPage.h | 25 ------- application/setupwizard/BaseWizardPage.h | 33 --------- application/setupwizard/JavaWizardPage.cpp | 96 ------------------------- application/setupwizard/JavaWizardPage.h | 29 -------- application/setupwizard/LanguageWizardPage.cpp | 48 ------------- application/setupwizard/LanguageWizardPage.h | 26 ------- application/setupwizard/SetupWizard.cpp | 88 ----------------------- application/setupwizard/SetupWizard.h | 45 ------------ 9 files changed, 453 deletions(-) delete mode 100644 application/setupwizard/AnalyticsWizardPage.cpp delete mode 100644 application/setupwizard/AnalyticsWizardPage.h delete mode 100644 application/setupwizard/BaseWizardPage.h delete mode 100644 application/setupwizard/JavaWizardPage.cpp delete mode 100644 application/setupwizard/JavaWizardPage.h delete mode 100644 application/setupwizard/LanguageWizardPage.cpp delete mode 100644 application/setupwizard/LanguageWizardPage.h delete mode 100644 application/setupwizard/SetupWizard.cpp delete mode 100644 application/setupwizard/SetupWizard.h (limited to 'application/setupwizard') diff --git a/application/setupwizard/AnalyticsWizardPage.cpp b/application/setupwizard/AnalyticsWizardPage.cpp deleted file mode 100644 index 4fb0bcca..00000000 --- a/application/setupwizard/AnalyticsWizardPage.cpp +++ /dev/null @@ -1,63 +0,0 @@ -#include "AnalyticsWizardPage.h" -#include - -#include -#include -#include - -#include -#include - -AnalyticsWizardPage::AnalyticsWizardPage(QWidget *parent) - : BaseWizardPage(parent) -{ - setObjectName(QStringLiteral("analyticsPage")); - verticalLayout_3 = new QVBoxLayout(this); - verticalLayout_3->setObjectName(QStringLiteral("verticalLayout_3")); - textBrowser = new QTextBrowser(this); - textBrowser->setObjectName(QStringLiteral("textBrowser")); - textBrowser->setAcceptRichText(false); - textBrowser->setOpenExternalLinks(true); - verticalLayout_3->addWidget(textBrowser); - - checkBox = new QCheckBox(this); - checkBox->setObjectName(QStringLiteral("checkBox")); - checkBox->setChecked(true); - verticalLayout_3->addWidget(checkBox); - retranslate(); -} - -AnalyticsWizardPage::~AnalyticsWizardPage() -{ -} - -bool AnalyticsWizardPage::validatePage() -{ - auto settings = MMC->settings(); - auto analytics = MMC->analytics(); - auto status = checkBox->isChecked(); - settings->set("AnalyticsSeen", analytics->version()); - settings->set("Analytics", status); - return true; -} - -void AnalyticsWizardPage::retranslate() -{ - setTitle(tr("Analytics")); - setSubTitle(tr("We track some anonymous statistics about users.")); - textBrowser->setHtml(tr( - "" - "

MultiMC sends anonymous usage statistics on every start of the application. This helps us decide what platforms and issues to focus on.

" - "

The data is processed by Google Analytics, see their article on the " - "matter.

" - "

The following data is collected:

" - "
  • A random unique ID of the MultiMC installation.
    It is stored in the application settings (multimc.cfg).
  • " - "
  • Anonymized (partial) IP address.
  • " - "
  • MultiMC version.
  • " - "
  • Operating system name, version and architecture.
  • " - "
  • CPU architecture (kernel architecture on linux).
  • " - "
  • Size of system memory.
  • " - "
  • Java version, architecture and memory settings.
" - "

If we change the tracked information, you will see this page again.

")); - checkBox->setText(tr("Enable Analytics")); -} diff --git a/application/setupwizard/AnalyticsWizardPage.h b/application/setupwizard/AnalyticsWizardPage.h deleted file mode 100644 index c451db2c..00000000 --- a/application/setupwizard/AnalyticsWizardPage.h +++ /dev/null @@ -1,25 +0,0 @@ -#pragma once - -#include "BaseWizardPage.h" - -class QVBoxLayout; -class QTextBrowser; -class QCheckBox; - -class AnalyticsWizardPage : public BaseWizardPage -{ - Q_OBJECT -public: - explicit AnalyticsWizardPage(QWidget *parent = Q_NULLPTR); - virtual ~AnalyticsWizardPage(); - - bool validatePage() override; - -protected: - void retranslate() override; - -private: - QVBoxLayout *verticalLayout_3 = nullptr; - QTextBrowser *textBrowser = nullptr; - QCheckBox *checkBox = nullptr; -}; \ No newline at end of file diff --git a/application/setupwizard/BaseWizardPage.h b/application/setupwizard/BaseWizardPage.h deleted file mode 100644 index 72dbecfd..00000000 --- a/application/setupwizard/BaseWizardPage.h +++ /dev/null @@ -1,33 +0,0 @@ -#pragma once - -#include -#include - -class BaseWizardPage : public QWizardPage -{ -public: - explicit BaseWizardPage(QWidget *parent = Q_NULLPTR) - : QWizardPage(parent) - { - } - virtual ~BaseWizardPage() {}; - - virtual bool wantsRefreshButton() - { - return false; - } - virtual void refresh() - { - } - -protected: - virtual void retranslate() = 0; - void changeEvent(QEvent * event) override - { - if (event->type() == QEvent::LanguageChange) - { - retranslate(); - } - QWizardPage::changeEvent(event); - } -}; diff --git a/application/setupwizard/JavaWizardPage.cpp b/application/setupwizard/JavaWizardPage.cpp deleted file mode 100644 index ad571c09..00000000 --- a/application/setupwizard/JavaWizardPage.cpp +++ /dev/null @@ -1,96 +0,0 @@ -#include "JavaWizardPage.h" -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include "widgets/JavaSettingsWidget.h" - - -JavaWizardPage::JavaWizardPage(QWidget *parent) - :BaseWizardPage(parent) -{ - setupUi(); -} - -void JavaWizardPage::setupUi() -{ - setObjectName(QStringLiteral("javaPage")); - QVBoxLayout * layout = new QVBoxLayout(this); - - m_java_widget = new JavaSettingsWidget(this); - layout->addWidget(m_java_widget); - setLayout(layout); - - retranslate(); -} - -void JavaWizardPage::refresh() -{ - m_java_widget->refresh(); -} - -void JavaWizardPage::initializePage() -{ - m_java_widget->initialize(); -} - -bool JavaWizardPage::wantsRefreshButton() -{ - return true; -} - -bool JavaWizardPage::validatePage() -{ - auto settings = MMC->settings(); - auto result = m_java_widget->validate(); - switch(result) - { - default: - case JavaSettingsWidget::ValidationStatus::Bad: - { - return false; - } - case JavaSettingsWidget::ValidationStatus::AllOK: - { - settings->set("JavaPath", m_java_widget->javaPath()); - } - case JavaSettingsWidget::ValidationStatus::JavaBad: - { - // Memory - auto s = MMC->settings(); - s->set("MinMemAlloc", m_java_widget->minHeapSize()); - s->set("MaxMemAlloc", m_java_widget->maxHeapSize()); - if (m_java_widget->permGenEnabled()) - { - s->set("PermGen", m_java_widget->permGenSize()); - } - else - { - s->reset("PermGen"); - } - return true; - } - } -} - -void JavaWizardPage::retranslate() -{ - setTitle(tr("Java")); - setSubTitle(tr("You do not have a working Java set up yet or it went missing.\n" - "Please select one of the following or browse for a java executable.")); - m_java_widget->retranslate(); -} diff --git a/application/setupwizard/JavaWizardPage.h b/application/setupwizard/JavaWizardPage.h deleted file mode 100644 index 0d749039..00000000 --- a/application/setupwizard/JavaWizardPage.h +++ /dev/null @@ -1,29 +0,0 @@ -#pragma once - -#include "BaseWizardPage.h" - -class JavaSettingsWidget; - -class JavaWizardPage : public BaseWizardPage -{ - Q_OBJECT -public: - explicit JavaWizardPage(QWidget *parent = Q_NULLPTR); - - virtual ~JavaWizardPage() - { - }; - - bool wantsRefreshButton() override; - void refresh() override; - void initializePage() override; - bool validatePage() override; - -protected: /* methods */ - void setupUi(); - void retranslate() override; - -private: /* data */ - JavaSettingsWidget *m_java_widget = nullptr; -}; - diff --git a/application/setupwizard/LanguageWizardPage.cpp b/application/setupwizard/LanguageWizardPage.cpp deleted file mode 100644 index ca93c6f5..00000000 --- a/application/setupwizard/LanguageWizardPage.cpp +++ /dev/null @@ -1,48 +0,0 @@ -#include "LanguageWizardPage.h" -#include -#include - -#include "widgets/LanguageSelectionWidget.h" -#include - -LanguageWizardPage::LanguageWizardPage(QWidget *parent) - : BaseWizardPage(parent) -{ - setObjectName(QStringLiteral("languagePage")); - auto layout = new QVBoxLayout(this); - mainWidget = new LanguageSelectionWidget(this); - layout->setContentsMargins(0,0,0,0); - layout->addWidget(mainWidget); - - retranslate(); -} - -LanguageWizardPage::~LanguageWizardPage() -{ -} - -bool LanguageWizardPage::wantsRefreshButton() -{ - return true; -} - -void LanguageWizardPage::refresh() -{ - auto translations = MMC->translations(); - translations->downloadIndex(); -} - -bool LanguageWizardPage::validatePage() -{ - auto settings = MMC->settings(); - QString key = mainWidget->getSelectedLanguageKey(); - settings->set("Language", key); - return true; -} - -void LanguageWizardPage::retranslate() -{ - setTitle(tr("Language")); - setSubTitle(tr("Select the language to use in MultiMC")); - mainWidget->retranslate(); -} diff --git a/application/setupwizard/LanguageWizardPage.h b/application/setupwizard/LanguageWizardPage.h deleted file mode 100644 index 45a0e5c0..00000000 --- a/application/setupwizard/LanguageWizardPage.h +++ /dev/null @@ -1,26 +0,0 @@ -#pragma once - -#include "BaseWizardPage.h" - -class LanguageSelectionWidget; - -class LanguageWizardPage : public BaseWizardPage -{ - Q_OBJECT -public: - explicit LanguageWizardPage(QWidget *parent = Q_NULLPTR); - - virtual ~LanguageWizardPage(); - - bool wantsRefreshButton() override; - - void refresh() override; - - bool validatePage() override; - -protected: - void retranslate() override; - -private: - LanguageSelectionWidget *mainWidget = nullptr; -}; diff --git a/application/setupwizard/SetupWizard.cpp b/application/setupwizard/SetupWizard.cpp deleted file mode 100644 index 60a78b8d..00000000 --- a/application/setupwizard/SetupWizard.cpp +++ /dev/null @@ -1,88 +0,0 @@ -#include "SetupWizard.h" - -#include "LanguageWizardPage.h" -#include "JavaWizardPage.h" -#include "AnalyticsWizardPage.h" - -#include "translations/TranslationsModel.h" -#include -#include -#include - -#include - -SetupWizard::SetupWizard(QWidget *parent) : QWizard(parent) -{ - setObjectName(QStringLiteral("SetupWizard")); - resize(615, 659); - // make it ugly everywhere to avoid variability in theming - setWizardStyle(QWizard::ClassicStyle); - setOptions(QWizard::NoCancelButton | QWizard::IndependentPages | QWizard::HaveCustomButton1); - - retranslate(); - - connect(this, &QWizard::currentIdChanged, this, &SetupWizard::pageChanged); -} - -void SetupWizard::retranslate() -{ - setButtonText(QWizard::NextButton, tr("&Next >")); - setButtonText(QWizard::BackButton, tr("< &Back")); - setButtonText(QWizard::FinishButton, tr("&Finish")); - setButtonText(QWizard::CustomButton1, tr("&Refresh")); - setWindowTitle(tr("MultiMC Quick Setup")); -} - -BaseWizardPage * SetupWizard::getBasePage(int id) -{ - if(id == -1) - return nullptr; - auto pagePtr = page(id); - if(!pagePtr) - return nullptr; - return dynamic_cast(pagePtr); -} - -BaseWizardPage * SetupWizard::getCurrentBasePage() -{ - return getBasePage(currentId()); -} - -void SetupWizard::pageChanged(int id) -{ - auto basePagePtr = getBasePage(id); - if(!basePagePtr) - { - return; - } - if(basePagePtr->wantsRefreshButton()) - { - setButtonLayout({QWizard::CustomButton1, QWizard::Stretch, QWizard::BackButton, QWizard::NextButton, QWizard::FinishButton}); - auto customButton = button(QWizard::CustomButton1); - connect(customButton, &QAbstractButton::pressed, [&](){ - auto basePagePtr = getCurrentBasePage(); - if(basePagePtr) - { - basePagePtr->refresh(); - } - }); - } - else - { - setButtonLayout({QWizard::Stretch, QWizard::BackButton, QWizard::NextButton, QWizard::FinishButton}); - } -} - - -void SetupWizard::changeEvent(QEvent *event) -{ - if (event->type() == QEvent::LanguageChange) - { - retranslate(); - } - QWizard::changeEvent(event); -} - -SetupWizard::~SetupWizard() -{ -} diff --git a/application/setupwizard/SetupWizard.h b/application/setupwizard/SetupWizard.h deleted file mode 100644 index 9b8adb4d..00000000 --- a/application/setupwizard/SetupWizard.h +++ /dev/null @@ -1,45 +0,0 @@ -/* Copyright 2017-2021 MultiMC Contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -#include - -namespace Ui -{ -class SetupWizard; -} - -class BaseWizardPage; - -class SetupWizard : public QWizard -{ - Q_OBJECT - -public: /* con/destructors */ - explicit SetupWizard(QWidget *parent = 0); - virtual ~SetupWizard(); - - void changeEvent(QEvent * event) override; - BaseWizardPage *getBasePage(int id); - BaseWizardPage *getCurrentBasePage(); - -private slots: - void pageChanged(int id); - -private: /* methods */ - void retranslate(); -}; - -- cgit