diff options
Diffstat (limited to 'launcher/ui/pages/global')
-rw-r--r-- | launcher/ui/pages/global/APIPage.cpp | 45 | ||||
-rw-r--r-- | launcher/ui/pages/global/APIPage.h | 36 | ||||
-rw-r--r-- | launcher/ui/pages/global/AccountListPage.cpp | 94 | ||||
-rw-r--r-- | launcher/ui/pages/global/AccountListPage.h | 44 | ||||
-rw-r--r-- | launcher/ui/pages/global/CustomCommandsPage.cpp | 20 | ||||
-rw-r--r-- | launcher/ui/pages/global/CustomCommandsPage.h | 35 | ||||
-rw-r--r-- | launcher/ui/pages/global/ExternalToolsPage.cpp | 103 | ||||
-rw-r--r-- | launcher/ui/pages/global/ExternalToolsPage.h | 36 | ||||
-rw-r--r-- | launcher/ui/pages/global/JavaPage.cpp | 44 | ||||
-rw-r--r-- | launcher/ui/pages/global/JavaPage.h | 47 | ||||
-rw-r--r-- | launcher/ui/pages/global/LanguagePage.cpp | 11 | ||||
-rw-r--r-- | launcher/ui/pages/global/LanguagePage.h | 37 | ||||
-rw-r--r-- | launcher/ui/pages/global/LauncherPage.cpp | 97 | ||||
-rw-r--r-- | launcher/ui/pages/global/LauncherPage.h | 49 | ||||
-rw-r--r-- | launcher/ui/pages/global/MinecraftPage.cpp | 6 | ||||
-rw-r--r-- | launcher/ui/pages/global/MinecraftPage.h | 44 | ||||
-rw-r--r-- | launcher/ui/pages/global/ProxyPage.cpp | 21 | ||||
-rw-r--r-- | launcher/ui/pages/global/ProxyPage.h | 44 |
18 files changed, 285 insertions, 528 deletions
diff --git a/launcher/ui/pages/global/APIPage.cpp b/launcher/ui/pages/global/APIPage.cpp index 668aa007..82aa76a4 100644 --- a/launcher/ui/pages/global/APIPage.cpp +++ b/launcher/ui/pages/global/APIPage.cpp @@ -39,37 +39,30 @@ #include "APIPage.h" #include "ui_APIPage.h" -#include <QMessageBox> #include <QFileDialog> +#include <QMessageBox> #include <QRegularExpression> #include <QStandardPaths> #include <QTabBar> #include <QValidator> #include <QVariant> -#include "settings/SettingsObject.h" -#include "tools/BaseProfiler.h" #include "Application.h" -#include "net/PasteUpload.h" #include "BuildConfig.h" +#include "net/PasteUpload.h" +#include "settings/SettingsObject.h" +#include "tools/BaseProfiler.h" -APIPage::APIPage(QWidget *parent) : - QWidget(parent), - ui(new Ui::APIPage) +APIPage::APIPage(QWidget* parent) : QWidget(parent), ui(new Ui::APIPage) { // This is here so you can reorder the entries in the combobox without messing stuff up - int comboBoxEntries[] = { - PasteUpload::PasteType::Mclogs, - PasteUpload::PasteType::NullPointer, - PasteUpload::PasteType::PasteGG, - PasteUpload::PasteType::Hastebin - }; + int comboBoxEntries[] = { PasteUpload::PasteType::Mclogs, PasteUpload::PasteType::NullPointer, PasteUpload::PasteType::PasteGG, + PasteUpload::PasteType::Hastebin }; static QRegularExpression validUrlRegExp("https?://.+"); - static QRegularExpression validMSAClientID(QRegularExpression::anchoredPattern( - "[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}")); - static QRegularExpression validFlameKey(QRegularExpression::anchoredPattern( - "\\$2[ayb]\\$.{56}")); + static QRegularExpression validMSAClientID( + QRegularExpression::anchoredPattern("[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}")); + static QRegularExpression validFlameKey(QRegularExpression::anchoredPattern("\\$2[ayb]\\$.{56}")); ui->setupUi(this); @@ -77,7 +70,7 @@ APIPage::APIPage(QWidget *parent) : ui->pasteTypeComboBox->addItem(PasteUpload::PasteTypes.at(pasteType).name, pasteType); } - void (QComboBox::*currentIndexChangedSignal)(int) (&QComboBox::currentIndexChanged); + void (QComboBox::*currentIndexChangedSignal)(int)(&QComboBox::currentIndexChanged); connect(ui->pasteTypeComboBox, currentIndexChangedSignal, this, &APIPage::updateBaseURLPlaceholder); // This function needs to be called even when the ComboBox's index is still in its default state. updateBaseURLPlaceholder(ui->pasteTypeComboBox->currentIndex()); @@ -110,12 +103,9 @@ void APIPage::resetBaseURLNote() void APIPage::updateBaseURLNote(int index) { - if (baseURLPasteType == index) - { + if (baseURLPasteType == index) { ui->baseURLNote->hide(); - } - else if (!ui->baseURLEntry->text().isEmpty()) - { + } else if (!ui->baseURLEntry->text().isEmpty()) { ui->baseURLNote->show(); } } @@ -136,8 +126,7 @@ void APIPage::loadSettings() ui->baseURLEntry->setText(pastebinURL); int pasteTypeIndex = ui->pasteTypeComboBox->findData(pasteType); - if (pasteTypeIndex == -1) - { + if (pasteTypeIndex == -1) { pasteTypeIndex = ui->pasteTypeComboBox->findData(PasteUpload::PasteType::Mclogs); ui->baseURLEntry->clear(); } @@ -167,15 +156,13 @@ void APIPage::applySettings() s->set("MSAClientIDOverride", msaClientID); QUrl metaURL(ui->metaURL->text()); // Add required trailing slash - if (!metaURL.isEmpty() && !metaURL.path().endsWith('/')) - { + if (!metaURL.isEmpty() && !metaURL.path().endsWith('/')) { QString path = metaURL.path(); path.append('/'); metaURL.setPath(path); } // Don't allow HTTP, since meta is basically RCE with all the jar files. - if(!metaURL.isEmpty() && metaURL.scheme() == "http") - { + if (!metaURL.isEmpty() && metaURL.scheme() == "http") { metaURL.setScheme("https"); } diff --git a/launcher/ui/pages/global/APIPage.h b/launcher/ui/pages/global/APIPage.h index 17e62ae7..8d8f0645 100644 --- a/launcher/ui/pages/global/APIPage.h +++ b/launcher/ui/pages/global/APIPage.h @@ -39,41 +39,28 @@ #include <QWidget> -#include "ui/pages/BasePage.h" #include <Application.h> +#include "ui/pages/BasePage.h" namespace Ui { class APIPage; } -class APIPage : public QWidget, public BasePage -{ +class APIPage : public QWidget, public BasePage { Q_OBJECT -public: - explicit APIPage(QWidget *parent = 0); + public: + explicit APIPage(QWidget* parent = 0); ~APIPage(); - QString displayName() const override - { - return tr("APIs"); - } - QIcon icon() const override - { - return APPLICATION->getThemedIcon("worlds"); - } - QString id() const override - { - return "apis"; - } - QString helpPage() const override - { - return "APIs"; - } + QString displayName() const override { return tr("APIs"); } + QIcon icon() const override { return APPLICATION->getThemedIcon("worlds"); } + QString id() const override { return "apis"; } + QString helpPage() const override { return "APIs"; } virtual bool apply() override; void retranslate() override; -private: + private: int baseURLPasteType; void resetBaseURLNote(); void updateBaseURLNote(int index); @@ -81,7 +68,6 @@ private: void loadSettings(); void applySettings(); -private: - Ui::APIPage *ui; + private: + Ui::APIPage* ui; }; - diff --git a/launcher/ui/pages/global/AccountListPage.cpp b/launcher/ui/pages/global/AccountListPage.cpp index fced5ff4..41e78bf4 100644 --- a/launcher/ui/pages/global/AccountListPage.cpp +++ b/launcher/ui/pages/global/AccountListPage.cpp @@ -44,29 +44,27 @@ #include "net/NetJob.h" -#include "ui/dialogs/ProgressDialog.h" -#include "ui/dialogs/OfflineLoginDialog.h" +#include "ui/dialogs/CustomMessageBox.h" #include "ui/dialogs/LoginDialog.h" #include "ui/dialogs/MSALoginDialog.h" -#include "ui/dialogs/CustomMessageBox.h" +#include "ui/dialogs/OfflineLoginDialog.h" +#include "ui/dialogs/ProgressDialog.h" #include "ui/dialogs/SkinUploadDialog.h" -#include "tasks/Task.h" #include "minecraft/auth/AccountTask.h" #include "minecraft/services/SkinDelete.h" +#include "tasks/Task.h" #include "Application.h" #include "BuildConfig.h" -AccountListPage::AccountListPage(QWidget *parent) - : QMainWindow(parent), ui(new Ui::AccountListPage) +AccountListPage::AccountListPage(QWidget* parent) : QMainWindow(parent), ui(new Ui::AccountListPage) { ui->setupUi(this); - ui->listView->setEmptyString(tr( - "Welcome!\n" - "If you're new here, you can click the \"Add\" button to add your Mojang or Minecraft account." - )); + ui->listView->setEmptyString( + tr("Welcome!\n" + "If you're new here, you can click the \"Add\" button to add your Mojang or Minecraft account.")); ui->listView->setEmptyMode(VersionListView::String); ui->listView->setContextMenuPolicy(Qt::CustomContextMenu); @@ -82,11 +80,10 @@ AccountListPage::AccountListPage(QWidget *parent) // Expand the account column - QItemSelectionModel *selectionModel = ui->listView->selectionModel(); + QItemSelectionModel* selectionModel = ui->listView->selectionModel(); - connect(selectionModel, &QItemSelectionModel::selectionChanged, [this](const QItemSelection &sel, const QItemSelection &dsel) { - updateButtonStates(); - }); + connect(selectionModel, &QItemSelectionModel::selectionChanged, + [this](const QItemSelection& sel, const QItemSelection& dsel) { updateButtonStates(); }); connect(ui->listView, &VersionListView::customContextMenuRequested, this, &AccountListPage::ShowContextMenu); connect(m_accounts.get(), &AccountList::listChanged, this, &AccountListPage::listChanged); @@ -121,21 +118,19 @@ void AccountListPage::ShowContextMenu(const QPoint& pos) void AccountListPage::changeEvent(QEvent* event) { - if (event->type() == QEvent::LanguageChange) - { + if (event->type() == QEvent::LanguageChange) { ui->retranslateUi(this); } QMainWindow::changeEvent(event); } -QMenu * AccountListPage::createPopupMenu() +QMenu* AccountListPage::createPopupMenu() { QMenu* filteredMenu = QMainWindow::createPopupMenu(); - filteredMenu->removeAction(ui->toolBar->toggleViewAction() ); + filteredMenu->removeAction(ui->toolBar->toggleViewAction()); return filteredMenu; } - void AccountListPage::listChanged() { updateButtonStates(); @@ -143,13 +138,10 @@ void AccountListPage::listChanged() void AccountListPage::on_actionAddMojang_triggered() { - MinecraftAccountPtr account = LoginDialog::newAccount( - this, - tr("Please enter your Mojang account email and password to add your account.") - ); + MinecraftAccountPtr account = + LoginDialog::newAccount(this, tr("Please enter your Mojang account email and password to add your account.")); - if (account) - { + if (account) { m_accounts->addAccount(account); if (m_accounts->count() == 1) { m_accounts->setDefaultAccount(account); @@ -159,13 +151,10 @@ void AccountListPage::on_actionAddMojang_triggered() void AccountListPage::on_actionAddMicrosoft_triggered() { - MinecraftAccountPtr account = MSALoginDialog::newAccount( - this, - tr("Please enter your Mojang account email and password to add your account.") - ); + MinecraftAccountPtr account = + MSALoginDialog::newAccount(this, tr("Please enter your Mojang account email and password to add your account.")); - if (account) - { + if (account) { m_accounts->addAccount(account); if (m_accounts->count() == 1) { m_accounts->setDefaultAccount(account); @@ -176,25 +165,17 @@ void AccountListPage::on_actionAddMicrosoft_triggered() void AccountListPage::on_actionAddOffline_triggered() { if (!m_accounts->anyAccountIsValid()) { - QMessageBox::warning( - this, - tr("Error"), - tr( - "You must add a Microsoft or Mojang account that owns Minecraft before you can add an offline account." - "<br><br>" - "If you have lost your account you can contact Microsoft for support." - ) - ); + QMessageBox::warning(this, tr("Error"), + tr("You must add a Microsoft or Mojang account that owns Minecraft before you can add an offline account." + "<br><br>" + "If you have lost your account you can contact Microsoft for support.")); return; } - MinecraftAccountPtr account = OfflineLoginDialog::newAccount( - this, - tr("Please enter your desired username to add your offline account.") - ); + MinecraftAccountPtr account = + OfflineLoginDialog::newAccount(this, tr("Please enter your desired username to add your offline account.")); - if (account) - { + if (account) { m_accounts->addAccount(account); if (m_accounts->count() == 1) { m_accounts->setDefaultAccount(account); @@ -205,14 +186,14 @@ void AccountListPage::on_actionAddOffline_triggered() void AccountListPage::on_actionRemove_triggered() { QModelIndexList selection = ui->listView->selectionModel()->selectedIndexes(); - if (selection.size() > 0) - { + if (selection.size() > 0) { QModelIndex selected = selection.first(); m_accounts->removeAccount(selected); } } -void AccountListPage::on_actionRefresh_triggered() { +void AccountListPage::on_actionRefresh_triggered() +{ QModelIndexList selection = ui->listView->selectionModel()->selectedIndexes(); if (selection.size() > 0) { QModelIndex selected = selection.first(); @@ -221,12 +202,10 @@ void AccountListPage::on_actionRefresh_triggered() { } } - void AccountListPage::on_actionSetDefault_triggered() { QModelIndexList selection = ui->listView->selectionModel()->selectedIndexes(); - if (selection.size() > 0) - { + if (selection.size() > 0) { QModelIndex selected = selection.first(); MinecraftAccountPtr account = selected.data(AccountList::PointerRole).value<MinecraftAccountPtr>(); m_accounts->setDefaultAccount(account); @@ -245,8 +224,7 @@ void AccountListPage::updateButtonStates() bool hasSelection = !selection.empty(); bool accountIsReady = false; bool accountIsOnline = false; - if (hasSelection) - { + if (hasSelection) { QModelIndex selected = selection.first(); MinecraftAccountPtr account = selected.data(AccountList::PointerRole).value<MinecraftAccountPtr>(); accountIsReady = !account->isActive(); @@ -258,11 +236,10 @@ void AccountListPage::updateButtonStates() ui->actionDeleteSkin->setEnabled(accountIsReady && accountIsOnline); ui->actionRefresh->setEnabled(accountIsReady && accountIsOnline); - if(m_accounts->defaultAccount().get() == nullptr) { + if (m_accounts->defaultAccount().get() == nullptr) { ui->actionNoDefault->setEnabled(false); ui->actionNoDefault->setChecked(true); - } - else { + } else { ui->actionNoDefault->setEnabled(true); ui->actionNoDefault->setChecked(false); } @@ -271,8 +248,7 @@ void AccountListPage::updateButtonStates() void AccountListPage::on_actionUploadSkin_triggered() { QModelIndexList selection = ui->listView->selectionModel()->selectedIndexes(); - if (selection.size() > 0) - { + if (selection.size() > 0) { QModelIndex selected = selection.first(); MinecraftAccountPtr account = selected.data(AccountList::PointerRole).value<MinecraftAccountPtr>(); SkinUploadDialog dialog(account, this); diff --git a/launcher/ui/pages/global/AccountListPage.h b/launcher/ui/pages/global/AccountListPage.h index 9395e92b..483d7924 100644 --- a/launcher/ui/pages/global/AccountListPage.h +++ b/launcher/ui/pages/global/AccountListPage.h @@ -41,47 +41,35 @@ #include "ui/pages/BasePage.h" -#include "minecraft/auth/AccountList.h" #include "Application.h" +#include "minecraft/auth/AccountList.h" -namespace Ui -{ +namespace Ui { class AccountListPage; } class AuthenticateTask; -class AccountListPage : public QMainWindow, public BasePage -{ +class AccountListPage : public QMainWindow, public BasePage { Q_OBJECT -public: - explicit AccountListPage(QWidget *parent = 0); + public: + explicit AccountListPage(QWidget* parent = 0); ~AccountListPage(); - QString displayName() const override - { - return tr("Accounts"); - } + QString displayName() const override { return tr("Accounts"); } QIcon icon() const override { auto icon = APPLICATION->getThemedIcon("accounts"); - if(icon.isNull()) - { + if (icon.isNull()) { icon = APPLICATION->getThemedIcon("noaccount"); } return icon; } - QString id() const override - { - return "accounts"; - } - QString helpPage() const override - { - return "Getting-Started#adding-an-account"; - } + QString id() const override { return "accounts"; } + QString helpPage() const override { return "Getting-Started#adding-an-account"; } void retranslate() override; -public slots: + public slots: void on_actionAddMojang_triggered(); void on_actionAddMicrosoft_triggered(); void on_actionAddOffline_triggered(); @@ -97,12 +85,12 @@ public slots: //! Updates the states of the dialog's buttons. void updateButtonStates(); -protected slots: - void ShowContextMenu(const QPoint &pos); + protected slots: + void ShowContextMenu(const QPoint& pos); -private: - void changeEvent(QEvent * event) override; - QMenu * createPopupMenu() override; + private: + void changeEvent(QEvent* event) override; + QMenu* createPopupMenu() override; shared_qobject_ptr<AccountList> m_accounts; - Ui::AccountListPage *ui; + Ui::AccountListPage* ui; }; diff --git a/launcher/ui/pages/global/CustomCommandsPage.cpp b/launcher/ui/pages/global/CustomCommandsPage.cpp index df1420ca..fad69050 100644 --- a/launcher/ui/pages/global/CustomCommandsPage.cpp +++ b/launcher/ui/pages/global/CustomCommandsPage.cpp @@ -35,13 +35,12 @@ */ #include "CustomCommandsPage.h" -#include <QVBoxLayout> -#include <QTabWidget> #include <QTabBar> +#include <QTabWidget> +#include <QVBoxLayout> -CustomCommandsPage::CustomCommandsPage(QWidget* parent): QWidget(parent) +CustomCommandsPage::CustomCommandsPage(QWidget* parent) : QWidget(parent) { - auto verticalLayout = new QVBoxLayout(this); verticalLayout->setObjectName(QStringLiteral("verticalLayout")); verticalLayout->setContentsMargins(0, 0, 0, 0); @@ -56,9 +55,7 @@ CustomCommandsPage::CustomCommandsPage(QWidget* parent): QWidget(parent) loadSettings(); } -CustomCommandsPage::~CustomCommandsPage() -{ -} +CustomCommandsPage::~CustomCommandsPage() {} bool CustomCommandsPage::apply() { @@ -77,13 +74,8 @@ void CustomCommandsPage::applySettings() void CustomCommandsPage::loadSettings() { auto s = APPLICATION->settings(); - commands->initialize( - false, - true, - s->get("PreLaunchCommand").toString(), - s->get("WrapperCommand").toString(), - s->get("PostExitCommand").toString() - ); + commands->initialize(false, true, s->get("PreLaunchCommand").toString(), s->get("WrapperCommand").toString(), + s->get("PostExitCommand").toString()); } void CustomCommandsPage::retranslate() diff --git a/launcher/ui/pages/global/CustomCommandsPage.h b/launcher/ui/pages/global/CustomCommandsPage.h index 865503ff..c69b02e5 100644 --- a/launcher/ui/pages/global/CustomCommandsPage.h +++ b/launcher/ui/pages/global/CustomCommandsPage.h @@ -35,42 +35,29 @@ #pragma once -#include <memory> #include <QDialog> +#include <memory> -#include "ui/pages/BasePage.h" #include <Application.h> +#include "ui/pages/BasePage.h" #include "ui/widgets/CustomCommands.h" -class CustomCommandsPage : public QWidget, public BasePage -{ +class CustomCommandsPage : public QWidget, public BasePage { Q_OBJECT -public: - explicit CustomCommandsPage(QWidget *parent = 0); + public: + explicit CustomCommandsPage(QWidget* parent = 0); ~CustomCommandsPage(); - QString displayName() const override - { - return tr("Custom Commands"); - } - QIcon icon() const override - { - return APPLICATION->getThemedIcon("custom-commands"); - } - QString id() const override - { - return "custom-commands"; - } - QString helpPage() const override - { - return "Custom-commands"; - } + QString displayName() const override { return tr("Custom Commands"); } + QIcon icon() const override { return APPLICATION->getThemedIcon("custom-commands"); } + QString id() const override { return "custom-commands"; } + QString helpPage() const override { return "Custom-commands"; } bool apply() override; void retranslate() override; -private: + private: void applySettings(); void loadSettings(); - CustomCommands * commands; + CustomCommands* commands; }; diff --git a/launcher/ui/pages/global/ExternalToolsPage.cpp b/launcher/ui/pages/global/ExternalToolsPage.cpp index 5ba0ebc2..abe157f0 100644 --- a/launcher/ui/pages/global/ExternalToolsPage.cpp +++ b/launcher/ui/pages/global/ExternalToolsPage.cpp @@ -36,20 +36,18 @@ #include "ExternalToolsPage.h" #include "ui_ExternalToolsPage.h" -#include <QMessageBox> #include <QFileDialog> +#include <QMessageBox> #include <QStandardPaths> #include <QTabBar> -#include "settings/SettingsObject.h" -#include "tools/BaseProfiler.h" #include <FileSystem.h> -#include "Application.h" #include <tools/MCEditTool.h> +#include "Application.h" +#include "settings/SettingsObject.h" +#include "tools/BaseProfiler.h" -ExternalToolsPage::ExternalToolsPage(QWidget *parent) : - QWidget(parent), - ui(new Ui::ExternalToolsPage) +ExternalToolsPage::ExternalToolsPage(QWidget* parent) : QWidget(parent), ui(new Ui::ExternalToolsPage) { ui->setupUi(this); ui->tabWidget->tabBar()->hide(); @@ -87,12 +85,9 @@ void ExternalToolsPage::applySettings() // Editors QString jsonEditor = ui->jsonEditorTextBox->text(); - if (!jsonEditor.isEmpty() && - (!QFileInfo(jsonEditor).exists() || !QFileInfo(jsonEditor).isExecutable())) - { + if (!jsonEditor.isEmpty() && (!QFileInfo(jsonEditor).exists() || !QFileInfo(jsonEditor).isExecutable())) { QString found = QStandardPaths::findExecutable(jsonEditor); - if (!found.isEmpty()) - { + if (!found.isEmpty()) { jsonEditor = found; } } @@ -103,21 +98,16 @@ void ExternalToolsPage::on_jprofilerPathBtn_clicked() { QString raw_dir = ui->jprofilerPathEdit->text(); QString error; - do - { + do { raw_dir = QFileDialog::getExistingDirectory(this, tr("JProfiler Folder"), raw_dir); - if (raw_dir.isEmpty()) - { + if (raw_dir.isEmpty()) { break; } QString cooked_dir = FS::NormalizePath(raw_dir); - if (!APPLICATION->profilers()["jprofiler"]->check(cooked_dir, &error)) - { + if (!APPLICATION->profilers()["jprofiler"]->check(cooked_dir, &error)) { QMessageBox::critical(this, tr("Error"), tr("Error while checking JProfiler install:\n%1").arg(error)); continue; - } - else - { + } else { ui->jprofilerPathEdit->setText(cooked_dir); break; } @@ -126,12 +116,9 @@ void ExternalToolsPage::on_jprofilerPathBtn_clicked() void ExternalToolsPage::on_jprofilerCheckBtn_clicked() { QString error; - if (!APPLICATION->profilers()["jprofiler"]->check(ui->jprofilerPathEdit->text(), &error)) - { + if (!APPLICATION->profilers()["jprofiler"]->check(ui->jprofilerPathEdit->text(), &error)) { QMessageBox::critical(this, tr("Error"), tr("Error while checking JProfiler install:\n%1").arg(error)); - } - else - { + } else { QMessageBox::information(this, tr("OK"), tr("JProfiler setup seems to be OK")); } } @@ -140,21 +127,16 @@ void ExternalToolsPage::on_jvisualvmPathBtn_clicked() { QString raw_dir = ui->jvisualvmPathEdit->text(); QString error; - do - { + do { raw_dir = QFileDialog::getOpenFileName(this, tr("JVisualVM Executable"), raw_dir); - if (raw_dir.isEmpty()) - { + if (raw_dir.isEmpty()) { break; } QString cooked_dir = FS::NormalizePath(raw_dir); - if (!APPLICATION->profilers()["jvisualvm"]->check(cooked_dir, &error)) - { + if (!APPLICATION->profilers()["jvisualvm"]->check(cooked_dir, &error)) { QMessageBox::critical(this, tr("Error"), tr("Error while checking JVisualVM install:\n%1").arg(error)); continue; - } - else - { + } else { ui->jvisualvmPathEdit->setText(cooked_dir); break; } @@ -163,12 +145,9 @@ void ExternalToolsPage::on_jvisualvmPathBtn_clicked() void ExternalToolsPage::on_jvisualvmCheckBtn_clicked() { QString error; - if (!APPLICATION->profilers()["jvisualvm"]->check(ui->jvisualvmPathEdit->text(), &error)) - { + if (!APPLICATION->profilers()["jvisualvm"]->check(ui->jvisualvmPathEdit->text(), &error)) { QMessageBox::critical(this, tr("Error"), tr("Error while checking JVisualVM install:\n%1").arg(error)); - } - else - { + } else { QMessageBox::information(this, tr("OK"), tr("JVisualVM setup seems to be OK")); } } @@ -177,25 +156,20 @@ void ExternalToolsPage::on_mceditPathBtn_clicked() { QString raw_dir = ui->mceditPathEdit->text(); QString error; - do - { + do { #ifdef Q_OS_OSX raw_dir = QFileDialog::getOpenFileName(this, tr("MCEdit Application"), raw_dir); #else raw_dir = QFileDialog::getExistingDirectory(this, tr("MCEdit Folder"), raw_dir); #endif - if (raw_dir.isEmpty()) - { + if (raw_dir.isEmpty()) { break; } QString cooked_dir = FS::NormalizePath(raw_dir); - if (!APPLICATION->mcedit()->check(cooked_dir, error)) - { + if (!APPLICATION->mcedit()->check(cooked_dir, error)) { QMessageBox::critical(this, tr("Error"), tr("Error while checking MCEdit install:\n%1").arg(error)); continue; - } - else - { + } else { ui->mceditPathEdit->setText(cooked_dir); break; } @@ -204,43 +178,34 @@ void ExternalToolsPage::on_mceditPathBtn_clicked() void ExternalToolsPage::on_mceditCheckBtn_clicked() { QString error; - if (!APPLICATION->mcedit()->check(ui->mceditPathEdit->text(), error)) - { + if (!APPLICATION->mcedit()->check(ui->mceditPathEdit->text(), error)) { QMessageBox::critical(this, tr("Error"), tr("Error while checking MCEdit install:\n%1").arg(error)); - } - else - { + } else { QMessageBox::information(this, tr("OK"), tr("MCEdit setup seems to be OK")); } } void ExternalToolsPage::on_jsonEditorBrowseBtn_clicked() { - QString raw_file = QFileDialog::getOpenFileName( - this, tr("JSON Editor"), - ui->jsonEditorTextBox->text().isEmpty() + QString raw_file = QFileDialog::getOpenFileName(this, tr("JSON Editor"), + ui->jsonEditorTextBox->text().isEmpty() #if defined(Q_OS_LINUX) - ? QString("/usr/bin") + ? QString("/usr/bin") #else - ? QStandardPaths::standardLocations(QStandardPaths::ApplicationsLocation).first() + ? QStandardPaths::standardLocations(QStandardPaths::ApplicationsLocation).first() #endif - : ui->jsonEditorTextBox->text()); + : ui->jsonEditorTextBox->text()); - if (raw_file.isEmpty()) - { + if (raw_file.isEmpty()) { return; } QString cooked_file = FS::NormalizePath(raw_file); // it has to exist and be an executable - if (QFileInfo(cooked_file).exists() && QFileInfo(cooked_file).isExecutable()) - { + if (QFileInfo(cooked_file).exists() && QFileInfo(cooked_file).isExecutable()) { ui->jsonEditorTextBox->setText(cooked_file); - } - else - { - QMessageBox::warning(this, tr("Invalid"), - tr("The file chosen does not seem to be an executable")); + } else { + QMessageBox::warning(this, tr("Invalid"), tr("The file chosen does not seem to be an executable")); } } diff --git a/launcher/ui/pages/global/ExternalToolsPage.h b/launcher/ui/pages/global/ExternalToolsPage.h index 8bd38a19..0b38b80f 100644 --- a/launcher/ui/pages/global/ExternalToolsPage.h +++ b/launcher/ui/pages/global/ExternalToolsPage.h @@ -37,54 +37,42 @@ #include <QWidget> -#include "ui/pages/BasePage.h" #include <Application.h> +#include "ui/pages/BasePage.h" namespace Ui { class ExternalToolsPage; } -class ExternalToolsPage : public QWidget, public BasePage -{ +class ExternalToolsPage : public QWidget, public BasePage { Q_OBJECT -public: - explicit ExternalToolsPage(QWidget *parent = 0); + public: + explicit ExternalToolsPage(QWidget* parent = 0); ~ExternalToolsPage(); - QString displayName() const override - { - return tr("External Tools"); - } + QString displayName() const override { return tr("External Tools"); } QIcon icon() const override { auto icon = APPLICATION->getThemedIcon("externaltools"); - if(icon.isNull()) - { + if (icon.isNull()) { icon = APPLICATION->getThemedIcon("loadermods"); } return icon; } - QString id() const override - { - return "external-tools"; - } - QString helpPage() const override - { - return "Tools"; - } + QString id() const override { return "external-tools"; } + QString helpPage() const override { return "Tools"; } virtual bool apply() override; void retranslate() override; -private: + private: void loadSettings(); void applySettings(); -private: - Ui::ExternalToolsPage *ui; + private: + Ui::ExternalToolsPage* ui; -private -slots: + private slots: void on_jprofilerPathBtn_clicked(); void on_jprofilerCheckBtn_clicked(); void on_jvisualvmPathBtn_clicked(); diff --git a/launcher/ui/pages/global/JavaPage.cpp b/launcher/ui/pages/global/JavaPage.cpp index 81dd4cc1..77563840 100644 --- a/launcher/ui/pages/global/JavaPage.cpp +++ b/launcher/ui/pages/global/JavaPage.cpp @@ -38,22 +38,22 @@ #include "JavaCommon.h" #include "ui_JavaPage.h" +#include <QDir> #include <QFileDialog> #include <QMessageBox> -#include <QDir> #include <QTabBar> #include "ui/dialogs/VersionSelectDialog.h" -#include "java/JavaUtils.h" #include "java/JavaInstallList.h" +#include "java/JavaUtils.h" -#include "settings/SettingsObject.h" #include <FileSystem.h> -#include "Application.h" #include <sys.h> +#include "Application.h" +#include "settings/SettingsObject.h" -JavaPage::JavaPage(QWidget *parent) : QWidget(parent), ui(new Ui::JavaPage) +JavaPage::JavaPage(QWidget* parent) : QWidget(parent), ui(new Ui::JavaPage) { ui->setupUi(this); ui->tabWidget->tabBar()->hide(); @@ -80,13 +80,10 @@ void JavaPage::applySettings() // Memory int min = ui->minMemSpinBox->value(); int max = ui->maxMemSpinBox->value(); - if(min < max) - { + if (min < max) { s->set("MinMemAlloc", min); s->set("MaxMemAlloc", max); - } - else - { + } else { s->set("MinMemAlloc", max); s->set("MaxMemAlloc", min); } @@ -105,13 +102,10 @@ void JavaPage::loadSettings() // Memory int min = s->get("MinMemAlloc").toInt(); int max = s->get("MaxMemAlloc").toInt(); - if(min < max) - { + if (min < max) { ui->minMemSpinBox->setValue(min); ui->maxMemSpinBox->setValue(max); - } - else - { + } else { ui->minMemSpinBox->setValue(max); ui->maxMemSpinBox->setValue(min); } @@ -137,8 +131,7 @@ void JavaPage::on_javaDetectBtn_clicked() vselect.setResizeOn(2); vselect.exec(); - if (vselect.result() == QDialog::Accepted && vselect.selectedVersion()) - { + if (vselect.result() == QDialog::Accepted && vselect.selectedVersion()) { java = std::dynamic_pointer_cast<JavaInstall>(vselect.selectedVersion()); ui->javaPathTextBox->setText(java->path); } @@ -149,15 +142,14 @@ void JavaPage::on_javaBrowseBtn_clicked() QString raw_path = QFileDialog::getOpenFileName(this, tr("Find Java executable")); // do not allow current dir - it's dirty. Do not allow dirs that don't exist - if(raw_path.isEmpty()) - { + if (raw_path.isEmpty()) { return; } QString cooked_path = FS::NormalizePath(raw_path); - QFileInfo javaInfo(cooked_path);; - if(!javaInfo.exists() || !javaInfo.isExecutable()) - { + QFileInfo javaInfo(cooked_path); + ; + if (!javaInfo.exists() || !javaInfo.isExecutable()) { return; } ui->javaPathTextBox->setText(cooked_path); @@ -165,13 +157,11 @@ void JavaPage::on_javaBrowseBtn_clicked() void JavaPage::on_javaTestBtn_clicked() { - if(checker) - { + if (checker) { return; } - checker.reset(new JavaCommon::TestCheck( - this, ui->javaPathTextBox->text(), ui->jvmArgsTextBox->toPlainText().replace("\n", " "), - ui->minMemSpinBox->value(), ui->maxMemSpinBox->value(), ui->permGenSpinBox->value())); + checker.reset(new JavaCommon::TestCheck(this, ui->javaPathTextBox->text(), ui->jvmArgsTextBox->toPlainText().replace("\n", " "), + ui->minMemSpinBox->value(), ui->maxMemSpinBox->value(), ui->permGenSpinBox->value())); connect(checker.get(), SIGNAL(finished()), SLOT(checkerFinished())); checker->run(); } diff --git a/launcher/ui/pages/global/JavaPage.h b/launcher/ui/pages/global/JavaPage.h index 2ef6d749..64f2a296 100644 --- a/launcher/ui/pages/global/JavaPage.h +++ b/launcher/ui/pages/global/JavaPage.h @@ -35,62 +35,47 @@ #pragma once -#include <memory> -#include <QDialog> -#include "ui/pages/BasePage.h" -#include "JavaCommon.h" #include <Application.h> #include <QObjectPtr.h> +#include <QDialog> +#include <memory> +#include "JavaCommon.h" +#include "ui/pages/BasePage.h" class SettingsObject; -namespace Ui -{ +namespace Ui { class JavaPage; } -class JavaPage : public QWidget, public BasePage -{ +class JavaPage : public QWidget, public BasePage { Q_OBJECT -public: - explicit JavaPage(QWidget *parent = 0); + public: + explicit JavaPage(QWidget* parent = 0); ~JavaPage(); - QString displayName() const override - { - return tr("Java"); - } - QIcon icon() const override - { - return APPLICATION->getThemedIcon("java"); - } - QString id() const override - { - return "java-settings"; - } - QString helpPage() const override - { - return "Java-settings"; - } + QString displayName() const override { return tr("Java"); } + QIcon icon() const override { return APPLICATION->getThemedIcon("java"); } + QString id() const override { return "java-settings"; } + QString helpPage() const override { return "Java-settings"; } bool apply() override; void retranslate() override; void updateThresholds(); -private: + private: void applySettings(); void loadSettings(); -private -slots: + private slots: void on_javaDetectBtn_clicked(); void on_javaTestBtn_clicked(); void on_javaBrowseBtn_clicked(); void on_maxMemSpinBox_valueChanged(int i); void checkerFinished(); -private: - Ui::JavaPage *ui; + private: + Ui::JavaPage* ui; unique_qobject_ptr<JavaCommon::TestCheck> checker; }; diff --git a/launcher/ui/pages/global/LanguagePage.cpp b/launcher/ui/pages/global/LanguagePage.cpp index fcd174bd..27af91d8 100644 --- a/launcher/ui/pages/global/LanguagePage.cpp +++ b/launcher/ui/pages/global/LanguagePage.cpp @@ -36,23 +36,20 @@ #include "LanguagePage.h" -#include "ui/widgets/LanguageSelectionWidget.h" #include <QVBoxLayout> +#include "ui/widgets/LanguageSelectionWidget.h" -LanguagePage::LanguagePage(QWidget* parent) : - QWidget(parent) +LanguagePage::LanguagePage(QWidget* parent) : QWidget(parent) { setObjectName(QStringLiteral("languagePage")); auto layout = new QVBoxLayout(this); mainWidget = new LanguageSelectionWidget(this); - layout->setContentsMargins(0,0,0,0); + layout->setContentsMargins(0, 0, 0, 0); layout->addWidget(mainWidget); retranslate(); } -LanguagePage::~LanguagePage() -{ -} +LanguagePage::~LanguagePage() {} bool LanguagePage::apply() { diff --git a/launcher/ui/pages/global/LanguagePage.h b/launcher/ui/pages/global/LanguagePage.h index 2fd4ab0d..ea358851 100644 --- a/launcher/ui/pages/global/LanguagePage.h +++ b/launcher/ui/pages/global/LanguagePage.h @@ -36,45 +36,32 @@ #pragma once -#include <memory> -#include "ui/pages/BasePage.h" #include <Application.h> #include <QWidget> +#include <memory> +#include "ui/pages/BasePage.h" class LanguageSelectionWidget; -class LanguagePage : public QWidget, public BasePage -{ +class LanguagePage : public QWidget, public BasePage { Q_OBJECT -public: - explicit LanguagePage(QWidget *parent = 0); + public: + explicit LanguagePage(QWidget* parent = 0); virtual ~LanguagePage(); - QString displayName() const override - { - return tr("Language"); - } - QIcon icon() const override - { - return APPLICATION->getThemedIcon("language"); - } - QString id() const override - { - return "language-settings"; - } - QString helpPage() const override - { - return "Language-settings"; - } + QString displayName() const override { return tr("Language"); } + QIcon icon() const override { return APPLICATION->getThemedIcon("language"); } + QString id() const override { return "language-settings"; } + QString helpPage() const override { return "Language-settings"; } bool apply() override; void retranslate() override; -private: + private: void applySettings(); void loadSettings(); -private: - LanguageSelectionWidget *mainWidget; + private: + LanguageSelectionWidget* mainWidget; }; diff --git a/launcher/ui/pages/global/LauncherPage.cpp b/launcher/ui/pages/global/LauncherPage.cpp index 2080b56f..7f22fdb5 100644 --- a/launcher/ui/pages/global/LauncherPage.cpp +++ b/launcher/ui/pages/global/LauncherPage.cpp @@ -38,17 +38,17 @@ #include "LauncherPage.h" #include "ui_LauncherPage.h" +#include <QDir> #include <QFileDialog> +#include <QMenuBar> #include <QMessageBox> -#include <QDir> #include <QTextCharFormat> -#include <QMenuBar> -#include "settings/SettingsObject.h" #include <FileSystem.h> #include "Application.h" #include "BuildConfig.h" #include "DesktopServices.h" +#include "settings/SettingsObject.h" #include "ui/themes/ITheme.h" #include "updater/ExternalUpdater.h" @@ -56,15 +56,14 @@ #include <QProcess> // FIXME: possibly move elsewhere -enum InstSortMode -{ +enum InstSortMode { // Sort alphabetically by name. Sort_Name, // Sort by which instance was launched most recently. Sort_LastLaunch }; -LauncherPage::LauncherPage(QWidget *parent) : QWidget(parent), ui(new Ui::LauncherPage) +LauncherPage::LauncherPage(QWidget* parent) : QWidget(parent), ui(new Ui::LauncherPage) { ui->setupUi(this); auto origForeground = ui->fontPreview->palette().color(ui->fontPreview->foregroundRole()); @@ -104,46 +103,39 @@ void LauncherPage::on_instDirBrowseBtn_clicked() QString raw_dir = QFileDialog::getExistingDirectory(this, tr("Instance Folder"), ui->instDirTextBox->text()); // do not allow current dir - it's dirty. Do not allow dirs that don't exist - if (!raw_dir.isEmpty() && QDir(raw_dir).exists()) - { + if (!raw_dir.isEmpty() && QDir(raw_dir).exists()) { QString cooked_dir = FS::NormalizePath(raw_dir); - if (FS::checkProblemticPathJava(QDir(cooked_dir))) - { + if (FS::checkProblemticPathJava(QDir(cooked_dir))) { QMessageBox warning; - warning.setText(tr("You're trying to specify an instance folder which\'s path " - "contains at least one \'!\'. " - "Java is known to cause problems if that is the case, your " - "instances (probably) won't start!")); + warning.setText( + tr("You're trying to specify an instance folder which\'s path " + "contains at least one \'!\'. " + "Java is known to cause problems if that is the case, your " + "instances (probably) won't start!")); warning.setInformativeText( tr("Do you really want to use this path? " "Selecting \"No\" will close this and not alter your instance path.")); warning.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel); int result = warning.exec(); - if (result == QMessageBox::Ok) - { + if (result == QMessageBox::Ok) { ui->instDirTextBox->setText(cooked_dir); } - } - else if(DesktopServices::isFlatpak() && raw_dir.startsWith("/run/user")) - { + } else if (DesktopServices::isFlatpak() && raw_dir.startsWith("/run/user")) { QMessageBox warning; warning.setText(tr("You're trying to specify an instance folder " - "which was granted temporarily via Flatpak.\n" - "This is known to cause problems. " - "After a restart the launcher might break, " - "because it will no longer have access to that directory.\n\n" - "Granting %1 access to it via Flatseal is recommended.").arg(BuildConfig.LAUNCHER_DISPLAYNAME)); - warning.setInformativeText( - tr("Do you want to proceed anyway?")); + "which was granted temporarily via Flatpak.\n" + "This is known to cause problems. " + "After a restart the launcher might break, " + "because it will no longer have access to that directory.\n\n" + "Granting %1 access to it via Flatseal is recommended.") + .arg(BuildConfig.LAUNCHER_DISPLAYNAME)); + warning.setInformativeText(tr("Do you want to proceed anyway?")); warning.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel); int result = warning.exec(); - if (result == QMessageBox::Ok) - { + if (result == QMessageBox::Ok) { ui->instDirTextBox->setText(cooked_dir); } - } - else - { + } else { ui->instDirTextBox->setText(cooked_dir); } } @@ -154,8 +146,7 @@ void LauncherPage::on_iconsDirBrowseBtn_clicked() QString raw_dir = QFileDialog::getExistingDirectory(this, tr("Icons Folder"), ui->iconsDirTextBox->text()); // do not allow current dir - it's dirty. Do not allow dirs that don't exist - if (!raw_dir.isEmpty() && QDir(raw_dir).exists()) - { + if (!raw_dir.isEmpty() && QDir(raw_dir).exists()) { QString cooked_dir = FS::NormalizePath(raw_dir); ui->iconsDirTextBox->setText(cooked_dir); } @@ -166,8 +157,7 @@ void LauncherPage::on_modsDirBrowseBtn_clicked() QString raw_dir = QFileDialog::getExistingDirectory(this, tr("Mods Folder"), ui->modsDirTextBox->text()); // do not allow current dir - it's dirty. Do not allow dirs that don't exist - if (!raw_dir.isEmpty() && QDir(raw_dir).exists()) - { + if (!raw_dir.isEmpty() && QDir(raw_dir).exists()) { QString cooked_dir = FS::NormalizePath(raw_dir); ui->modsDirTextBox->setText(cooked_dir); } @@ -177,8 +167,7 @@ void LauncherPage::on_downloadsDirBrowseBtn_clicked() { QString raw_dir = QFileDialog::getExistingDirectory(this, tr("Downloads Folder"), ui->downloadsDirTextBox->text()); - if (!raw_dir.isEmpty() && QDir(raw_dir).exists()) - { + if (!raw_dir.isEmpty() && QDir(raw_dir).exists()) { QString cooked_dir = FS::NormalizePath(raw_dir); ui->downloadsDirTextBox->setText(cooked_dir); } @@ -194,8 +183,7 @@ void LauncherPage::applySettings() auto s = APPLICATION->settings(); // Updates - if (APPLICATION->updater()) - { + if (APPLICATION->updater()) { APPLICATION->updater()->setAutomaticallyChecksForUpdates(ui->autoUpdateCheckBox->isChecked()); } @@ -220,15 +208,14 @@ void LauncherPage::applySettings() s->set("DownloadsDirWatchRecursive", ui->downloadsDirWatchRecursiveCheckBox->isChecked()); auto sortMode = (InstSortMode)ui->sortingModeGroup->checkedId(); - switch (sortMode) - { - case Sort_LastLaunch: - s->set("InstSortMode", "LastLaunch"); - break; - case Sort_Name: - default: - s->set("InstSortMode", "Name"); - break; + switch (sortMode) { + case Sort_LastLaunch: + s->set("InstSortMode", "LastLaunch"); + break; + case Sort_Name: + default: + s->set("InstSortMode", "Name"); + break; } // Mods @@ -238,12 +225,10 @@ void LauncherPage::loadSettings() { auto s = APPLICATION->settings(); // Updates - if (APPLICATION->updater()) - { + if (APPLICATION->updater()) { ui->autoUpdateCheckBox->setChecked(APPLICATION->updater()->getAutomaticallyChecksForUpdates()); } - // Toolbar/menu bar settings (not applicable if native menu bar is present) ui->toolsBox->setEnabled(!QMenuBar().isNativeMenuBar()); #ifdef Q_OS_MACOS @@ -261,8 +246,7 @@ void LauncherPage::loadSettings() bool conversionOk = true; int fontSize = APPLICATION->settings()->get("ConsoleFontSize").toInt(&conversionOk); - if(!conversionOk) - { + if (!conversionOk) { fontSize = 11; } ui->fontSizeBox->setValue(fontSize); @@ -279,12 +263,9 @@ void LauncherPage::loadSettings() QString sortMode = s->get("InstSortMode").toString(); - if (sortMode == "LastLaunch") - { + if (sortMode == "LastLaunch") { ui->sortLastLaunchedBtn->setChecked(true); - } - else - { + } else { ui->sortByNameBtn->setChecked(true); } diff --git a/launcher/ui/pages/global/LauncherPage.h b/launcher/ui/pages/global/LauncherPage.h index e06d9897..238e31bb 100644 --- a/launcher/ui/pages/global/LauncherPage.h +++ b/launcher/ui/pages/global/LauncherPage.h @@ -35,56 +35,41 @@ #pragma once -#include <memory> #include <QDialog> +#include <memory> -#include "java/JavaChecker.h" -#include "ui/pages/BasePage.h" #include <Application.h> -#include "ui/ColorCache.h" #include <translations/TranslationsModel.h> +#include "java/JavaChecker.h" +#include "ui/ColorCache.h" +#include "ui/pages/BasePage.h" class QTextCharFormat; class SettingsObject; -namespace Ui -{ +namespace Ui { class LauncherPage; } -class LauncherPage : public QWidget, public BasePage -{ +class LauncherPage : public QWidget, public BasePage { Q_OBJECT -public: - explicit LauncherPage(QWidget *parent = 0); + public: + explicit LauncherPage(QWidget* parent = 0); ~LauncherPage(); - QString displayName() const override - { - return tr("Launcher"); - } - QIcon icon() const override - { - return APPLICATION->getThemedIcon("launcher"); - } - QString id() const override - { - return "launcher-settings"; - } - QString helpPage() const override - { - return "Launcher-settings"; - } + QString displayName() const override { return tr("Launcher"); } + QIcon icon() const override { return APPLICATION->getThemedIcon("launcher"); } + QString id() const override { return "launcher-settings"; } + QString helpPage() const override { return "Launcher-settings"; } bool apply() override; void retranslate() override; -private: + private: void applySettings(); void loadSettings(); -private -slots: + private slots: void on_instDirBrowseBtn_clicked(); void on_modsDirBrowseBtn_clicked(); void on_iconsDirBrowseBtn_clicked(); @@ -96,8 +81,8 @@ slots: */ void refreshFontPreview(); -private: - Ui::LauncherPage *ui; + private: + Ui::LauncherPage* ui; /*! * Stores the currently selected update channel. @@ -105,7 +90,7 @@ private: QString m_currentUpdateChannel; // default format for the font preview... - QTextCharFormat *defaultFormat; + QTextCharFormat* defaultFormat; std::unique_ptr<LogColorCache> m_colors; diff --git a/launcher/ui/pages/global/MinecraftPage.cpp b/launcher/ui/pages/global/MinecraftPage.cpp index 95482356..55ad12ac 100644 --- a/launcher/ui/pages/global/MinecraftPage.cpp +++ b/launcher/ui/pages/global/MinecraftPage.cpp @@ -37,14 +37,14 @@ #include "MinecraftPage.h" #include "ui_MinecraftPage.h" -#include <QMessageBox> #include <QDir> +#include <QMessageBox> #include <QTabBar> -#include "settings/SettingsObject.h" #include "Application.h" +#include "settings/SettingsObject.h" -MinecraftPage::MinecraftPage(QWidget *parent) : QWidget(parent), ui(new Ui::MinecraftPage) +MinecraftPage::MinecraftPage(QWidget* parent) : QWidget(parent), ui(new Ui::MinecraftPage) { ui->setupUi(this); loadSettings(); diff --git a/launcher/ui/pages/global/MinecraftPage.h b/launcher/ui/pages/global/MinecraftPage.h index cf5f95eb..a9e2e802 100644 --- a/launcher/ui/pages/global/MinecraftPage.h +++ b/launcher/ui/pages/global/MinecraftPage.h @@ -35,57 +35,41 @@ #pragma once -#include <memory> #include <QDialog> +#include <memory> +#include <Application.h> #include "java/JavaChecker.h" #include "ui/pages/BasePage.h" -#include <Application.h> class SettingsObject; -namespace Ui -{ +namespace Ui { class MinecraftPage; } -class MinecraftPage : public QWidget, public BasePage -{ +class MinecraftPage : public QWidget, public BasePage { Q_OBJECT -public: - explicit MinecraftPage(QWidget *parent = 0); + public: + explicit MinecraftPage(QWidget* parent = 0); ~MinecraftPage(); - QString displayName() const override - { - return tr("Minecraft"); - } - QIcon icon() const override - { - return APPLICATION->getThemedIcon("minecraft"); - } - QString id() const override - { - return "minecraft-settings"; - } - QString helpPage() const override - { - return "Minecraft-settings"; - } + QString displayName() const override { return tr("Minecraft"); } + QIcon icon() const override { return APPLICATION->getThemedIcon("minecraft"); } + QString id() const override { return "minecraft-settings"; } + QString helpPage() const override { return "Minecraft-settings"; } bool apply() override; void retranslate() override; -private: + private: void updateCheckboxStuff(); void applySettings(); void loadSettings(); -private -slots: + private slots: void on_maximizedCheckBox_clicked(bool checked); -private: - Ui::MinecraftPage *ui; - + private: + Ui::MinecraftPage* ui; }; diff --git a/launcher/ui/pages/global/ProxyPage.cpp b/launcher/ui/pages/global/ProxyPage.cpp index ffff8456..931adac5 100644 --- a/launcher/ui/pages/global/ProxyPage.cpp +++ b/launcher/ui/pages/global/ProxyPage.cpp @@ -40,18 +40,17 @@ #include <QButtonGroup> #include <QTabBar> -#include "settings/SettingsObject.h" #include "Application.h" +#include "settings/SettingsObject.h" -ProxyPage::ProxyPage(QWidget *parent) : QWidget(parent), ui(new Ui::ProxyPage) +ProxyPage::ProxyPage(QWidget* parent) : QWidget(parent), ui(new Ui::ProxyPage) { ui->setupUi(this); ui->tabWidget->tabBar()->hide(); loadSettings(); updateCheckboxStuff(); - connect(ui->proxyGroup, QOverload<QAbstractButton *>::of(&QButtonGroup::buttonClicked), - this, &ProxyPage::proxyGroupChanged); + connect(ui->proxyGroup, QOverload<QAbstractButton*>::of(&QButtonGroup::buttonClicked), this, &ProxyPage::proxyGroupChanged); } ProxyPage::~ProxyPage() @@ -67,13 +66,12 @@ bool ProxyPage::apply() void ProxyPage::updateCheckboxStuff() { - bool enableEditing = ui->proxyHTTPBtn->isChecked() - || ui->proxySOCKS5Btn->isChecked(); + bool enableEditing = ui->proxyHTTPBtn->isChecked() || ui->proxySOCKS5Btn->isChecked(); ui->proxyAddrBox->setEnabled(enableEditing); ui->proxyAuthBox->setEnabled(enableEditing); } -void ProxyPage::proxyGroupChanged(QAbstractButton *button) +void ProxyPage::proxyGroupChanged(QAbstractButton* button) { updateCheckboxStuff(); } @@ -99,13 +97,8 @@ void ProxyPage::applySettings() s->set("ProxyUser", ui->proxyUserEdit->text()); s->set("ProxyPass", ui->proxyPassEdit->text()); - APPLICATION->updateProxySettings( - proxyType, - ui->proxyAddrEdit->text(), - ui->proxyPortEdit->value(), - ui->proxyUserEdit->text(), - ui->proxyPassEdit->text() - ); + APPLICATION->updateProxySettings(proxyType, ui->proxyAddrEdit->text(), ui->proxyPortEdit->value(), ui->proxyUserEdit->text(), + ui->proxyPassEdit->text()); } void ProxyPage::loadSettings() { diff --git a/launcher/ui/pages/global/ProxyPage.h b/launcher/ui/pages/global/ProxyPage.h index 279a9029..092a11d2 100644 --- a/launcher/ui/pages/global/ProxyPage.h +++ b/launcher/ui/pages/global/ProxyPage.h @@ -36,53 +36,39 @@ #pragma once -#include <memory> #include <QAbstractButton> #include <QDialog> +#include <memory> -#include "ui/pages/BasePage.h" #include <Application.h> +#include "ui/pages/BasePage.h" -namespace Ui -{ +namespace Ui { class ProxyPage; } -class ProxyPage : public QWidget, public BasePage -{ +class ProxyPage : public QWidget, public BasePage { Q_OBJECT -public: - explicit ProxyPage(QWidget *parent = 0); + public: + explicit ProxyPage(QWidget* parent = 0); ~ProxyPage(); - QString displayName() const override - { - return tr("Proxy"); - } - QIcon icon() const override - { - return APPLICATION->getThemedIcon("proxy"); - } - QString id() const override - { - return "proxy-settings"; - } - QString helpPage() const override - { - return "Proxy-settings"; - } + QString displayName() const override { return tr("Proxy"); } + QIcon icon() const override { return APPLICATION->getThemedIcon("proxy"); } + QString id() const override { return "proxy-settings"; } + QString helpPage() const override { return "Proxy-settings"; } bool apply() override; void retranslate() override; -private slots: - void proxyGroupChanged(QAbstractButton *button); + private slots: + void proxyGroupChanged(QAbstractButton* button); -private: + private: void updateCheckboxStuff(); void applySettings(); void loadSettings(); -private: - Ui::ProxyPage *ui; + private: + Ui::ProxyPage* ui; }; |