diff options
Diffstat (limited to 'launcher/ui/pages')
71 files changed, 1385 insertions, 2265 deletions
diff --git a/launcher/ui/pages/BasePageContainer.h b/launcher/ui/pages/BasePageContainer.h index eb3c9427..a497ef7b 100644 --- a/launcher/ui/pages/BasePageContainer.h +++ b/launcher/ui/pages/BasePageContainer.h @@ -2,9 +2,8 @@ class BasePage; -class BasePageContainer -{ -public: +class BasePageContainer { + public: virtual ~BasePageContainer(){}; virtual bool selectPage(QString pageId) = 0; virtual BasePage* selectedPage() const = 0; diff --git a/launcher/ui/pages/BasePageProvider.h b/launcher/ui/pages/BasePageProvider.h index 873e8dce..4c3ecd6c 100644 --- a/launcher/ui/pages/BasePageProvider.h +++ b/launcher/ui/pages/BasePageProvider.h @@ -15,54 +15,43 @@ #pragma once -#include "ui/pages/BasePage.h" -#include <memory> #include <functional> +#include <memory> +#include "ui/pages/BasePage.h" -class BasePageProvider -{ -public: - virtual QList<BasePage *> getPages() = 0; +class BasePageProvider { + public: + virtual QList<BasePage*> getPages() = 0; virtual QString dialogTitle() = 0; }; -class GenericPageProvider : public BasePageProvider -{ - typedef std::function<BasePage *()> PageCreator; -public: - explicit GenericPageProvider(const QString &dialogTitle) - : m_dialogTitle(dialogTitle) - { - } +class GenericPageProvider : public BasePageProvider { + typedef std::function<BasePage*()> PageCreator; + + public: + explicit GenericPageProvider(const QString& dialogTitle) : m_dialogTitle(dialogTitle) {} virtual ~GenericPageProvider() {} - QList<BasePage *> getPages() override + QList<BasePage*> getPages() override { - QList<BasePage *> pages; - for (PageCreator creator : m_creators) - { + QList<BasePage*> pages; + for (PageCreator creator : m_creators) { pages.append(creator()); } return pages; } QString dialogTitle() override { return m_dialogTitle; } - void setDialogTitle(const QString &title) - { - m_dialogTitle = title; - } - void addPageCreator(PageCreator page) - { - m_creators.append(page); - } + void setDialogTitle(const QString& title) { m_dialogTitle = title; } + void addPageCreator(PageCreator page) { m_creators.append(page); } - template<typename PageClass> + template <typename PageClass> void addPage() { - addPageCreator([](){return new PageClass();}); + addPageCreator([]() { return new PageClass(); }); } -private: + private: QList<PageCreator> m_creators; QString m_dialogTitle; }; 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 37df1a31..caaa4b06 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,7 +80,7 @@ AccountListPage::AccountListPage(QWidget *parent) // Expand the account column - QItemSelectionModel *selectionModel = ui->listView->selectionModel(); + QItemSelectionModel* selectionModel = ui->listView->selectionModel(); connect(selectionModel, &QItemSelectionModel::selectionChanged, [this]([[maybe_unused]] const QItemSelection& sel, [[maybe_unused]] const QItemSelection& dsel) { updateButtonStates(); }); @@ -120,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(); @@ -142,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); @@ -158,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); @@ -175,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); @@ -204,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(); @@ -220,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); @@ -244,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(); @@ -257,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 |
