diff options
| author | Trial97 <alexandru.tripon97@gmail.com> | 2023-08-05 19:09:10 +0300 |
|---|---|---|
| committer | Trial97 <alexandru.tripon97@gmail.com> | 2023-08-05 19:09:10 +0300 |
| commit | b2fdd8359405c93d0d93aa8c68971c986a1f68cb (patch) | |
| tree | 59859119373213ce04b2f5e2d7a95227b57be609 /launcher/ui/pages | |
| parent | 149b6d59cf848a3b3cd50b3aee1c112e9c47e633 (diff) | |
| parent | ae793f6cf11658c9abc5111e82d5ba7b3e6af127 (diff) | |
| download | PrismLauncher-b2fdd8359405c93d0d93aa8c68971c986a1f68cb.tar.gz PrismLauncher-b2fdd8359405c93d0d93aa8c68971c986a1f68cb.tar.bz2 PrismLauncher-b2fdd8359405c93d0d93aa8c68971c986a1f68cb.zip | |
Merge branch 'develop' of https://github.com/PrismLauncher/PrismLauncher into download_threads
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
Diffstat (limited to 'launcher/ui/pages')
88 files changed, 1852 insertions, 2354 deletions
diff --git a/launcher/ui/pages/BasePage.h b/launcher/ui/pages/BasePage.h index dc2bde99..d35206a0 100644 --- a/launcher/ui/pages/BasePage.h +++ b/launcher/ui/pages/BasePage.h @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-3.0-only /* - * PolyMC - Minecraft Launcher + * Prism Launcher - Minecraft Launcher * Copyright (c) 2022 Jamie Mansfield <jmansfield@cadixdev.org> * * This program is free software: you can redistribute it and/or modify diff --git a/launcher/ui/pages/BasePageContainer.h b/launcher/ui/pages/BasePageContainer.h index b41fe12a..b750e827 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* getPage(QString pageId) { return nullptr; }; 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..d4ed9290 100644 --- a/launcher/ui/pages/global/APIPage.h +++ b/launcher/ui/pages/global/APIPage.h @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-3.0-only /* - * PolyMC - Minecraft Launcher + * Prism Launcher - Minecraft Launcher * Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net> * Copyright (c) 2022 Jamie Mansfield <jmansfield@cadixdev.org> * Copyright (c) 2022 Lenny McLennington <lenny@sneed.church> @@ -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/APIPage.ui b |
