diff options
Diffstat (limited to 'meshmc/launcher/ui/setupwizard')
| -rw-r--r-- | meshmc/launcher/ui/setupwizard/AnalyticsWizardPage.cpp | 88 | ||||
| -rw-r--r-- | meshmc/launcher/ui/setupwizard/AnalyticsWizardPage.h | 46 | ||||
| -rw-r--r-- | meshmc/launcher/ui/setupwizard/BaseWizardPage.h | 50 | ||||
| -rw-r--r-- | meshmc/launcher/ui/setupwizard/JavaWizardPage.cpp | 111 | ||||
| -rw-r--r-- | meshmc/launcher/ui/setupwizard/JavaWizardPage.h | 47 | ||||
| -rw-r--r-- | meshmc/launcher/ui/setupwizard/LanguageWizardPage.cpp | 68 | ||||
| -rw-r--r-- | meshmc/launcher/ui/setupwizard/LanguageWizardPage.h | 47 | ||||
| -rw-r--r-- | meshmc/launcher/ui/setupwizard/SetupWizard.cpp | 105 | ||||
| -rw-r--r-- | meshmc/launcher/ui/setupwizard/SetupWizard.h | 67 |
9 files changed, 629 insertions, 0 deletions
diff --git a/meshmc/launcher/ui/setupwizard/AnalyticsWizardPage.cpp b/meshmc/launcher/ui/setupwizard/AnalyticsWizardPage.cpp new file mode 100644 index 0000000000..0627f9bbc0 --- /dev/null +++ b/meshmc/launcher/ui/setupwizard/AnalyticsWizardPage.cpp @@ -0,0 +1,88 @@ +/* SPDX-FileCopyrightText: 2026 Project Tick + * SPDX-FileContributor: Project Tick + * SPDX-License-Identifier: GPL-3.0-or-later + * + * MeshMC - A Custom Launcher for Minecraft + * Copyright (C) 2026 Project Tick + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + +#include "AnalyticsWizardPage.h" +#include <Application.h> + +#include <QVBoxLayout> +#include <QTextBrowser> +#include <QCheckBox> + +#include <ganalytics.h> +#include <BuildConfig.h> + +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 = APPLICATION->settings(); + auto analytics = APPLICATION->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("<html><body>" + "<p>MeshMC sends anonymous usage statistics on every start of the " + "application. This helps us decide what platforms and issues to " + "focus on.</p>" + "<p>The data is processed by Google Analytics, see their <a " + "href=\"https://support.google.com/analytics/answer/" + "6004245?hl=en\">article on the " + "matter</a>.</p>" + "<p>The following data is collected:</p>" + "<ul><li>A random unique ID of the installation.<br />It is stored " + "in the application settings file.</li>" + "<li>Anonymized (partial) IP address.</li>" + "<li>MeshMC version.</li>" + "<li>Operating system name, version and architecture.</li>" + "<li>CPU architecture (kernel architecture on linux).</li>" + "<li>Size of system memory.</li>" + "<li>Java version, architecture and memory settings.</li></ul>" + "<p>If we change the tracked information, you will see this page " + "again.</p></body></html>")); + checkBox->setText(tr("Enable Analytics")); +} diff --git a/meshmc/launcher/ui/setupwizard/AnalyticsWizardPage.h b/meshmc/launcher/ui/setupwizard/AnalyticsWizardPage.h new file mode 100644 index 0000000000..d304a2e059 --- /dev/null +++ b/meshmc/launcher/ui/setupwizard/AnalyticsWizardPage.h @@ -0,0 +1,46 @@ +/* SPDX-FileCopyrightText: 2026 Project Tick + * SPDX-FileContributor: Project Tick + * SPDX-License-Identifier: GPL-3.0-or-later + * + * MeshMC - A Custom Launcher for Minecraft + * Copyright (C) 2026 Project Tick + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + +#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/meshmc/launcher/ui/setupwizard/BaseWizardPage.h b/meshmc/launcher/ui/setupwizard/BaseWizardPage.h new file mode 100644 index 0000000000..255e4a871d --- /dev/null +++ b/meshmc/launcher/ui/setupwizard/BaseWizardPage.h @@ -0,0 +1,50 @@ +/* SPDX-FileCopyrightText: 2026 Project Tick + * SPDX-FileContributor: Project Tick + * SPDX-License-Identifier: GPL-3.0-or-later + * + * MeshMC - A Custom Launcher for Minecraft + * Copyright (C) 2026 Project Tick + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + +#pragma once + +#include <QWizardPage> +#include <QEvent> + +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/meshmc/launcher/ui/setupwizard/JavaWizardPage.cpp b/meshmc/launcher/ui/setupwizard/JavaWizardPage.cpp new file mode 100644 index 0000000000..5d00ff164b --- /dev/null +++ b/meshmc/launcher/ui/setupwizard/JavaWizardPage.cpp @@ -0,0 +1,111 @@ +/* SPDX-FileCopyrightText: 2026 Project Tick + * SPDX-FileContributor: Project Tick + * SPDX-License-Identifier: GPL-3.0-or-later + * + * MeshMC - A Custom Launcher for Minecraft + * Copyright (C) 2026 Project Tick + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + +#include "JavaWizardPage.h" +#include "Application.h" + +#include <QVBoxLayout> +#include <QGroupBox> +#include <QSpinBox> +#include <QLabel> +#include <QLineEdit> +#include <QPushButton> +#include <QToolButton> +#include <QFileDialog> + +#include <sys.h> + +#include "FileSystem.h" +#include "java/JavaInstall.h" +#include "java/JavaUtils.h" +#include "JavaCommon.h" + +#include "ui/widgets/VersionSelectWidget.h" +#include "ui/dialogs/CustomMessageBox.h" +#include "ui/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 = APPLICATION->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 = APPLICATION->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/meshmc/launcher/ui/setupwizard/JavaWizardPage.h b/meshmc/launcher/ui/setupwizard/JavaWizardPage.h new file mode 100644 index 0000000000..8ffd2e83df --- /dev/null +++ b/meshmc/launcher/ui/setupwizard/JavaWizardPage.h @@ -0,0 +1,47 @@ +/* SPDX-FileCopyrightText: 2026 Project Tick + * SPDX-FileContributor: Project Tick + * SPDX-License-Identifier: GPL-3.0-or-later + * + * MeshMC - A Custom Launcher for Minecraft + * Copyright (C) 2026 Project Tick + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + +#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/meshmc/launcher/ui/setupwizard/LanguageWizardPage.cpp b/meshmc/launcher/ui/setupwizard/LanguageWizardPage.cpp new file mode 100644 index 0000000000..20915c9c3e --- /dev/null +++ b/meshmc/launcher/ui/setupwizard/LanguageWizardPage.cpp @@ -0,0 +1,68 @@ +/* SPDX-FileCopyrightText: 2026 Project Tick + * SPDX-FileContributor: Project Tick + * SPDX-License-Identifier: GPL-3.0-or-later + * + * MeshMC - A Custom Launcher for Minecraft + * Copyright (C) 2026 Project Tick + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + +#include "LanguageWizardPage.h" +#include <Application.h> +#include <translations/TranslationsModel.h> + +#include "ui/widgets/LanguageSelectionWidget.h" +#include <QVBoxLayout> +#include <BuildConfig.h> + +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 = APPLICATION->translations(); + translations->downloadIndex(); +} + +bool LanguageWizardPage::validatePage() +{ + auto settings = APPLICATION->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 %1").arg(BuildConfig.MESHMC_NAME)); + mainWidget->retranslate(); +} diff --git a/meshmc/launcher/ui/setupwizard/LanguageWizardPage.h b/meshmc/launcher/ui/setupwizard/LanguageWizardPage.h new file mode 100644 index 0000000000..bcd68b3e57 --- /dev/null +++ b/meshmc/launcher/ui/setupwizard/LanguageWizardPage.h @@ -0,0 +1,47 @@ +/* SPDX-FileCopyrightText: 2026 Project Tick + * SPDX-FileContributor: Project Tick + * SPDX-License-Identifier: GPL-3.0-or-later + * + * MeshMC - A Custom Launcher for Minecraft + * Copyright (C) 2026 Project Tick + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + +#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/meshmc/launcher/ui/setupwizard/SetupWizard.cpp b/meshmc/launcher/ui/setupwizard/SetupWizard.cpp new file mode 100644 index 0000000000..57642238f2 --- /dev/null +++ b/meshmc/launcher/ui/setupwizard/SetupWizard.cpp @@ -0,0 +1,105 @@ +/* SPDX-FileCopyrightText: 2026 Project Tick + * SPDX-FileContributor: Project Tick + * SPDX-License-Identifier: GPL-3.0-or-later + * + * MeshMC - A Custom Launcher for Minecraft + * Copyright (C) 2026 Project Tick + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + +#include "SetupWizard.h" + +#include "LanguageWizardPage.h" +#include "JavaWizardPage.h" +#include "AnalyticsWizardPage.h" + +#include "translations/TranslationsModel.h" +#include <Application.h> +#include <FileSystem.h> +#include <ganalytics.h> + +#include <QAbstractButton> +#include <BuildConfig.h> + +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("%1 Quick Setup").arg(BuildConfig.MESHMC_NAME)); +} + +BaseWizardPage* SetupWizard::getBasePage(int id) +{ + if (id == -1) + return nullptr; + auto pagePtr = page(id); + if (!pagePtr) + return nullptr; + return dynamic_cast<BaseWizardPage*>(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/meshmc/launcher/ui/setupwizard/SetupWizard.h b/meshmc/launcher/ui/setupwizard/SetupWizard.h new file mode 100644 index 0000000000..871385ca37 --- /dev/null +++ b/meshmc/launcher/ui/setupwizard/SetupWizard.h @@ -0,0 +1,67 @@ +/* SPDX-FileCopyrightText: 2026 Project Tick + * SPDX-FileContributor: Project Tick + * SPDX-License-Identifier: GPL-3.0-or-later + * + * MeshMC - A Custom Launcher for Minecraft + * Copyright (C) 2026 Project Tick + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + * + * This file incorporates work covered by the following copyright and + * permission notice: + * + * 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 <QWizard> + +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(); +}; |
