aboutsummaryrefslogtreecommitdiff
path: root/launcher/ui/pages
diff options
context:
space:
mode:
Diffstat (limited to 'launcher/ui/pages')
-rw-r--r--launcher/ui/pages/BasePage.h2
-rw-r--r--launcher/ui/pages/BasePageContainer.h5
-rw-r--r--launcher/ui/pages/BasePageProvider.h47
-rw-r--r--launcher/ui/pages/global/APIPage.cpp49
-rw-r--r--launcher/ui/pages/global/APIPage.h38
-rw-r--r--launcher/ui/pages/global/APIPage.ui2
-rw-r--r--launcher/ui/pages/global/AccountListPage.cpp109
-rw-r--r--launcher/ui/pages/global/AccountListPage.h46
-rw-r--r--launcher/ui/pages/global/CustomCommandsPage.cpp22
-rw-r--r--launcher/ui/pages/global/CustomCommandsPage.h37
-rw-r--r--launcher/ui/pages/global/ExternalToolsPage.cpp105
-rw-r--r--launcher/ui/pages/global/ExternalToolsPage.h38
-rw-r--r--launcher/ui/pages/global/JavaPage.cpp46
-rw-r--r--launcher/ui/pages/global/JavaPage.h49
-rw-r--r--launcher/ui/pages/global/JavaPage.ui2
-rw-r--r--launcher/ui/pages/global/LanguagePage.cpp13
-rw-r--r--launcher/ui/pages/global/LanguagePage.h39
-rw-r--r--launcher/ui/pages/global/LauncherPage.cpp99
-rw-r--r--launcher/ui/pages/global/LauncherPage.h51
-rw-r--r--launcher/ui/pages/global/LauncherPage.ui2
-rw-r--r--launcher/ui/pages/global/MinecraftPage.cpp14
-rw-r--r--launcher/ui/pages/global/MinecraftPage.h46
-rw-r--r--launcher/ui/pages/global/MinecraftPage.ui21
-rw-r--r--launcher/ui/pages/global/ProxyPage.cpp23
-rw-r--r--launcher/ui/pages/global/ProxyPage.h46
-rw-r--r--launcher/ui/pages/instance/ExternalResourcesPage.cpp33
-rw-r--r--launcher/ui/pages/instance/ExternalResourcesPage.h6
-rw-r--r--launcher/ui/pages/instance/ExternalResourcesPage.ui11
-rw-r--r--launcher/ui/pages/instance/GameOptionsPage.cpp13
-rw-r--r--launcher/ui/pages/instance/GameOptionsPage.h40
-rw-r--r--launcher/ui/pages/instance/InstanceSettingsPage.cpp157
-rw-r--r--launcher/ui/pages/instance/InstanceSettingsPage.h41
-rw-r--r--launcher/ui/pages/instance/InstanceSettingsPage.ui27
-rw-r--r--launcher/ui/pages/instance/LogPage.cpp146
-rw-r--r--launcher/ui/pages/instance/LogPage.h46
-rw-r--r--launcher/ui/pages/instance/ManagedPackPage.cpp41
-rw-r--r--launcher/ui/pages/instance/ManagedPackPage.ui12
-rw-r--r--launcher/ui/pages/instance/ModFolderPage.cpp68
-rw-r--r--launcher/ui/pages/instance/ModFolderPage.h5
-rw-r--r--launcher/ui/pages/instance/NotesPage.cpp7
-rw-r--r--launcher/ui/pages/instance/NotesPage.h37
-rw-r--r--launcher/ui/pages/instance/OtherLogsPage.cpp140
-rw-r--r--launcher/ui/pages/instance/OtherLogsPage.h44
-rw-r--r--launcher/ui/pages/instance/ResourcePackPage.cpp2
-rw-r--r--launcher/ui/pages/instance/ResourcePackPage.h11
-rw-r--r--launcher/ui/pages/instance/ScreenshotsPage.cpp306
-rw-r--r--launcher/ui/pages/instance/ScreenshotsPage.h60
-rw-r--r--launcher/ui/pages/instance/ServersPage.cpp382
-rw-r--r--launcher/ui/pages/instance/ServersPage.h61
-rw-r--r--launcher/ui/pages/instance/ShaderPackPage.cpp3
-rw-r--r--launcher/ui/pages/instance/ShaderPackPage.h7
-rw-r--r--launcher/ui/pages/instance/TexturePackPage.cpp2
-rw-r--r--launcher/ui/pages/instance/TexturePackPage.h12
-rw-r--r--launcher/ui/pages/instance/VersionPage.cpp306
-rw-r--r--launcher/ui/pages/instance/VersionPage.h55
-rw-r--r--launcher/ui/pages/instance/WorldListPage.cpp178
-rw-r--r--launcher/ui/pages/instance/WorldListPage.h66
-rw-r--r--launcher/ui/pages/modplatform/CustomPage.cpp85
-rw-r--r--launcher/ui/pages/modplatform/CustomPage.h46
-rw-r--r--launcher/ui/pages/modplatform/ImportPage.cpp68
-rw-r--r--launcher/ui/pages/modplatform/ImportPage.h45
-rw-r--r--launcher/ui/pages/modplatform/ResourcePackPage.cpp6
-rw-r--r--launcher/ui/pages/modplatform/ResourcePackPage.h2
-rw-r--r--launcher/ui/pages/modplatform/ResourcePage.cpp1
-rw-r--r--launcher/ui/pages/modplatform/TexturePackPage.h5
-rw-r--r--launcher/ui/pages/modplatform/atlauncher/AtlFilterModel.cpp16
-rw-r--r--launcher/ui/pages/modplatform/atlauncher/AtlFilterModel.h16
-rw-r--r--launcher/ui/pages/modplatform/atlauncher/AtlOptionalModDialog.cpp134
-rw-r--r--launcher/ui/pages/modplatform/atlauncher/AtlOptionalModDialog.h39
-rw-r--r--launcher/ui/pages/modplatform/atlauncher/AtlPage.cpp36
-rw-r--r--launcher/ui/pages/modplatform/atlauncher/AtlPage.h48
-rw-r--r--launcher/ui/pages/modplatform/atlauncher/AtlUserInteractionSupportImpl.cpp18
-rw-r--r--launcher/ui/pages/modplatform/atlauncher/AtlUserInteractionSupportImpl.h2
-rw-r--r--launcher/ui/pages/modplatform/flame/FlameModel.cpp8
-rw-r--r--launcher/ui/pages/modplatform/flame/FlamePage.cpp2
-rw-r--r--launcher/ui/pages/modplatform/flame/FlamePage.h48
-rw-r--r--launcher/ui/pages/modplatform/flame/FlameResourcePages.cpp28
-rw-r--r--launcher/ui/pages/modplatform/flame/FlameResourcePages.h29
-rw-r--r--launcher/ui/pages/modplatform/import_ftb/ImportFTBPage.cpp104
-rw-r--r--launcher/ui/pages/modplatform/import_ftb/ImportFTBPage.h67
-rw-r--r--launcher/ui/pages/modplatform/import_ftb/ImportFTBPage.ui28
-rw-r--r--launcher/ui/pages/modplatform/import_ftb/ListModel.cpp88
-rw-r--r--launcher/ui/pages/modplatform/import_ftb/ListModel.h46
-rw-r--r--launcher/ui/pages/modplatform/legacy_ftb/ListModel.cpp2
-rw-r--r--launcher/ui/pages/modplatform/legacy_ftb/ListModel.h49
-rw-r--r--launcher/ui/pages/modplatform/legacy_ftb/Page.cpp149
-rw-r--r--launcher/ui/pages/modplatform/legacy_ftb/Page.h64
-rw-r--r--launcher/ui/pages/modplatform/modrinth/ModrinthModel.cpp30
-rw-r--r--launcher/ui/pages/modplatform/modrinth/ModrinthModel.h11
-rw-r--r--launcher/ui/pages/modplatform/modrinth/ModrinthPage.cpp2
-rw-r--r--launcher/ui/pages/modplatform/modrinth/ModrinthPage.h2
-rw-r--r--launcher/ui/pages/modplatform/modrinth/ModrinthResourceModels.cpp2
-rw-r--r--launcher/ui/pages/modplatform/modrinth/ModrinthResourceModels.h2
-rw-r--r--launcher/ui/pages/modplatform/modrinth/ModrinthResourcePages.cpp32
-rw-r--r--launcher/ui/pages/modplatform/modrinth/ModrinthResourcePages.h32
-rw-r--r--launcher/ui/pages/modplatform/technic/TechnicData.h4
-rw-r--r--launcher/ui/pages/modplatform/technic/TechnicModel.cpp2
-rw-r--r--launcher/ui/pages/modplatform/technic/TechnicModel.h2
-rw-r--r--launcher/ui/pages/modplatform/technic/TechnicPage.cpp100
-rw-r--r--launcher/ui/pages/modplatform/technic/TechnicPage.h46
100 files changed, 2142 insertions, 2680 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 dca1b3a6..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,10 +70,12 @@ 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());
+ // NOTE: this allows http://, but we replace that with https later anyway
+ ui->metaURL->setValidator(new QRegularExpressionValidator(validUrlRegExp, ui->metaURL));
ui->baseURLEntry->setValidator(new QRegularExpressionValidator(validUrlRegExp, ui->baseURLEntry));
ui->msaClientID->setValidator(new QRegularExpressionValidator(validMSAClientID, ui->msaClientID));
ui->flameKey->setValidator(new QRegularExpressionValidator(validFlameKey, ui->flameKey));
@@ -108,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();
}
}
@@ -134,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();
}
@@ -163,17 +154,15 @@ void APIPage::applySettings()
QString msaClientID = ui->msaClientID->text();
s->set("MSAClientIDOverride", msaClientID);
- QUrl metaURL = ui->metaURL->text();
+ 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/launcher/ui/pages/global/APIPage.ui
index 40b89d91..492741ba 100644
--- a/launcher/ui/pages/global/APIPage.ui
+++ b/launcher/ui/pages/global/APIPage.ui
@@ -30,7 +30,7 @@
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
- <string notr="true">Services</string>
+ <string>Services</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
diff --git a/launcher/ui/pages/global/AccountListPage.cpp b/launcher/ui/pages/global/AccountListPage.cpp
index 278f45c4..1d5ecb8d 100644
--- a/launcher/ui/pages/global/AccountListPage.cpp
+++ b/launcher/ui/pages/global/AccountListPage.cpp
@@ -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>
*
@@ -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,26 +151,10 @@ void AccountListPage::on_actionAddMojang_triggered()
void AccountListPage::on_actionAddMicrosoft_triggered()
{
- if(BuildConfig.BUILD_PLATFORM == "osx64") {
- CustomMessageBox::selectable(
- this,
- tr("Microsoft Accounts not available"),
- //: %1 refers to the launcher itself
- tr(
- "Microsoft accounts are only usable on macOS 10.13 or newer, with fully updated %1.\n\n"
- "Please update both your operating system and %1."
- ).arg(BuildConfig.LAUNCHER_DISPLAYNAME),
- QMessageBox::Warning
- )->exec();
- return;
- }
- 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);
@@ -189,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);
@@ -218,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();
@@ -234,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);
@@ -258,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();
@@ -271,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);
}
@@ -284,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..add0f4aa 100644
--- a/launcher/ui/pages/global/AccountListPage.h
+++ b/launcher/ui/pages/global/AccountListPage.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>
*
@@ -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..cc8518c2 100644
--- a/launcher/ui/pages/global/CustomCommandsPage.cpp
+++ b/launcher/ui/pages/global/CustomCommandsPage.cpp
@@ -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>
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
*
@@ -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..ec1204ff 100644
--- a/launcher/ui/pages/global/CustomCommandsPage.h
+++ b/launcher/ui/pages/global/CustomCommandsPage.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
@@ -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..33e9c538 100644
--- a/launcher/ui/pages/global/ExternalToolsPage.cpp
+++ b/launcher/ui/pages/global/ExternalToolsPage.cpp
@@ -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
@@ -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..7248f0c9 100644
--- a/launcher/ui/pages/global/ExternalToolsPage.h
+++ b/launcher/ui/pages/global/ExternalToolsPage.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
@@ -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..a9ede8ed 100644
--- a/launcher/ui/pages/global/JavaPage.cpp
+++ b/launcher/ui/pages/global/JavaPage.cpp
@@ -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>
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
*
@@ -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..1a1bd96e 100644
--- a/launcher/ui/pages/global/JavaPage.h
+++ b/launcher/ui/pages/global/JavaPage.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
@@ -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/JavaPage.ui b/launcher/ui/pages/global/JavaPage.ui
index 6749cbe4..561cf79b 100644
--- a/launcher/ui/pages/global/JavaPage.ui
+++ b/launcher/ui/pages/global/JavaPage.ui
@@ -58,7 +58,7 @@
<item row="2" column="0">
<widget class="QLabel" name="labelPermGen">
<property name="text">
- <string notr="true">&amp;PermGen:</string>
+ <string>&amp;PermGen:</string>
</property>
<property name="buddy">
<cstring>permGenSpinBox</cstring>
diff --git a/launcher/ui/pages/global/LanguagePage.cpp b/launcher/ui/pages/global/LanguagePage.cpp
index fcd174bd..af6fc172 100644
--- a/launcher/ui/pages/global/LanguagePage.cpp
+++ b/launcher/ui/pages/global/LanguagePage.cpp
@@ -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>
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
*
@@ -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..ff7ce7dd 100644
--- a/launcher/ui/pages/global/LanguagePage.h
+++ b/launcher/ui/pages/global/LanguagePage.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>
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
*
@@ -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 816dde72..7f22fdb5 100644
--- a/launcher/ui/pages/global/LauncherPage.cpp
+++ b/launcher/ui/pages/global/LauncherPage.cpp
@@ -3,7 +3,7 @@
* Prism Launcher - Minecraft Launcher
* Copyright (c) 2022 Jamie Mansfield <jmansfield@cadixdev.org>
* Copyright (c) 2022 dada513 <dada513@protonmail.com>
- * Copyright (C) 2022 Tayou <tayou@gmx.net>
+ * Copyright (C) 2022 Tayou <git@tayou.org>
*
* 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
@@ -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 33f66f1b..e733224d 100644
--- a/launcher/ui/pages/global/LauncherPage.h
+++ b/launcher/ui/pages/global/LauncherPage.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
@@ -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 "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/LauncherPage.ui b/launcher/ui/pages/global/LauncherPage.ui
index d9116bfc..26408f44 100644
--- a/launcher/ui/pages/global/LauncherPage.ui
+++ b/launcher/ui/pages/global/LauncherPage.ui
@@ -169,7 +169,7 @@
<item>
<widget class="QCheckBox" name="metadataDisableBtn">
<property name="toolTip">
- <string>Disable using metadata provided by mod providers (like Modrinth or Curseforge) for mods.</string>
+ <string>Disable using metadata provided by mod providers (like Modrinth or CurseForge) for mods.</string>
</property>
<property name="text">
<string>Disable using metadata for mods</string>
diff --git a/launcher/ui/pages/global/MinecraftPage.cpp b/launcher/ui/pages/global/MinecraftPage.cpp
index eca3e865..866a4121 100644
--- a/launcher/ui/pages/global/MinecraftPage.cpp
+++ b/launcher/ui/pages/global/MinecraftPage.cpp
@@ -1,7 +1,8 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
- * PolyMC - Minecraft Launcher
+ * Prism Launcher - Minecraft Launcher
* Copyright (c) 2022 Jamie Mansfield <jmansfield@cadixdev.org>
+ * Copyright (C) 2023 seth <getchoo at tuta dot io>
*
* 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
@@ -36,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();
@@ -99,6 +100,9 @@ void MinecraftPage::applySettings()
// Miscellaneous
s->set("CloseAfterLaunch", ui->closeAfterLaunchCheck->isChecked());
s->set("QuitAfterGameStop", ui->quitAfterGameStopCheck->isChecked());
+
+ // Mod loader settings
+ s->set("DisableQuiltBeacon", ui->disableQuiltBeaconCheckBox->isChecked());
}
void MinecraftPage::loadSettings()
@@ -137,6 +141,8 @@ void MinecraftPage::loadSettings()
ui->closeAfterLaunchCheck->setChecked(s->get("CloseAfterLaunch").toBool());
ui->quitAfterGameStopCheck->setChecked(s->get("QuitAfterGameStop").toBool());
+
+ ui->disableQuiltBeaconCheckBox->setChecked(s->get("DisableQuiltBeacon").toBool());
}
void MinecraftPage::retranslate()
diff --git a/launcher/ui/pages/global/MinecraftPage.h b/launcher/ui/pages/global/MinecraftPage.h
index cf5f95eb..28c31b5d 100644
--- a/launcher/ui/pages/global/MinecraftPage.h
+++ b/launcher/ui/pages/global/MinecraftPage.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
@@ -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/MinecraftPage.ui b/launcher/ui/pages/global/MinecraftPage.ui
index 8f5de725..393b0f35 100644
--- a/launcher/ui/pages/global/MinecraftPage.ui
+++ b/launcher/ui/pages/global/MinecraftPage.ui
@@ -39,7 +39,7 @@
</property>
<widget class="QWidget" name="minecraftTab">
<attribute name="title">
- <string notr="true">General</string>
+ <string>General</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
@@ -191,6 +191,25 @@
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_12">
<item>
+ <widget class="QGroupBox" name="modLoaderSettingsGroupBox">
+ <property name="title">
+ <string>Mod loader settings</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_13">
+ <item>
+ <widget class="QCheckBox" name="disableQuiltBeaconCheckBox">
+ <property name="text">
+ <string>Disable Quilt Loader Beacon</string>
+ </property>
+ <property name="toolTip">
+ <string>Disable Quilt loader's beacon for counting monthly active users</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
<widget class="QGroupBox" name="nativeLibWorkaroundGroupBox">
<property name="title">
<string>Native library workarounds</string>
diff --git a/launcher/ui/pages/global/ProxyPage.cpp b/launcher/ui/pages/global/ProxyPage.cpp
index ffff8456..19b2bcea 100644
--- a/launcher/ui/pages/global/ProxyPage.cpp
+++ b/launcher/ui/pages/global/ProxyPage.cpp
@@ -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>
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
*
@@ -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..26118f18 100644
--- a/launcher/ui/pages/global/ProxyPage.h
+++ b/launcher/ui/pages/global/ProxyPage.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>
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
*
@@ -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;
};
diff --git a/launcher/ui/pages/instance/ExternalResourcesPage.cpp b/launcher/ui/pages/instance/ExternalResourcesPage.cpp
index 173bcb66..12038f88 100644
--- a/launcher/ui/pages/instance/ExternalResourcesPage.cpp
+++ b/launcher/ui/pages/instance/ExternalResourcesPage.cpp
@@ -151,9 +151,6 @@ void ExternalResourcesPage::retranslate()
void ExternalResourcesPage::itemActivated(const QModelIndex&)
{
- if (!m_controlsEnabled)
- return;
-
auto selection = m_filterModel->mapSelectionToSource(ui->treeView->selectionModel()->selection());
}
@@ -197,9 +194,6 @@ bool ExternalResourcesPage::eventFilter(QObject* obj, QEvent* ev)
void ExternalResourcesPage::addItem()
{
- if (!m_controlsEnabled)
- return;
-
auto list = GuiUtil::BrowseForFiles(
helpPage(), tr("Select %1", "Select whatever type of files the page contains. Example: 'Loader Mods'").arg(displayName()),
m_fileSelectionFilter.arg(displayName()), APPLICATION->settings()->get("CentralModsDir").toString(), this->parentWidget());
@@ -213,9 +207,6 @@ void ExternalResourcesPage::addItem()
void ExternalResourcesPage::removeItem()
{
- if (!m_controlsEnabled)
- return;
-
auto selection = m_filterModel->mapSelectionToSource(ui->treeView->selectionModel()->selection());
int count = 0;
@@ -259,23 +250,37 @@ void ExternalResourcesPage::removeItem()
void ExternalResourcesPage::removeItems(const QItemSelection& selection)
{
+ if (m_instance != nullptr && m_instance->isRunning()) {
+ auto response = CustomMessageBox::selectable(this, "Confirm Delete",
+ "If you remove this resource while the game is running it may crash your game.\n"
+ "Are you sure you want to do this?",
+ QMessageBox::Warning, QMessageBox::Yes | QMessageBox::No, QMessageBox::No)
+ ->exec();
+
+ if (response != QMessageBox::Yes)
+ return;
+ }
m_model->deleteResources(selection.indexes());
}
void ExternalResourcesPage::enableItem()
{
- if (!m_controlsEnabled)
- return;
-
auto selection = m_filterModel->mapSelectionToSource(ui->treeView->selectionModel()->selection());
m_model->setResourceEnabled(selection.indexes(), EnableAction::ENABLE);
}
void ExternalResourcesPage::disableItem()
{
- if (!m_controlsEnabled)
- return;
+ if (m_instance != nullptr && m_instance->isRunning()) {
+ auto response = CustomMessageBox::selectable(this, "Confirm disable",
+ "If you disable this resource while the game is running it may crash your game.\n"
+ "Are you sure you want to do this?",
+ QMessageBox::Warning, QMessageBox::Yes | QMessageBox::No, QMessageBox::No)
+ ->exec();
+ if (response != QMessageBox::Yes)
+ return;
+ }
auto selection = m_filterModel->mapSelectionToSource(ui->treeView->selectionModel()->selection());
m_model->setResourceEnabled(selection.indexes(), EnableAction::DISABLE);
}
diff --git a/launcher/ui/pages/instance/ExternalResourcesPage.h b/launcher/ui/pages/instance/ExternalResourcesPage.h
index 6c0a12cb..d29be0fc 100644
--- a/launcher/ui/pages/instance/ExternalResourcesPage.h
+++ b/launcher/ui/pages/instance/ExternalResourcesPage.h
@@ -4,8 +4,8 @@
#include <QSortFilterProxyModel>
#include "Application.h"
-#include "settings/Setting.h"
#include "minecraft/MinecraftInstance.h"
+#include "settings/Setting.h"
#include "ui/pages/BasePage.h"
class ResourceFolderModel;
@@ -52,7 +52,7 @@ class ExternalResourcesPage : public QMainWindow, public BasePage {
virtual void addItem();
void removeItem();
- virtual void removeItems(const QItemSelection &selection);
+ virtual void removeItems(const QItemSelection& selection);
virtual void enableItem();
virtual void disableItem();
@@ -73,7 +73,5 @@ class ExternalResourcesPage : public QMainWindow, public BasePage {
QString m_fileSelectionFilter;
QString m_viewFilter;
- bool m_controlsEnabled = true;
-
std::shared_ptr<Setting> m_wide_bar_setting = nullptr;
};
diff --git a/launcher/ui/pages/instance/ExternalResourcesPage.ui b/launcher/ui/pages/instance/ExternalResourcesPage.ui
index f676361c..3c836691 100644
--- a/launcher/ui/pages/instance/ExternalResourcesPage.ui
+++ b/launcher/ui/pages/instance/ExternalResourcesPage.ui
@@ -157,6 +157,17 @@
<string>Try to check or update all selected resources (all resources if none are selected)</string>
</property>
</action>
+ <action name="actionVisitItemPage">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Visit mod's page</string>
+ </property>
+ <property name="toolTip">
+ <string>Go to mods home page</string>
+ </property>
+ </action>
</widget>
<customwidgets>
<customwidget>
diff --git a/launcher/ui/pages/instance/GameOptionsPage.cpp b/launcher/ui/pages/instance/GameOptionsPage.cpp
index 63443166..8db392b1 100644
--- a/launcher/ui/pages/instance/GameOptionsPage.cpp
+++ b/launcher/ui/pages/instance/GameOptionsPage.cpp
@@ -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
@@ -34,23 +34,20 @@
*/
#include "GameOptionsPage.h"
-#include "ui_GameOptionsPage.h"
#include "minecraft/MinecraftInstance.h"
#include "minecraft/gameoptions/GameOptions.h"
+#include "ui_GameOptionsPage.h"
-GameOptionsPage::GameOptionsPage(MinecraftInstance * inst, QWidget* parent)
- : QWidget(parent), ui(new Ui::GameOptionsPage)
+GameOptionsPage::GameOptionsPage(MinecraftInstance* inst, QWidget* parent) : QWidget(parent), ui(new Ui::GameOptionsPage)
{
ui->setupUi(this);
ui->tabWidget->tabBar()->hide();
m_model = inst->gameOptionsModel();
ui->optionsView->setModel(m_model.get());
auto head = ui->optionsView->header();
- if(head->count())
- {
+ if (head->count()) {
head->setSectionResizeMode(0, QHeaderView::ResizeToContents);
- for(int i = 1; i < head->count(); i++)
- {
+ for (int i = 1; i < head->count(); i++) {
head->setSectionResizeMode(i, QHeaderView::Stretch);
}
}
diff --git a/launcher/ui/pages/instance/GameOptionsPage.h b/launcher/ui/pages/instance/GameOptionsPage.h
index de8c421e..a132843e 100644
--- a/launcher/ui/pages/instance/GameOptionsPage.h
+++ b/launcher/ui/pages/instance/GameOptionsPage.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
@@ -35,50 +35,36 @@
#pragma once
-#include <QWidget>
#include <QString>
+#include <QWidget>
-#include "ui/pages/BasePage.h"
#include <Application.h>
+#include "ui/pages/BasePage.h"
-namespace Ui
-{
+namespace Ui {
class GameOptionsPage;
}
class GameOptions;
class MinecraftInstance;
-class GameOptionsPage : public QWidget, public BasePage
-{
+class GameOptionsPage : public QWidget, public BasePage {
Q_OBJECT
-public:
- explicit GameOptionsPage(MinecraftInstance *inst, QWidget *parent = 0);
+ public:
+ explicit GameOptionsPage(MinecraftInstance* inst, QWidget* parent = 0);
virtual ~GameOptionsPage();
void openedImpl() override;
void closedImpl() override;
- virtual QString displayName() const override
- {
- return tr("Game Options");
- }
- virtual QIcon icon() const override
- {
- return APPLICATION->getThemedIcon("settings");
- }
- virtual QString id() const override
- {
- return "gameoptions";
- }
- virtual QString helpPage() const override
- {
- return "Game-Options-management";
- }
+ virtual QString displayName() const override { return tr("Game Options"); }
+ virtual QIcon icon() const override { return APPLICATION->getThemedIcon("settings"); }
+ virtual QString id() const override { return "gameoptions"; }
+ virtual QString helpPage() const override { return "Game-Options-management"; }
void retranslate() override;
-private: // data
- Ui::GameOptionsPage *ui = nullptr;
+ private: // data
+ Ui::GameOptionsPage* ui = nullptr;
std::shared_ptr<GameOptions> m_model;
};
diff --git a/launcher/ui/pages/instance/InstanceSettingsPage.cpp b/launcher/ui/pages/instance/InstanceSettingsPage.cpp
index 2a7c5b27..687b82d7 100644
--- a/launcher/ui/pages/instance/InstanceSettingsPage.cpp
+++ b/launcher/ui/pages/instance/InstanceSettingsPage.cpp
@@ -1,8 +1,9 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
- * PolyMC - Minecraft Launcher
+ * Prism Launcher - Minecraft Launcher
* Copyright (c) 2022 Jamie Mansfield <jmansfield@cadixdev.org>
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
+ * Copyright (C) 2023 seth <getchoo at tuta dot io>
*
* 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
@@ -37,8 +38,8 @@
#include "InstanceSettingsPage.h"
#include "ui_InstanceSettingsPage.h"
-#include <QFileDialog>
#include <QDialog>
+#include <QFileDialog>
#include <QMessageBox>
#include <sys.h>
@@ -46,31 +47,27 @@
#include "ui/dialogs/VersionSelectDialog.h"
#include "ui/widgets/CustomCommands.h"
-#include "JavaCommon.h"
#include "Application.h"
+#include "JavaCommon.h"
#include "minecraft/auth/AccountList.h"
+#include "FileSystem.h"
#include "java/JavaInstallList.h"
#include "java/JavaUtils.h"
-#include "FileSystem.h"
-InstanceSettingsPage::InstanceSettingsPage(BaseInstance *inst, QWidget *parent)
+InstanceSettingsPage::InstanceSettingsPage(BaseInstance* inst, QWidget* parent)
: QWidget(parent), ui(new Ui::InstanceSettingsPage), m_instance(inst)
{
m_settings = inst->settings();
ui->setupUi(this);
- // As the signal will (probably) not be triggered once we click edit, let's update it manually instead.
- updateRunningStatus(m_instance->isRunning());
-
- connect(m_instance, &BaseInstance::runningStatusChanged, this, &InstanceSettingsPage::updateRunningStatus);
connect(ui->openGlobalJavaSettingsButton, &QCommandLinkButton::clicked, this, &InstanceSettingsPage::globalSettingsButtonClicked);
connect(APPLICATION, &Application::globalSettingsAboutToOpen, this, &InstanceSettingsPage::applySettings);
connect(APPLICATION, &Application::globalSettingsClosed, this, &InstanceSettingsPage::loadSettings);
- connect(ui->instanceAccountSelector, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &InstanceSettingsPage::changeInstanceAccount);
+ connect(ui->instanceAccountSelector, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
+ &InstanceSettingsPage::changeInstanceAccount);
loadSettings();
-
updateThresholds();
}
@@ -81,7 +78,7 @@ InstanceSettingsPage::~InstanceSettingsPage()
void InstanceSettingsPage::globalSettingsButtonClicked(bool)
{
- switch(ui->settingsTabs->currentIndex()) {
+ switch (ui->settingsTabs->currentIndex()) {
case 0:
APPLICATION->ShowGlobalSettings(this, "java-settings");
return;
@@ -107,13 +104,10 @@ void InstanceSettingsPage::applySettings()
// Miscellaneous
bool miscellaneous = ui->miscellaneousSettingsBox->isChecked();
m_settings->set("OverrideMiscellaneous", miscellaneous);
- if (miscellaneous)
- {
+ if (miscellaneous) {
m_settings->set("CloseAfterLaunch", ui->closeAfterLaunchCheck->isChecked());
m_settings->set("QuitAfterGameStop", ui->quitAfterGameStopCheck->isChecked());
- }
- else
- {
+ } else {
m_settings->reset("CloseAfterLaunch");
m_settings->reset("QuitAfterGameStop");
}
@@ -121,14 +115,11 @@ void InstanceSettingsPage::applySettings()
// Console
bool console = ui->consoleSettingsBox->isChecked();
m_settings->set("OverrideConsole", console);
- if (console)
- {
+ if (console) {
m_settings->set("ShowConsole", ui->showConsoleCheck->isChecked());
m_settings->set("AutoCloseConsole", ui->autoCloseConsoleCheck->isChecked());
m_settings->set("ShowConsoleOnError", ui->showConsoleErrorCheck->isChecked());
- }
- else
- {
+ } else {
m_settings->reset("ShowConsole");
m_settings->reset("AutoCloseConsole");
m_settings->reset("ShowConsoleOnError");
@@ -137,14 +128,11 @@ void InstanceSettingsPage::applySettings()
// Window Size
bool window = ui->windowSizeGroupBox->isChecked();
m_settings->set("OverrideWindow", window);
- if (window)
- {
+ if (window) {
m_settings->set("LaunchMaximized", ui->maximizedCheckBox->isChecked());
m_settings->set("MinecraftWinWidth", ui->windowWidthSpinBox->value());
m_settings->set("MinecraftWinHeight", ui->windowHeightSpinBox->value());
- }
- else
- {
+ } else {
m_settings->reset("LaunchMaximized");
m_settings->reset("MinecraftWinWidth");
m_settings->reset("MinecraftWinHeight");
@@ -153,24 +141,18 @@ void InstanceSettingsPage::applySettings()
// Memory
bool memory = ui->memoryGroupBox->isChecked();
m_settings->set("OverrideMemory", memory);
- if (memory)
- {
+ if (memory) {
int min = ui->minMemSpinBox->value();
int max = ui->maxMemSpinBox->value();
- if(min < max)
- {
+ if (min < max) {
m_settings->set("MinMemAlloc", min);
m_settings->set("MaxMemAlloc", max);
- }
- else
- {
+ } else {
m_settings->set("MinMemAlloc", max);
m_settings->set("MaxMemAlloc", min);
}
m_settings->set("PermGen", ui->permGenSpinBox->value());
- }
- else
- {
+ } else {
m_settings->reset("MinMemAlloc");
m_settings->reset("MaxMemAlloc");
m_settings->reset("PermGen");
@@ -179,13 +161,10 @@ void InstanceSettingsPage::applySettings()
// Java Install Settings
bool javaInstall = ui->javaSettingsGroupBox->isChecked();
m_settings->set("OverrideJavaLocation", javaInstall);
- if (javaInstall)
- {
+ if (javaInstall) {
m_settings->set("JavaPath", ui->javaPathTextBox->text());
m_settings->set("IgnoreJavaCompatibility", ui->skipCompatibilityCheckbox->isChecked());
- }
- else
- {
+ } else {
m_settings->reset("JavaPath");
m_settings->reset("IgnoreJavaCompatibility");
}
@@ -193,12 +172,9 @@ void InstanceSettingsPage::applySettings()
// Java arguments
bool javaArgs = ui->javaArgumentsGroupBox->isChecked();
m_settings->set("OverrideJavaArgs", javaArgs);
- if(javaArgs)
- {
+ if (javaArgs) {
m_settings->set("JvmArgs", ui->jvmArgsTextBox->toPlainText().replace("\n", " "));
- }
- else
- {
+ } else {
m_settings->reset("JvmArgs");
}
@@ -208,14 +184,11 @@ void InstanceSettingsPage::applySettings()
// Custom Commands
bool custcmd = ui->customCommands->checked();
m_settings->set("OverrideCommands", custcmd);
- if (custcmd)
- {
+ if (custcmd) {
m_settings->set("PreLaunchCommand", ui->customCommands->prelaunchCommand());
m_settings->set("WrapperCommand", ui->customCommands->wrapperCommand());
m_settings->set("PostExitCommand", ui->customCommands->postexitCommand());
- }
- else
- {
+ } else {
m_settings->reset("PreLaunchCommand");
m_settings->reset("WrapperCommand");
m_settings->reset("PostExitCommand");
@@ -224,13 +197,10 @@ void InstanceSettingsPage::applySettings()
// Workarounds
bool workarounds = ui->nativeWorkaroundsGroupBox->isChecked();
m_settings->set("OverrideNativeWorkarounds", workarounds);
- if(workarounds)
- {
+ if (workarounds) {
m_settings->set("UseNativeOpenAL", ui->useNativeOpenALCheck->isChecked());
m_settings->set("UseNativeGLFW", ui->useNativeGLFWCheck->isChecked());
- }
- else
- {
+ } else {
m_settings->reset("UseNativeOpenAL");
m_settings->reset("UseNativeGLFW");
}
@@ -238,14 +208,11 @@ void InstanceSettingsPage::applySettings()
// Performance
bool performance = ui->perfomanceGroupBox->isChecked();
m_settings->set("OverridePerformance", performance);
- if(performance)
- {
+ if (performance) {
m_settings->set("EnableFeralGamemode", ui->enableFeralGamemodeCheck->isChecked());
m_settings->set("EnableMangoHud", ui->enableMangoHud->isChecked());
m_settings->set("UseDiscreteGpu", ui->useDiscreteGpuCheck->isChecked());
- }
- else
- {
+ } else {
m_settings->reset("EnableFeralGamemode");
m_settings->reset("EnableMangoHud");
m_settings->reset("UseDiscreteGpu");
@@ -254,13 +221,10 @@ void InstanceSettingsPage::applySettings()
// Game time
bool gameTime = ui->gameTimeGroupBox->isChecked();
m_settings->set("OverrideGameTime", gameTime);
- if (gameTime)
- {
+ if (gameTime) {
m_settings->set("ShowGameTime", ui->showGameTime->isChecked());
m_settings->set("RecordGameTime", ui->recordGameTime->isChecked());
- }
- else
- {
+ } else {
m_settings->reset("ShowGameTime");
m_settings->reset("RecordGameTime");
}
@@ -268,12 +232,9 @@ void InstanceSettingsPage::applySettings()
// Join server on launch
bool joinServerOnLaunch = ui->serverJoinGroupBox->isChecked();
m_settings->set("JoinServerOnLaunch", joinServerOnLaunch);
- if (joinServerOnLaunch)
- {
+ if (joinServerOnLaunch) {
m_settings->set("JoinServerOnLaunchAddress", ui->serverJoinAddress->text());
- }
- else
- {
+ } else {
m_settings->reset("JoinServerOnLaunchAddress");
}
@@ -284,6 +245,14 @@ void InstanceSettingsPage::applySettings()
m_settings->reset("InstanceAccountId");
}
+ bool overrideModLoaderSettings = ui->modLoaderSettingsGroupBox->isChecked();
+ m_settings->set("OverrideModLoaderSettings", overrideModLoaderSettings);
+ if (overrideModLoaderSettings) {
+ m_settings->set("DisableQuiltBeacon", ui->disableQuiltBeaconCheckBox->isChecked());
+ } else {
+ m_settings->reset("DisableQuiltBeacon");
+ }
+
// FIXME: This should probably be called by a signal instead
m_instance->updateRuntimeContext();
}
@@ -311,13 +280,10 @@ void InstanceSettingsPage::loadSettings()
ui->memoryGroupBox->setChecked(m_settings->get("OverrideMemory").toBool());
int min = m_settings->get("MinMemAlloc").toInt();
int max = m_settings->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);
}
@@ -327,7 +293,6 @@ void InstanceSettingsPage::loadSettings()
ui->labelPermGen->setVisible(permGenVisible);
ui->labelPermgenNote->setVisible(permGenVisible);
-
// Java Settings
bool overrideJava = m_settings->get("OverrideJava").toBool();
bool overrideLocation = m_settings->get("OverrideJavaLocation").toBool() || overrideJava;
@@ -341,13 +306,8 @@ void InstanceSettingsPage::loadSettings()
ui->jvmArgsTextBox->setPlainText(m_settings->get("JvmArgs").toString());
// Custom commands
- ui->customCommands->initialize(
- true,
- m_settings->get("OverrideCommands").toBool(),
- m_settings->get("PreLaunchCommand").toString(),
- m_settings->get("WrapperCommand").toString(),
- m_settings->get("PostExitCommand").toString()
- );
+ ui->customCommands->initialize(true, m_settings->get("OverrideCommands").toBool(), m_settings->get("PreLaunchCommand").toString(),
+ m_settings->get("WrapperCommand").toString(), m_settings->get("PostExitCommand").toString());
// Workarounds
ui->nativeWorkaroundsGroupBox->setChecked(m_settings->get("OverrideNativeWorkarounds").toBool());
@@ -384,6 +344,10 @@ void InstanceSettingsPage::loadSettings()
ui->instanceAccountGroupBox->setChecked(m_settings->get("UseAccountForInstance").toBool());
updateAccountsMenu();
+
+ // Mod loader specific settings
+ ui->modLoaderSettingsGroupBox->setChecked(m_settings->get("OverrideModLoaderSettings").toBool());
+ ui->disableQuiltBeaconCheckBox->setChecked(m_settings->get("DisableQuiltBeacon").toBool());
}
void InstanceSettingsPage::on_javaDetectBtn_clicked()
@@ -399,8 +363,7 @@ void InstanceSettingsPage::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);
bool visible = java->id.requiresPermGen() && m_settings->get("OverrideMemory").toBool();
@@ -416,15 +379,13 @@ void InstanceSettingsPage::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())
- {
+ if (!javaInfo.exists() || !javaInfo.isExecutable()) {
return;
}
ui->javaPathTextBox->setText(cooked_path);
@@ -438,13 +399,11 @@ void InstanceSettingsPage::on_javaBrowseBtn_clicked()
void InstanceSettingsPage::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();
}
@@ -461,7 +420,6 @@ void InstanceSettingsPage::updateAccountsMenu()
if (i == accountIndex)
ui->instanceAccountSelector->setCurrentIndex(i);
}
-
}
QIcon InstanceSettingsPage::getFaceForAccount(MinecraftAccountPtr account)
@@ -523,8 +481,3 @@ void InstanceSettingsPage::updateThresholds()
ui->labelMaxMemIcon->setPixmap(pix);
}
}
-
-void InstanceSettingsPage::updateRunningStatus(bool running)
-{
- setEnabled(!running);
-}
diff --git a/launcher/ui/pages/instance/InstanceSettingsPage.h b/launcher/ui/pages/instance/InstanceSettingsPage.h
index 0438fe3b..21ecbaf8 100644
--- a/launcher/ui/pages/instance/InstanceSettingsPage.h
+++ b/launcher/ui/pages/instance/InstanceSettingsPage.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
@@ -46,41 +46,26 @@
#include "ui/pages/BasePage.h"
class JavaChecker;
-namespace Ui
-{
+namespace Ui {
class InstanceSettingsPage;
}
-class InstanceSettingsPage : public QWidget, public BasePage
-{
+class InstanceSettingsPage : public QWidget, public BasePage {
Q_OBJECT
-public:
- explicit InstanceSettingsPage(BaseInstance *inst, QWidget *parent = 0);
+ public:
+ explicit InstanceSettingsPage(BaseInstance* inst, QWidget* parent = 0);
virtual ~InstanceSettingsPage();
- virtual QString displayName() const override
- {
- return tr("Settings");
- }
- virtual QIcon icon() const override
- {
- return APPLICATION->getThemedIcon("instance-settings");
- }
- virtual QString id() const override
- {
- return "settings";
- }
+ virtual QString displayName() const override { return tr("Settings"); }
+ virtual QIcon icon() const override { return APPLICATION->getThemedIcon("instance-settings"); }
+ virtual QString id() const override { return "settings"; }
virtual bool apply() override;
- virtual QString helpPage() const override
- {
- return "Instance-settings";
- }
+ virtual QString helpPage() const override { return "Instance-settings"; }
void retranslate() override;
void updateThresholds();
-private slots:
- void updateRunningStatus(bool running);
+ private slots:
void on_javaDetectBtn_clicked();
void on_javaTestBtn_clicked();
void on_javaBrowseBtn_clicked();
@@ -97,9 +82,9 @@ private slots:
QIcon getFaceForAccount(MinecraftAccountPtr account);
void changeInstanceAccount(int index);
-private:
- Ui::InstanceSettingsPage *ui;
- BaseInstance *m_instance;
+ private:
+ Ui::InstanceSettingsPage* ui;
+ BaseInstance* m_instance;
SettingsObjectPtr m_settings;
unique_qobject_ptr<JavaCommon::TestCheck> checker;
};
diff --git a/launcher/ui/pages/instance/InstanceSettingsPage.ui b/launcher/ui/pages/instance/InstanceSettingsPage.ui
index 8427965d..245433fe 100644
--- a/launcher/ui/pages/instance/InstanceSettingsPage.ui
+++ b/launcher/ui/pages/instance/InstanceSettingsPage.ui
@@ -116,7 +116,7 @@
<item row="2" column="0">
<widget class="QLabel" name="labelPermGen">
<property name="text">
- <string notr="true">PermGen:</string>
+ <string>PermGen:</string>
</property>
</widget>
</item>
@@ -542,6 +542,31 @@
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_9">
<item>
+ <widget class="QGroupBox" name="modLoaderSettingsGroupBox">
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ <property name="checked">
+ <bool>false</bool>
+ </property>
+ <property name="title">
+ <string>Mod loader settings</string>
+ </property>
+ <layout class="QVBoxLayout" name="VerticalLayout_16">
+ <item>
+ <widget class="QCheckBox" name="disableQuiltBeaconCheckBox">
+ <property name="text">
+ <string>Disable Quilt Loader Beacon</string>
+ </property>
+ <property name="toolTip">
+ <string>Disable Quilt loader's beacon for counting monthly active users</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
<widget class="QGroupBox" name="gameTimeGroupBox">
<property name="enabled">
<bool>true</bool>
diff --git a/launcher/ui/pages/instance/LogPage.cpp b/launcher/ui/pages/instance/LogPage.cpp
index 639cd711..8e1e5376 100644
--- a/launcher/ui/pages/instance/LogPage.cpp
+++ b/launcher/ui/pages/instance/LogPage.cpp
@@ -47,56 +47,42 @@
#include "launch/LaunchTask.h"
#include "settings/Setting.h"
-#include "ui/GuiUtil.h"
#include "ui/ColorCache.h"
+#include "ui/GuiUtil.h"
#include <BuildConfig.h>
-class LogFormatProxyModel : public QIdentityProxyModel
-{
-public:
- LogFormatProxyModel(QObject* parent = nullptr) : QIdentityProxyModel(parent)
- {
- }
- QVariant data(const QModelIndex &index, int role) const override
+class LogFormatProxyModel : public QIdentityProxyModel {
+ public:
+ LogFormatProxyModel(QObject* parent = nullptr) : QIdentityProxyModel(parent) {}
+ QVariant data(const QModelIndex& index, int role) const override
{
- switch(role)
- {
+ switch (role) {
case Qt::FontRole:
return m_font;
- case Qt::ForegroundRole:
- {
- MessageLevel::Enum level = (MessageLevel::Enum) QIdentityProxyModel::data(index, LogModel::LevelRole).toInt();
+ case Qt::ForegroundRole: {
+ MessageLevel::Enum level = (MessageLevel::Enum)QIdentityProxyModel::data(index, LogModel::LevelRole).toInt();
return m_colors->getFront(level);
}
- case Qt::BackgroundRole:
- {
- MessageLevel::Enum level = (MessageLevel::Enum) QIdentityProxyModel::data(index, LogModel::LevelRole).toInt();
+ case Qt::BackgroundRole: {
+ MessageLevel::Enum level = (MessageLevel::Enum)QIdentityProxyModel::data(index, LogModel::LevelRole).toInt();
return m_colors->getBack(level);
}
default:
return QIdentityProxyModel::data(index, role);
- }
+ }
}
- void setFont(QFont font)
- {
- m_font = font;
- }
+ void setFont(QFont font) { m_font = font; }
- void setColors(LogColorCache* colors)
- {
- m_colors.reset(colors);
- }
+ void setColors(LogColorCache* colors) { m_colors.reset(colors); }
- QModelIndex find(const QModelIndex &start, const QString &value, bool reverse) const
+ QModelIndex find(const QModelIndex& start, const QString& value, bool reverse) const
{
QModelIndex parentIndex = parent(start);
- auto compare = [&](int r) -> QModelIndex
- {
+ auto compare = [&](int r) -> QModelIndex {
QModelIndex idx = index(r, start.column(), parentIndex);
- if (!idx.isValid() || idx == start)
- {
+ if (!idx.isValid() || idx == start) {
return QModelIndex();
}
QVariant v = data(idx, Qt::DisplayRole);
@@ -105,35 +91,28 @@ public:
return idx;
return QModelIndex();
};
- if(reverse)
- {
+ if (reverse) {
int from = start.row();
int to = 0;
- for (int i = 0; i < 2; ++i)
- {
- for (int r = from; (r >= to); --r)
- {
+ for (int i = 0; i < 2; ++i) {
+ for (int r = from; (r >= to); --r) {
auto idx = compare(r);
- if(idx.isValid())
+ if (idx.isValid())
return idx;
}
// prepare for the next iteration
from = rowCount() - 1;
to = start.row();
}
- }
- else
- {
+ } else {
int from = start.row();
int to = rowCount(parentIndex);
- for (int i = 0; i < 2; ++i)
- {
- for (int r = from; (r < to); ++r)
- {
+ for (int i = 0; i < 2; ++i) {
+ for (int r = from; (r < to); ++r) {
auto idx = compare(r);
- if(idx.isValid())
+ if (idx.isValid())
return idx;
}
// prepare for the next iteration
@@ -143,13 +122,13 @@ public:
}
return QModelIndex();
}
-private:
+
+ private:
QFont m_font;
std::unique_ptr<LogColorCache> m_colors;
};
-LogPage::LogPage(InstancePtr instance, QWidget *parent)
- : QWidget(parent), ui(new Ui::LogPage), m_instance(instance)
+LogPage::LogPage(InstancePtr instance, QWidget* parent) : QWidget(parent), ui(new Ui::LogPage), m_instance(instance)
{
ui->setupUi(this);
ui->tabWidget->tabBar()->hide();
@@ -167,8 +146,7 @@ LogPage::LogPage(InstancePtr instance, QWidget *parent)
QString fontFamily = APPLICATION->settings()->get("ConsoleFont").toString();
bool conversionOk = false;
int fontSize = APPLICATION->settings()->get("ConsoleFontSize").toInt(&conversionOk);
- if(!conversionOk)
- {
+ if (!conversionOk) {
fontSize = 11;
}
m_proxy->setFont(QFont(fontFamily, fontSize));
@@ -179,8 +157,7 @@ LogPage::LogPage(InstancePtr instance, QWidget *parent)
// set up instance and launch process recognition
{
auto launchTask = m_instance->getLaunchTask();
- if(launchTask)
- {
+ if (launchTask) {
setInstanceLaunchTaskChanged(launchTask, true);
}
connect(m_instance.get(), &BaseInstance::launchTaskChanged, this, &LogPage::onInstanceLaunchTaskChanged);
@@ -202,30 +179,23 @@ LogPage::~LogPage()
void LogPage::modelStateToUI()
{
- if(m_model->wrapLines())
- {
+ if (m_model->wrapLines()) {
ui->text->setWordWrap(true);
ui->wrapCheckbox->setCheckState(Qt::Checked);
- }
- else
- {
+ } else {
ui->text->setWordWrap(false);
ui->wrapCheckbox->setCheckState(Qt::Unchecked);
}
- if(m_model->suspended())
- {
+ if (m_model->suspended()) {
ui->trackLogCheckbox->setCheckState(Qt::Unchecked);
- }
- else
- {
+ } else {
ui->trackLogCheckbox->setCheckState(Qt::Checked);
}
}
void LogPage::UIToModelState()
{
- if(!m_model)
- {
+ if (!m_model) {
return;
}
m_model->setLineWrap(ui->wrapCheckbox->checkState() == Qt::Checked);
@@ -235,21 +205,15 @@ void LogPage::UIToModelState()
void LogPage::setInstanceLaunchTaskChanged(shared_qobject_ptr<LaunchTask> proc, bool initial)
{
m_process = proc;
- if(m_process)
- {
+ if (m_process) {
m_model = proc->getLogModel();
m_proxy->setSourceModel(m_model.get());
- if(initial)
- {
+ if (initial) {
modelStateToUI();
- }
- else
- {
+ } else {
UIToModelState();
}
- }
- else
- {
+ } else {
m_proxy->setSourceModel(nullptr);
m_model.reset();
}
@@ -272,34 +236,25 @@ bool LogPage::shouldDisplay() const
void LogPage::on_btnPaste_clicked()
{
- if(!m_model)
+ if (!m_model)
return;
- //FIXME: turn this into a proper task and move the upload logic out of GuiUtil!
- m_model->append(
- MessageLevel::Launcher,
- QString("Log upload triggered at: %1").arg(
- QDateTime::currentDateTime().toString(Qt::RFC2822Date)
- )
- );
+ // FIXME: turn this into a proper task and move the upload logic out of GuiUtil!
+ m_model->append(MessageLevel::Launcher,
+ QString("Log upload triggered at: %1").arg(QDateTime::currentDateTime().toString(Qt::RFC2822Date)));
auto url = GuiUtil::uploadPaste(tr("Minecraft Log"), m_model->toPlainText(), this);
- if(!url.has_value())
- {
+ if (!url.has_value()) {
m_model->append(MessageLevel::Error, QString("Log upload canceled"));
- }
- else if (url->isNull())
- {
+ } else if (url->isNull()) {
m_model->append(MessageLevel::Error, QString("Log upload failed!"));
- }
- else
- {
+ } else {
m_model->append(MessageLevel::Launcher, QString("Log uploaded to: %1").arg(url.value()));
}
}
void LogPage::on_btnCopy_clicked()
{
- if(!m_model)
+ if (!m_model)
return;
m_model->append(MessageLevel::Launcher, QString("Clipboard copy at: %1").arg(QDateTime::currentDateTime().toString(Qt::RFC2822Date)));
GuiUtil::setClipboardText(m_model->toPlainText());
@@ -307,7 +262,7 @@ void LogPage::on_btnCopy_clicked()
void LogPage::on_btnClear_clicked()
{
- if(!m_model)
+ if (!m_model)
return;
m_model->clear();
m_container->refreshContainer();
@@ -320,7 +275,7 @@ void LogPage::on_btnBottom_clicked()
void LogPage::on_trackLogCheckbox_clicked(bool checked)
{
- if(!m_model)
+ if (!m_model)
return;
m_model->suspend(!checked);
}
@@ -328,7 +283,7 @@ void LogPage::on_trackLogCheckbox_clicked(bool checked)
void LogPage::on_wrapCheckbox_clicked(bool checked)
{
ui->text->setWordWrap(checked);
- if(!m_model)
+ if (!m_model)
return;
m_model->setLineWrap(checked);
}
@@ -353,8 +308,7 @@ void LogPage::findPreviousActivated()
void LogPage::findActivated()
{
// focus the search bar if it doesn't have focus
- if (!ui->searchBar->hasFocus())
- {
+ if (!ui->searchBar->hasFocus()) {
ui->searchBar->setFocus();
ui->searchBar->selectAll();
}
diff --git a/launcher/ui/pages/instance/LogPage.h b/launcher/ui/pages/instance/LogPage.h
index f6fe87c4..6c259891 100644
--- a/launcher/ui/pages/instance/LogPage.h
+++ b/launcher/ui/pages/instance/LogPage.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
@@ -37,46 +37,32 @@
#include <QWidget>
+#include <Application.h>
#include "BaseInstance.h"
#include "launch/LaunchTask.h"
#include "ui/pages/BasePage.h"
-#include <Application.h>
-namespace Ui
-{
+namespace Ui {
class LogPage;
}
class QTextCharFormat;
class LogFormatProxyModel;
-class LogPage : public QWidget, public BasePage
-{
+class LogPage : public QWidget, public BasePage {
Q_OBJECT
-public:
- explicit LogPage(InstancePtr instance, QWidget *parent = 0);
+ public:
+ explicit LogPage(InstancePtr instance, QWidget* parent = 0);
virtual ~LogPage();
- virtual QString displayName() const override
- {
- return tr("Minecraft Log");
- }
- virtual QIcon icon() const override
- {
- return APPLICATION->getThemedIcon("log");
- }
- virtual QString id() const override
- {
- return "console";
- }
+ virtual QString displayName() const override { return tr("Minecraft Log"); }
+ virtual QIcon icon() const override { return APPLICATION->getThemedIcon("log"); }
+ virtual QString id() const override { return "console"; }
virtual bool apply() override;
- virtual QString helpPage() const override
- {
- return "Minecraft-Logs";
- }
+ virtual QString helpPage() const override { return "Minecraft-Logs"; }
virtual bool shouldDisplay() const override;
void retranslate() override;
-private slots:
+ private slots:
void on_btnPaste_clicked();
void on_btnCopy_clicked();
void on_btnClear_clicked();
@@ -92,16 +78,16 @@ private slots:
void onInstanceLaunchTaskChanged(shared_qobject_ptr<LaunchTask> proc);
-private:
+ private:
void modelStateToUI();
void UIToModelState();
void setInstanceLaunchTaskChanged(shared_qobject_ptr<LaunchTask> proc, bool initial);
-private:
- Ui::LogPage *ui;
+ private:
+ Ui::LogPage* ui;
InstancePtr m_instance;
shared_qobject_ptr<LaunchTask> m_process;
- LogFormatProxyModel * m_proxy;
- shared_qobject_ptr <LogModel> m_model;
+ LogFormatProxyModel* m_proxy;
+ shared_qobject_ptr<LogModel> m_model;
};
diff --git a/launcher/ui/pages/instance/ManagedPackPage.cpp b/launcher/ui/pages/instance/ManagedPackPage.cpp
index d89c5bfc..0443baf1 100644
--- a/launcher/ui/pages/instance/ManagedPackPage.cpp
+++ b/launcher/ui/pages/instance/ManagedPackPage.cpp
@@ -3,6 +3,9 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "ManagedPackPage.h"
+#include <QDesktopServices>
+#include <QUrl>
+#include <QUrlQuery>
#include "ui_ManagedPackPage.h"
#include <QListView>
@@ -69,7 +72,6 @@ class NoBigComboBoxStyle : public QProxyStyle {
private:
NoBigComboBoxStyle(QStyle* style) : QProxyStyle(style) {}
-
};
ManagedPackPage* ManagedPackPage::createPage(BaseInstance* inst, QString type, QWidget* parent)
@@ -91,19 +93,32 @@ ManagedPackPage::ManagedPackPage(BaseInstance* inst, InstanceWindow* instance_wi
// NOTE: GTK2 themes crash with the proxy style.
// This seems like an upstream bug, so there's not much else that can be done.
- if (!QStyleFactory::keys().contains("gtk2")){
+ if (!QStyleFactory::keys().contains("gtk2")) {
auto comboStyle = NoBigComboBoxStyle::getInstance(ui->versionsComboBox->style());
ui->versionsComboBox->setStyle(comboStyle);
}
ui->reloadButton->setVisible(false);
- connect(ui->reloadButton, &QPushButton::clicked, this, [this](bool){
+ connect(ui->reloadButton, &QPushButton::clicked, this, [this](bool) {
ui->reloadButton->setVisible(false);
m_loaded = false;
// Pretend we're opening the page again
openedImpl();
});
+
+ connect(ui->changelogTextBrowser, &QTextBrowser::anchorClicked, this, [](const QUrl url) {
+ if (url.scheme().isEmpty()) {
+ auto querry =
+ QUrlQuery(url.query()).queryItemValue("remoteUrl", QUrl::FullyDecoded); // curseforge workaround for linkout?remoteUrl=
+ auto decoded = QUrl::fromPercentEncoding(querry.toUtf8());
+ auto newUrl = QUrl(decoded);
+ if (newUrl.isValid() && (newUrl.scheme() == "http" || newUrl.scheme() == "https"))
+ QDesktopServices ::openUrl(newUrl);
+ return;
+ }
+ QDesktopServices::openUrl(url);
+ });
}
ManagedPackPage::~ManagedPackPage()
@@ -226,7 +241,8 @@ void ModrinthManagedPackPage::parseManagedPack()
QString id = m_inst->getManagedPackID();
- m_fetch_job->addNetAction(Net::Download::makeByteArray(QString("%1/project/%2/version").arg(BuildConfig.MODRINTH_PROD_URL, id), response));
+ m_fetch_job->addNetAction(
+ Net::Download::makeByteArray(QString("%1/project/%2/version").arg(BuildConfig.MODRINTH_PROD_URL, id), response));
QObject::connect(m_fetch_job.get(), &NetJob::succeeded, this, [this, response, id] {
QJsonParseError parse_error{};
@@ -267,7 +283,6 @@ void ModrinthManagedPackPage::parseManagedPack()
if (version.version == m_inst->getManagedPackVersionName())
name = tr("%1 (Current)").arg(name);
-
ui->versionsComboBox->addItem(name, QVariant(version.id));
}
@@ -291,6 +306,10 @@ QString ModrinthManagedPackPage::url() const
void ModrinthManagedPackPage::suggestVersion()
{
auto index = ui->versionsComboBox->currentIndex();
+ if (m_pack.versions.length() == 0) {
+ setFailState();
+ return;
+ }
auto version = m_pack.versions.at(index);
ui->changelogTextBrowser->setHtml(markdownToHTML(version.changelog.toUtf8()));
@@ -301,6 +320,10 @@ void ModrinthManagedPackPage::suggestVersion()
void ModrinthManagedPackPage::update()
{
auto index = ui->versionsComboBox->currentIndex();
+ if (m_pack.versions.length() == 0) {
+ setFailState();
+ return;
+ }
auto version = m_pack.versions.at(index);
QMap<QString, QString> extra_info;
@@ -429,6 +452,10 @@ QString FlameManagedPackPage::url() const
void FlameManagedPackPage::suggestVersion()
{
auto index = ui->versionsComboBox->currentIndex();
+ if (m_pack.versions.length() == 0) {
+ setFailState();
+ return;
+ }
auto version = m_pack.versions.at(index);
ui->changelogTextBrowser->setHtml(m_api.getModFileChangelog(m_inst->getManagedPackID().toInt(), version.fileId));
@@ -439,6 +466,10 @@ void FlameManagedPackPage::suggestVersion()
void FlameManagedPackPage::update()
{
auto index = ui->versionsComboBox->currentIndex();
+ if (m_pack.versions.length() == 0) {
+ setFailState();
+ return;
+ }
auto version = m_pack.versions.at(index);
QMap<QString, QString> extra_info;
diff --git a/launcher/ui/pages/instance/ManagedPackPage.ui b/launcher/ui/pages/instance/ManagedPackPage.ui
index bbe44a94..05e91bbc 100644
--- a/launcher/ui/pages/instance/ManagedPackPage.ui
+++ b/launcher/ui/pages/instance/ManagedPackPage.ui
@@ -168,10 +168,13 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
- <widget class="QTextBrowser" name="changelogTextBrowser">
+ <widget class="ProjectDescriptionPage" name="changelogTextBrowser">
<property name="placeholderText">
<string>No changelog available for this version!</string>
</property>
+ <property name="openLinks">
+ <bool>false</bool>
+ </property>
</widget>
</item>
</layout>
@@ -188,6 +191,13 @@
</item>
</layout>
</widget>
+ <customwidgets>
+ <customwidget>
+ <class>ProjectDescriptionPage</class>
+ <extends>QTextBrowser</extends>
+ <header>ui/widgets/ProjectDescriptionPage.h</header>
+ </customwidget>
+ </customwidgets>
<resources/>
<connections/>
</ui>
diff --git a/launcher/ui/pages/instance/ModFolderPage.cpp b/launcher/ui/pages/instance/ModFolderPage.cpp
index 90e7d0d6..cef292bd 100644
--- a/launcher/ui/pages/instance/ModFolderPage.cpp
+++ b/launcher/ui/pages/instance/ModFolderPage.cpp
@@ -45,6 +45,7 @@
#include <QMenu>
#include <QMessageBox>
#include <QSortFilterProxyModel>
+#include <algorithm>
#include "Application.h"
@@ -60,6 +61,7 @@
#include "minecraft/mod/Mod.h"
#include "minecraft/mod/ModFolderModel.h"
+#include "modplatform/ModIndex.h"
#include "modplatform/ResourceAPI.h"
#include "Version.h"
@@ -86,12 +88,28 @@ ModFolderPage::ModFolderPage(BaseInstance* inst, std::shared_ptr<ModFolderModel>
ui->actionsToolbar->insertActionAfter(ui->actionAddItem, ui->actionUpdateItem);
connect(ui->actionUpdateItem, &QAction::triggered, this, &ModFolderPage::updateMods);
- auto check_allow_update = [this] {
- return (!m_instance || !m_instance->isRunning()) && (ui->treeView->selectionModel()->hasSelection() || !m_model->empty());
- };
+ ui->actionVisitItemPage->setToolTip(tr("Go to mod's home page"));
+ ui->actionsToolbar->addAction(ui->actionVisitItemPage);
+ connect(ui->actionVisitItemPage, &QAction::triggered, this, &ModFolderPage::visitModPages);
- connect(ui->treeView->selectionModel(), &QItemSelectionModel::selectionChanged, this,
- [this, check_allow_update] { ui->actionUpdateItem->setEnabled(check_allow_update()); });
+ auto check_allow_update = [this] { return ui->treeView->selectionModel()->hasSelection() || !m_model->empty(); };
+
+ connect(ui->treeView->selectionModel(), &QItemSelectionModel::selectionChanged, this, [this, check_allow_update] {
+ ui->actionUpdateItem->setEnabled(check_allow_update());
+
+ auto selection = m_filterModel->mapSelectionToSource(ui->treeView->selectionModel()->selection()).indexes();
+ auto mods_list = m_model->selectedMods(selection);
+ auto selected = std::count_if(mods_list.cbegin(), mods_list.cend(),
+ [](Mod* v) { return v->metadata() != nullptr || v->homeurl().size() != 0; });
+ if (selected <= 1) {
+ ui->actionVisitItemPage->setText(tr("Visit mod's page"));
+ ui->actionVisitItemPage->setToolTip(tr("Go to mod's home page"));
+ } else {
+ ui->actionVisitItemPage->setText(tr("Visit mods' pages"));
+ ui->actionVisitItemPage->setToolTip(tr("Go to the pages of the selected mods"));
+ }
+ ui->actionVisitItemPage->setEnabled(selected != 0);
+ });
connect(mods.get(), &ModFolderModel::rowsInserted, this,
[this, check_allow_update] { ui->actionUpdateItem->setEnabled(check_allow_update()); });
@@ -101,22 +119,9 @@ ModFolderPage::ModFolderPage(BaseInstance* inst, std::shared_ptr<ModFolderModel>
connect(mods.get(), &ModFolderModel::updateFinished, this,
[this, check_allow_update] { ui->actionUpdateItem->setEnabled(check_allow_update()); });
-
- connect(m_instance, &BaseInstance::runningStatusChanged, this, &ModFolderPage::runningStateChanged);
- ModFolderPage::runningStateChanged(m_instance && m_instance->isRunning());
}
}
-void ModFolderPage::runningStateChanged(bool running)
-{
- ui->actionDownloadItem->setEnabled(!running);
- ui->actionUpdateItem->setEnabled(!running);
- ui->actionAddItem->setEnabled(!running);
- ui->actionEnableItem->setEnabled(!running);
- ui->actionDisableItem->setEnabled(!running);
- ui->actionRemoveItem->setEnabled(!running);
-}
-
bool ModFolderPage::shouldDisplay() const
{
return true;
@@ -133,15 +138,23 @@ bool ModFolderPage::onSelectionChanged(const QModelIndex& current, const QModelI
return true;
}
-void ModFolderPage::removeItems(const QItemSelection &selection)
+void ModFolderPage::removeItems(const QItemSelection& selection)
{
+ if (m_instance != nullptr && m_instance->isRunning()) {
+ auto response = CustomMessageBox::selectable(this, "Confirm Delete",
+ "If you remove mods while the game is running it may crash your game.\n"
+ "Are you sure you want to do this?",
+ QMessageBox::Warning, QMessageBox::Yes | QMessageBox::No, QMessageBox::No)
+ ->exec();
+
+ if (response != QMessageBox::Yes)
+ return;
+ }
m_model->deleteMods(selection.indexes());
}
void ModFolderPage::installMods()
{
- if (!m_controlsEnabled)
- return;
if (m_instance->typeName() != "Minecraft")
return; // this is a null instance or a legacy instance
@@ -207,8 +220,7 @@ void ModFolderPage::updateMods()
message = tr("All selected mods are up-to-date! :)");
}
}
- CustomMessageBox::selectable(this, tr("Update checker"), message)
- ->exec();
+ CustomMessageBox::selectable(this, tr("Update checker"), message)->exec();
return;
}
@@ -275,3 +287,13 @@ bool NilModFolderPage::shouldDisplay() const
{
return m_model->dir().exists();
}
+
+void ModFolderPage::visitModPages()
+{
+ auto selection = m_filterModel->mapSelectionToSource(ui->treeView->selectionModel()->selection()).indexes();
+ for (auto mod : m_model->selectedMods(selection)) {
+ auto url = mod->metaurl();
+ if (!url.isEmpty())
+ DesktopServices::openUrl(url);
+ }
+}
diff --git a/launcher/ui/pages/instance/ModFolderPage.h b/launcher/ui/pages/instance/ModFolderPage.h
index 2fc7b574..a23dcae1 100644
--- a/launcher/ui/pages/instance/ModFolderPage.h
+++ b/launcher/ui/pages/instance/ModFolderPage.h
@@ -4,6 +4,7 @@
* Copyright (c) 2022 Jamie Mansfield <jmansfield@cadixdev.org>
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
* Copyright (C) 2022 TheKodeToad <TheKodeToad@proton.me>
+ * Copyright (c) 2023 Trial97 <alexandru.tripon97@gmail.com>
*
* 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
@@ -59,11 +60,11 @@ class ModFolderPage : public ExternalResourcesPage {
bool onSelectionChanged(const QModelIndex& current, const QModelIndex& previous) override;
private slots:
- void runningStateChanged(bool running);
- void removeItems(const QItemSelection &selection) override;
+ void removeItems(const QItemSelection& selection) override;
void installMods();
void updateMods();
+ void visitModPages();
protected:
std::shared_ptr<ModFolderModel> m_model;
diff --git a/launcher/ui/pages/instance/NotesPage.cpp b/launcher/ui/pages/instance/NotesPage.cpp
index 95a9fad2..a86369f8 100644
--- a/launcher/ui/pages/instance/NotesPage.cpp
+++ b/launcher/ui/pages/instance/NotesPage.cpp
@@ -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
@@ -34,11 +34,10 @@
*/
#include "NotesPage.h"
-#include "ui_NotesPage.h"
#include <QTabBar>
+#include "ui_NotesPage.h"
-NotesPage::NotesPage(BaseInstance *inst, QWidget *parent)
- : QWidget(parent), ui(new Ui::NotesPage), m_inst(inst)
+NotesPage::NotesPage(BaseInstance* inst, QWidget* parent) : QWidget(parent), ui(new Ui::NotesPage), m_inst(inst)
{
ui->setupUi(this);
ui->noteEditor->setText(m_inst->notes());
diff --git a/launcher/ui/pages/instance/NotesPage.h b/launcher/ui/pages/instance/NotesPage.h
index 80a7279b..3351d25f 100644
--- a/launcher/ui/pages/instance/NotesPage.h
+++ b/launcher/ui/pages/instance/NotesPage.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
@@ -37,45 +37,34 @@
#include <QWidget>
+#include <Application.h>
#include "BaseInstance.h"
#include "ui/pages/BasePage.h"
-#include <Application.h>
-namespace Ui
-{
+namespace Ui {
class NotesPage;
}
-class NotesPage : public QWidget, public BasePage
-{
+class NotesPage : public QWidget, public BasePage {
Q_OBJECT
-public:
- explicit NotesPage(BaseInstance *inst, QWidget *parent = 0);
+ public:
+ explicit NotesPage(BaseInstance* inst, QWidget* parent = 0);
virtual ~NotesPage();
- virtual QString displayName() const override
- {
- return tr("Notes");
- }
+ virtual QString displayName() const override { return tr("Notes"); }
virtual QIcon icon() const override
{
auto icon = APPLICATION->getThemedIcon("notes");
- if(icon.isNull())
+ if (icon.isNull())
icon = APPLICATION->getThemedIcon("news");
return icon;
}
- virtual QString id() const override
- {
- return "notes";
- }
+ virtual QString id() const override { return "notes"; }
virtual bool apply() override;
- virtual QString helpPage() const override
- {
- return "Notes";
- }
+ virtual QString helpPage() const override { return "Notes"; }
void retranslate() override;
-private:
- Ui::NotesPage *ui;
- BaseInstance *m_inst;
+ private:
+ Ui::NotesPage* ui;
+ BaseInstance* m_inst;
};
diff --git a/launcher/ui/pages/instance/OtherLogsPage.cpp b/launcher/ui/pages/instance/OtherLogsPage.cpp
index bbdd7324..b80c08e1 100644
--- a/launcher/ui/pages/instance/OtherLogsPage.cpp
+++ b/launcher/ui/pages/instance/OtherLogsPage.cpp
@@ -41,14 +41,13 @@
#include "ui/GuiUtil.h"
-#include "RecursiveFileSystemWatcher.h"
-#include <GZip.h>
#include <FileSystem.h>
+#include <GZip.h>
#include <QShortcut>
+#include "RecursiveFileSystemWatcher.h"
-OtherLogsPage::OtherLogsPage(QString path, IPathMatcher::Ptr fileFilter, QWidget *parent)
- : QWidget(parent), ui(new Ui::OtherLogsPage), m_path(path), m_fileFilter(fileFilter),
- m_watcher(new RecursiveFileSystemWatcher(this))
+OtherLogsPage::OtherLogsPage(QString path, IPathMatcher::Ptr fileFilter, QWidget* parent)
+ : QWidget(parent), ui(new Ui::OtherLogsPage), m_path(path), m_fileFilter(fileFilter), m_watcher(new RecursiveFileSystemWatcher(this))
{
ui->setupUi(this);
ui->tabWidget->tabBar()->hide();
@@ -94,21 +93,15 @@ void OtherLogsPage::populateSelectLogBox()
{
ui->selectLogBox->clear();
ui->selectLogBox->addItems(m_watcher->files());
- if (m_currentFile.isEmpty())
- {
+ if (m_currentFile.isEmpty()) {
setControlsEnabled(false);
ui->selectLogBox->setCurrentIndex(-1);
- }
- else
- {
+ } else {
const int index = ui->selectLogBox->findText(m_currentFile);
- if (index != -1)
- {
+ if (index != -1) {
ui->selectLogBox->setCurrentIndex(index);
setControlsEnabled(true);
- }
- else
- {
+ } else {
setControlsEnabled(false);
}
}
@@ -117,19 +110,15 @@ void OtherLogsPage::populateSelectLogBox()
void OtherLogsPage::on_selectLogBox_currentIndexChanged(const int index)
{
QString file;
- if (index != -1)
- {
+ if (index != -1) {
file = ui->selectLogBox->itemText(index);
}
- if (file.isEmpty() || !QFile::exists(FS::PathCombine(m_path, file)))
- {
+ if (file.isEmpty() || !QFile::exists(FS::PathCombine(m_path, file))) {
m_currentFile = QString();
ui->text->clear();
setControlsEnabled(false);
- }
- else
- {
+ } else {
m_currentFile = file;
on_btnReload_clicked();
setControlsEnabled(true);
@@ -138,64 +127,49 @@ void OtherLogsPage::on_selectLogBox_currentIndexChanged(const int index)
void OtherLogsPage::on_btnReload_clicked()
{
- if(m_currentFile.isEmpty())
- {
+ if (m_currentFile.isEmpty()) {
setControlsEnabled(false);
return;
}
QFile file(FS::PathCombine(m_path, m_currentFile));
- if (!file.open(QFile::ReadOnly))
- {
+ if (!file.open(QFile::ReadOnly)) {
setControlsEnabled(false);
- ui->btnReload->setEnabled(true); // allow reload
+ ui->btnReload->setEnabled(true); // allow reload
m_currentFile = QString();
- QMessageBox::critical(this, tr("Error"), tr("Unable to open %1 for reading: %2")
- .arg(m_currentFile, file.errorString()));
- }
- else
- {
- auto setPlainText = [&](const QString & text)
- {
+ QMessageBox::critical(this, tr("Error"), tr("Unable to open %1 for reading: %2").arg(m_currentFile, file.errorString()));
+ } else {
+ auto setPlainText = [&](const QString& text) {
QString fontFamily = APPLICATION->settings()->get("ConsoleFont").toString();
bool conversionOk = false;
int fontSize = APPLICATION->settings()->get("ConsoleFontSize").toInt(&conversionOk);
- if(!conversionOk)
- {
+ if (!conversionOk) {
fontSize = 11;
}
- QTextDocument *doc = ui->text->document();
+ QTextDocument* doc = ui->text->document();
doc->setDefaultFont(QFont(fontFamily, fontSize));
ui->text->setPlainText(text);
};
- auto showTooBig = [&]()
- {
- setPlainText(
- tr("The file (%1) is too big. You may want to open it in a viewer optimized "
- "for large files.").arg(file.fileName()));
+ auto showTooBig = [&]() {
+ setPlainText(tr("The file (%1) is too big. You may want to open it in a viewer optimized "
+ "for large files.")
+ .arg(file.fileName()));
};
- if(file.size() > (1024ll * 1024ll * 12ll))
- {
+ if (file.size() > (1024ll * 1024ll * 12ll)) {
showTooBig();
return;
}
QString content;
- if(file.fileName().endsWith(".gz"))
- {
+ if (file.fileName().endsWith(".gz")) {
QByteArray temp;
- if(!GZip::unzip(file.readAll(), temp))
- {
- setPlainText(
- tr("The file (%1) is not readable.").arg(file.fileName()));
+ if (!GZip::unzip(file.readAll(), temp)) {
+ setPlainText(tr("The file (%1) is not readable.").arg(file.fileName()));
return;
}
content = QString::fromUtf8(temp);
- }
- else
- {
+ } else {
content = QString::fromUtf8(file.readAll());
}
- if (content.size() >= 50000000ll)
- {
+ if (content.size() >= 50000000ll) {
showTooBig();
return;
}
@@ -215,8 +189,7 @@ void OtherLogsPage::on_btnCopy_clicked()
void OtherLogsPage::on_btnDelete_clicked()
{
- if(m_currentFile.isEmpty())
- {
+ if (m_currentFile.isEmpty()) {
setControlsEnabled(false);
return;
}
@@ -230,36 +203,27 @@ void OtherLogsPage::on_btnDelete_clicked()
}
QFile file(FS::PathCombine(m_path, m_currentFile));
- if (FS::trash(file.fileName()))
- {
+ if (FS::trash(file.fileName())) {
return;
}
- if (!file.remove())
- {
- QMessageBox::critical(this, tr("Error"), tr("Unable to delete %1: %2")
- .arg(m_currentFile, file.errorString()));
+ if (!file.remove()) {
+ QMessageBox::critical(this, tr("Error"), tr("Unable to delete %1: %2").arg(m_currentFile, file.errorString()));
}
}
-
-
void OtherLogsPage::on_btnClean_clicked()
{
auto toDelete = m_watcher->files();
- if(toDelete.isEmpty())
- {
+ if (toDelete.isEmpty()) {
return;
}
- QMessageBox *messageBox = new QMessageBox(this);
+ QMessageBox* messageBox = new QMessageBox(this);
messageBox->setWindowTitle(tr("Confirm Cleanup"));
- if(toDelete.size() > 5)
- {
+ if (toDelete.size() > 5) {
messageBox->setText(tr("Are you sure you want to delete all log files?"));
messageBox->setDetailedText(toDelete.join('\n'));
- }
- else
- {
+ } else {
messageBox->setText(tr("Are you sure you want to delete all these files?\n%1").arg(toDelete.join('\n')));
}
messageBox->setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
@@ -268,34 +232,26 @@ void OtherLogsPage::on_btnClean_clicked()
messageBox->setIcon(QMessageBox::Question);
messageBox->setTextInteractionFlags(Qt::TextBrowserInteraction);
- if (messageBox->exec() != QMessageBox::Ok)
- {
+ if (messageBox->exec() != QMessageBox::Ok) {
return;
}
QStringList failed;
- for(auto item: toDelete)
- {
+ for (auto item : toDelete) {
QFile file(FS::PathCombine(m_path, item));
- if (FS::trash(file.fileName()))
- {
+ if (FS::trash(file.fileName())) {
continue;
}
- if (!file.remove())
- {
+ if (!file.remove()) {
failed.push_back(item);
}
}
- if(!failed.empty())
- {
- QMessageBox *messageBox = new QMessageBox(this);
+ if (!failed.empty()) {
+ QMessageBox* messageBox = new QMessageBox(this);
messageBox->setWindowTitle(tr("Error"));
- if(failed.size() > 5)
- {
+ if (failed.size() > 5) {
messageBox->setText(tr("Couldn't delete some files!"));
messageBox->setDetailedText(failed.join('\n'));
- }
- else
- {
+ } else {
messageBox->setText(tr("Couldn't delete some files:\n%1").arg(failed.join('\n')));
}
messageBox->setStandardButtons(QMessageBox::Ok);
@@ -307,7 +263,6 @@ void OtherLogsPage::on_btnClean_clicked()
}
}
-
void OtherLogsPage::setControlsEnabled(const bool enabled)
{
ui->btnReload->setEnabled(enabled);
@@ -319,7 +274,7 @@ void OtherLogsPage::setControlsEnabled(const bool enabled)
}
// FIXME: HACK, use LogView instead?
-static void findNext(QPlainTextEdit * _this, const QString& what, bool reverse)
+static void findNext(QPlainTextEdit* _this, const QString& what, bool reverse)
{
_this->find(what, reverse ? QTextDocument::FindFlag::FindBackward : QTextDocument::FindFlag(0));
}
@@ -344,8 +299,7 @@ void OtherLogsPage::findPreviousActivated()
void OtherLogsPage::findActivated()
{
// focus the search bar if it doesn't have focus
- if (!ui->searchBar->hasFocus())
- {
+ if (!ui->searchBar->hasFocus()) {
ui->searchBar->setFocus();
ui->searchBar->selectAll();
}
diff --git a/launcher/ui/pages/instance/OtherLogsPage.h b/launcher/ui/pages/instance/OtherLogsPage.h
index 95591638..4b3b122b 100644
--- a/launcher/ui/pages/instance/OtherLogsPage.h
+++ b/launcher/ui/pages/instance/OtherLogsPage.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
@@ -37,47 +37,33 @@
#include <QWidget>
-#include "ui/pages/BasePage.h"
#include <Application.h>
#include <pathmatcher/IPathMatcher.h>
+#include "ui/pages/BasePage.h"
-namespace Ui
-{
+namespace Ui {
class OtherLogsPage;
}
class RecursiveFileSystemWatcher;
-class OtherLogsPage : public QWidget, public BasePage
-{
+class OtherLogsPage : public QWidget, public BasePage {
Q_OBJECT
-public:
- explicit OtherLogsPage(QString path, IPathMatcher::Ptr fileFilter, QWidget *parent = 0);
+ public:
+ explicit OtherLogsPage(QString path, IPathMatcher::Ptr fileFilter, QWidget* parent = 0);
~OtherLogsPage();
- QString id() const override
- {
- return "logs";
- }
- QString displayName() const override
- {
- return tr("Other logs");
- }
- QIcon icon() const override
- {
- return APPLICATION->getThemedIcon("log");
- }
- QString helpPage() const override
- {
- return "Minecraft-Logs";
- }
+ QString id() const override { return "logs"; }
+ QString displayName() const override { return tr("Other logs"); }
+ QIcon icon() const override { return APPLICATION->getThemedIcon("log"); }
+ QString helpPage() const override { return "Minecraft-Logs"; }
void retranslate() override;
void openedImpl() override;
void closedImpl() override;
-private slots:
+ private slots:
void populateSelectLogBox();
void on_selectLogBox_currentIndexChanged(const int index);
void on_btnReload_clicked();
@@ -91,13 +77,13 @@ private slots:
void findNextActivated();
void findPreviousActivated();
-private:
+ private:
void setControlsEnabled(const bool enabled);
-private:
- Ui::OtherLogsPage *ui;
+ private:
+ Ui::OtherLogsPage* ui;
QString m_path;
QString m_currentFile;
IPathMatcher::Ptr m_fileFilter;
- RecursiveFileSystemWatcher *m_watcher;
+ RecursiveFileSystemWatcher* m_watcher;
};
diff --git a/launcher/ui/pages/instance/ResourcePackPage.cpp b/launcher/ui/pages/instance/ResourcePackPage.cpp
index 24bfb38d..12b371df 100644
--- a/launcher/ui/pages/instance/ResourcePackPage.cpp
+++ b/launcher/ui/pages/instance/ResourcePackPage.cpp
@@ -67,8 +67,6 @@ bool ResourcePackPage::onSelectionChanged(const QModelIndex& current, const QMod
void ResourcePackPage::downloadRPs()
{
- if (!m_controlsEnabled)
- return;
if (m_instance->typeName() != "Minecraft")
return; // this is a null instance or a legacy instance
diff --git a/launcher/ui/pages/instance/ResourcePackPage.h b/launcher/ui/pages/instance/ResourcePackPage.h
index b04aa2e9..cb84ca96 100644
--- a/launcher/ui/pages/instance/ResourcePackPage.h
+++ b/launcher/ui/pages/instance/ResourcePackPage.h
@@ -42,11 +42,10 @@
#include "minecraft/mod/ResourcePackFolderModel.h"
-class ResourcePackPage : public ExternalResourcesPage
-{
+class ResourcePackPage : public ExternalResourcesPage {
Q_OBJECT
-public:
- explicit ResourcePackPage(MinecraftInstance *instance, std::shared_ptr<ResourcePackFolderModel> model, QWidget *parent = 0);
+ public:
+ explicit ResourcePackPage(MinecraftInstance* instance, std::shared_ptr<ResourcePackFolderModel> model, QWidget* parent = 0);
QString displayName() const override { return tr("Resource packs"); }
QIcon icon() const override { return APPLICATION->getThemedIcon("resourcepacks"); }
@@ -55,12 +54,10 @@ public:
virtual bool shouldDisplay() const override
{
- return !m_instance->traits().contains("no-texturepacks") &&
- !m_instance->traits().contains("texturepacks");
+ return !m_instance->traits().contains("no-texturepacks") && !m_instance->traits().contains("texturepacks");
}
public slots:
bool onSelectionChanged(const QModelIndex& current, const QModelIndex& previous) override;
void downloadRPs();
};
-
diff --git a/launcher/ui/pages/instance/ScreenshotsPage.cpp b/launcher/ui/pages/instance/ScreenshotsPage.cpp
index 35237594..29c835fc 100644
--- a/launcher/ui/pages/instance/ScreenshotsPage.cpp
+++ b/launcher/ui/pages/instance/ScreenshotsPage.cpp
@@ -39,52 +39,50 @@
#include "BuildConfig.h"
#include "ui_ScreenshotsPage.h"
-#include <QModelIndex>
-#include <QMutableListIterator>
-#include <QMap>
-#include <QSet>
+#include <QClipboard>
+#include <QEvent>
#include <QFileIconProvider>
#include <QFileSystemModel>
-#include <QStyledItemDelegate>
-#include <QLineEdit>
-#include <QEvent>
-#include <QPainter>
-#include <QClipboard>
#include <QKeyEvent>
+#include <QLineEdit>
+#include <QMap>
#include <QMenu>
+#include <QModelIndex>
+#include <QMutableListIterator>
+#include <QPainter>
#include <QRegularExpression>
+#include <QSet>
+#include <QStyledItemDelegate>
#include <Application.h>
-#include "ui/dialogs/ProgressDialog.h"
#include "ui/dialogs/CustomMessageBox.h"
+#include "ui/dialogs/ProgressDialog.h"
#include "net/NetJob.h"
-#include "screenshots/ImgurUpload.h"
#include "screenshots/ImgurAlbumCreation.h"
+#include "screenshots/ImgurUpload.h"
#include "tasks/SequentialTask.h"
-#include "RWStorage.h"
-#include <FileSystem.h>
#include <DesktopServices.h>
+#include <FileSystem.h>
+#include "RWStorage.h"
typedef RWStorage<QString, QIcon> SharedIconCache;
typedef std::shared_ptr<SharedIconCache> SharedIconCachePtr;
-class ThumbnailingResult : public QObject
-{
+class ThumbnailingResult : public QObject {
Q_OBJECT
-public slots:
- inline void emitResultsReady(const QString &path) { emit resultsReady(path); }
- inline void emitResultsFailed(const QString &path) { emit resultsFailed(path); }
-signals:
- void resultsReady(const QString &path);
- void resultsFailed(const QString &path);
+ public slots:
+ inline void emitResultsReady(const QString& path) { emit resultsReady(path); }
+ inline void emitResultsFailed(const QString& path) { emit resultsFailed(path); }
+ signals:
+ void resultsReady(const QString& path);
+ void resultsFailed(const QString& path);
};
-class ThumbnailRunnable : public QRunnable
-{
-public:
+class ThumbnailRunnable : public QRunnable {
+ public:
ThumbnailRunnable(QString path, SharedIconCachePtr cache)
{
m_path = path;
@@ -97,37 +95,30 @@ public:
return;
if ((info.suffix().compare("png", Qt::CaseInsensitive) != 0))
return;
- int tries = 5;
- while (tries)
- {
- if (!m_cache->stale(m_path))
- return;
- QImage image(m_path);
- if (image.isNull())
- {
- QThread::msleep(500);
- tries--;
- continue;
- }
- QImage small;
- if (image.width() > image.height())
- small = image.scaledToWidth(512).scaledToWidth(256, Qt::SmoothTransformation);
- else
- small = image.scaledToHeight(512).scaledToHeight(256, Qt::SmoothTransformation);
- QPoint offset((256 - small.width()) / 2, (256 - small.height()) / 2);
- QImage square(QSize(256, 256), QImage::Format_ARGB32);
- square.fill(Qt::transparent);
-
- QPainter painter(&square);
- painter.drawImage(offset, small);
- painter.end();
-
- QIcon icon(QPixmap::fromImage(square));
- m_cache->add(m_path, icon);
- m_resultEmitter.emitResultsReady(m_path);
+ if (!m_cache->stale(m_path))
+ return;
+ QImage image(m_path);
+ if (image.isNull()) {
+ m_resultEmitter.emitResultsFailed(m_path);
+ qDebug() << "Error loading screenshot: " + m_path + ". Perhaps too large?";
return;
}
- m_resultEmitter.emitResultsFailed(m_path);
+ QImage small;
+ if (image.width() > image.height())
+ small = image.scaledToWidth(512).scaledToWidth(256, Qt::SmoothTransformation);
+ else
+ small = image.scaledToHeight(512).scaledToHeight(256, Qt::SmoothTransformation);
+ QPoint offset((256 - small.width()) / 2, (256 - small.height()) / 2);
+ QImage square(QSize(256, 256), QImage::Format_ARGB32);
+ square.fill(Qt::transparent);
+
+ QPainter painter(&square);
+ painter.drawImage(offset, small);
+ painter.end();
+
+ QIcon icon(QPixmap::fromImage(square));
+ m_cache->add(m_path, icon);
+ m_resultEmitter.emitResultsReady(m_path);
}
QString m_path;
SharedIconCachePtr m_cache;
@@ -136,54 +127,50 @@ public:
// this is about as elegant and well written as a bag of bricks with scribbles done by insane
// asylum patients.
-class FilterModel : public QIdentityProxyModel
-{
+class FilterModel : public QIdentityProxyModel {
Q_OBJECT
-public:
- explicit FilterModel(QObject *parent = 0) : QIdentityProxyModel(parent)
+ public:
+ explicit FilterModel(QObject* parent = 0) : QIdentityProxyModel(parent)
{
m_thumbnailingPool.setMaxThreadCount(4);
m_thumbnailCache = std::make_shared<SharedIconCache>();
m_thumbnailCache->add("placeholder", APPLICATION->getThemedIcon("screenshot-placeholder"));
connect(&watcher, SIGNAL(fileChanged(QString)), SLOT(fileChanged(QString)));
- // FIXME: the watched file set is not updated when files are removed
}
- virtual ~FilterModel() { m_thumbnailingPool.waitForDone(500); }
- virtual QVariant data(const QModelIndex &proxyIndex, int role = Qt::DisplayRole) const
+ virtual ~FilterModel()
+ {
+ m_thumbnailingPool.clear();
+ if (!m_thumbnailingPool.waitForDone(500))
+ qDebug() << "Thumbnail pool took longer than 500ms to finish";
+ }
+ virtual QVariant data(const QModelIndex& proxyIndex, int role = Qt::DisplayRole) const
{
auto model = sourceModel();
if (!model)
return QVariant();
- if (role == Qt::DisplayRole || role == Qt::EditRole)
- {
+ if (role == Qt::DisplayRole || role == Qt::EditRole) {
QVariant result = sourceModel()->data(mapToSource(proxyIndex), role);
return result.toString().remove(QRegularExpression("\\.png$"));
}
- if (role == Qt::DecorationRole)
- {
- QVariant result =
- sourceModel()->data(mapToSource(proxyIndex), QFileSystemModel::FilePathRole);
+ if (role == Qt::DecorationRole) {
+ QVariant result = sourceModel()->data(mapToSource(proxyIndex), QFileSystemModel::FilePathRole);
QString filePath = result.toString();
QIcon temp;
- if (!watched.contains(filePath))
- {
- ((QFileSystemWatcher &)watcher).addPath(filePath);
- ((QSet<QString> &)watched).insert(filePath);
+ if (!watched.contains(filePath)) {
+ ((QFileSystemWatcher&)watcher).addPath(filePath);
+ ((QSet<QString>&)watched).insert(filePath);
}
- if (m_thumbnailCache->get(filePath, temp))
- {
+ if (m_thumbnailCache->get(filePath, temp)) {
return temp;
}
- if (!m_failed.contains(filePath))
- {
- ((FilterModel *)this)->thumbnailImage(filePath);
+ if (!m_failed.contains(filePath)) {
+ ((FilterModel*)this)->thumbnailImage(filePath);
}
return (m_thumbnailCache->get("placeholder"));
}
return sourceModel()->data(mapToSource(proxyIndex), role);
}
- virtual bool setData(const QModelIndex &index, const QVariant &value,
- int role = Qt::EditRole)
+ virtual bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole)
{
auto model = sourceModel();
if (!model)
@@ -193,35 +180,35 @@ public:
// FIXME: this is a workaround for a bug in QFileSystemModel, where it doesn't
// sort after renames
{
- ((QFileSystemModel *)model)->setNameFilterDisables(true);
- ((QFileSystemModel *)model)->setNameFilterDisables(false);
+ ((QFileSystemModel*)model)->setNameFilterDisables(true);
+ ((QFileSystemModel*)model)->setNameFilterDisables(false);
}
return model->setData(mapToSource(index), value.toString() + ".png", role);
}
-private:
+ private:
void thumbnailImage(QString path)
{
auto runnable = new ThumbnailRunnable(path, m_thumbnailCache);
- connect(&(runnable->m_resultEmitter), SIGNAL(resultsReady(QString)),
- SLOT(thumbnailReady(QString)));
- connect(&(runnable->m_resultEmitter), SIGNAL(resultsFailed(QString)),
- SLOT(thumbnailFailed(QString)));
- ((QThreadPool &)m_thumbnailingPool).start(runnable);
+ connect(&(runnable->m_resultEmitter), SIGNAL(resultsReady(QString)), SLOT(thumbnailReady(QString)));
+ connect(&(runnable->m_resultEmitter), SIGNAL(resultsFailed(QString)), SLOT(thumbnailFailed(QString)));
+ ((QThreadPool&)m_thumbnailingPool).start(runnable);
}
-private slots:
+ private slots:
void thumbnailReady(QString path) { emit layoutChanged(); }
void thumbnailFailed(QString path) { m_failed.insert(path); }
void fileChanged(QString filepath)
{
m_thumbnailCache->setStale(filepath);
- thumbnailImage(filepath);
// reinsert the path...
watcher.removePath(filepath);
- watcher.addPath(filepath);
+ if (QFile::exists(filepath)) {
+ watcher.addPath(filepath);
+ thumbnailImage(filepath);
+ }
}
-private:
+ private:
SharedIconCachePtr m_thumbnailCache;
QThreadPool m_thumbnailingPool;
QSet<QString> m_failed;
@@ -229,18 +216,15 @@ private:
QFileSystemWatcher watcher;
};
-class CenteredEditingDelegate : public QStyledItemDelegate
-{
-public:
- explicit CenteredEditingDelegate(QObject *parent = 0) : QStyledItemDelegate(parent) {}
+class CenteredEditingDelegate : public QStyledItemDelegate {
+ public:
+ explicit CenteredEditingDelegate(QObject* parent = 0) : QStyledItemDelegate(parent) {}
virtual ~CenteredEditingDelegate() {}
- virtual QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
- const QModelIndex &index) const
+ virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const
{
auto widget = QStyledItemDelegate::createEditor(parent, option, index);
- auto foo = dynamic_cast<QLineEdit *>(widget);
- if (foo)
- {
+ auto foo = dynamic_cast<QLineEdit*>(widget);
+ if (foo) {
foo->setAlignment(Qt::AlignHCenter);
foo->setFrame(true);
foo->setMaximumWidth(192);
@@ -249,15 +233,14 @@ public:
}
};
-ScreenshotsPage::ScreenshotsPage(QString path, QWidget *parent)
- : QMainWindow(parent), ui(new Ui::ScreenshotsPage)
+ScreenshotsPage::ScreenshotsPage(QString path, QWidget* parent) : QMainWindow(parent), ui(new Ui::ScreenshotsPage)
{
m_model.reset(new QFileSystemModel());
m_filterModel.reset(new FilterModel());
m_filterModel->setSourceModel(m_model.get());
m_model->setFilter(QDir::Files);
m_model->setReadOnly(false);
- m_model->setNameFilters({"*.png"});
+ m_model->setNameFilters({ "*.png" });
m_model->setNameFilterDisables(false);
m_folder = path;
m_valid = FS::ensureFolderPathExists(m_folder);
@@ -280,31 +263,29 @@ ScreenshotsPage::ScreenshotsPage(QString path, QWidget *parent)
connect(ui->listView, SIGNAL(activated(QModelIndex)), SLOT(onItemActivated(QModelIndex)));
}
-bool ScreenshotsPage::eventFilter(QObject *obj, QEvent *evt)
+bool ScreenshotsPage::eventFilter(QObject* obj, QEvent* evt)
{
if (obj != ui->listView)
return QWidget::eventFilter(obj, evt);
- if (evt->type() != QEvent::KeyPress)
- {
+ if (evt->type() != QEvent::KeyPress) {
return QWidget::eventFilter(obj, evt);
}
- QKeyEvent *keyEvent = static_cast<QKeyEvent *>(evt);
+ QKeyEvent* keyEvent = static_cast<QKeyEvent*>(evt);
if (keyEvent->matches(QKeySequence::Copy)) {
on_actionCopy_File_s_triggered();
return true;
}
- switch (keyEvent->key())
- {
- case Qt::Key_Delete:
- on_actionDelete_triggered();
- return true;
- case Qt::Key_F2:
- on_actionRename_triggered();
- return true;
- default:
- break;
+ switch (keyEvent->key()) {
+ case Qt::Key_Delete:
+ on_actionDelete_triggered();
+ return true;
+ case Qt::Key_F2:
+ on_actionRename_triggered();
+ return true;
+ default:
+ break;
}
return QWidget::eventFilter(obj, evt);
}
@@ -324,17 +305,17 @@ void ScreenshotsPage::ShowContextMenu(const QPoint& pos)
auto menu = ui->toolBar->createContextMenu(this, tr("Context menu"));
if (ui->listView->selectionModel()->selectedRows().size() > 1) {
- menu->removeAction( ui->actionCopy_Image );
+ menu->removeAction(ui->actionCopy_Image);
}
menu->exec(ui->listView->mapToGlobal(pos));
delete menu;
}
-QMenu * ScreenshotsPage::createPopupMenu()
+QMenu* ScreenshotsPage::createPopupMenu()
{
QMenu* filteredMenu = QMainWindow::createPopupMenu();
- filteredMenu->removeAction( ui->toolBar->toggleViewAction() );
+ filteredMenu->removeAction(ui->toolBar->toggleViewAction());
return filteredMenu;
}
@@ -347,13 +328,12 @@ void ScreenshotsPage::onItemActivated(QModelIndex index)
DesktopServices::openFile(info.absoluteFilePath());
}
-void ScreenshotsPage::onCurrentSelectionChanged(const QItemSelection &selected)
+void ScreenshotsPage::onCurrentSelectionChanged(const QItemSelection& selected)
{
bool allReadable = !selected.isEmpty();
bool allWritable = !selected.isEmpty();
- for (auto index : selected.indexes())
- {
+ for (auto index : selected.indexes()) {
if (!index.isValid())
break;
auto info = m_model->fileInfo(index);
@@ -403,8 +383,7 @@ void ScreenshotsPage::on_actionUpload_triggered()
QList<ScreenShot::Ptr> uploaded;
auto job = NetJob::Ptr(new NetJob("Screenshot Upload", APPLICATION->network()));
- if(selection.size() < 2)
- {
+ if (selection.size() < 2) {
auto item = selection.at(0);
auto info = m_model->fileInfo(item);
auto screenshot = std::make_shared<ScreenShot>(info);
@@ -413,31 +392,24 @@ void ScreenshotsPage::on_actionUpload_triggered()
m_uploadActive = true;
ProgressDialog dialog(this);
- if(dialog.execWithTask(job.get()) != QDialog::Accepted)
- {
- CustomMessageBox::selectable(this, tr("Failed to upload screenshots!"),
- tr("Unknown error"), QMessageBox::Warning)->exec();
- }
- else
- {
+ if (dialog.execWithTask(job.get()) != QDialog::Accepted) {
+ CustomMessageBox::selectable(this, tr("Failed to upload screenshots!"), tr("Unknown error"), QMessageBox::Warning)->exec();
+ } else {
auto link = screenshot->m_url;
- QClipboard *clipboard = QApplication::clipboard();
+ QClipboard* clipboard = QApplication::clipboard();
clipboard->setText(link);
CustomMessageBox::selectable(
- this,
- tr("Upload finished"),
- tr("The <a href=\"%1\">link to the uploaded screenshot</a> has been placed in your clipboard.")
- .arg(link),
- QMessageBox::Information
- )->exec();
+ this, tr("Upload finished"),
+ tr("The <a href=\"%1\">link to the uploaded screenshot</a> has been placed in your clipboard.").arg(link),
+ QMessageBox::Information)
+ ->exec();
}
m_uploadActive = false;
return;
}
- for (auto item : selection)
- {
+ for (auto item : selection) {
auto info = m_model->fileInfo(item);
auto screenshot = std::make_shared<ScreenShot>(info);
uploaded.push_back(screenshot);
@@ -451,26 +423,16 @@ void ScreenshotsPage::on_actionUpload_triggered()
task.addTask(albumTask);
m_uploadActive = true;
ProgressDialog prog(this);
- if (prog.execWithTask(&task) != QDialog::Accepted)
- {
- CustomMessageBox::selectable(
- this,
- tr("Failed to upload screenshots!"),
- tr("Unknown error"),
- QMessageBox::Warning
- )->exec();
- }
- else
- {
+ if (prog.execWithTask(&task) != QDialog::Accepted) {
+ CustomMessageBox::selectable(this, tr("Failed to upload screenshots!"), tr("Unknown error"), QMessageBox::Warning)->exec();
+ } else {
auto link = QString("https://imgur.com/a/%1").arg(imgurAlbum->id());
- QClipboard *clipboard = QApplication::clipboard();
+ QClipboard* clipboard = QApplication::clipboard();
clipboard->setText(link);
- CustomMessageBox::selectable(
- this,
- tr("Upload finished"),
- tr("The <a href=\"%1\">link to the uploaded album</a> has been placed in your clipboard.") .arg(link),
- QMessageBox::Information
- )->exec();
+ CustomMessageBox::selectable(this, tr("Upload finished"),
+ tr("The <a href=\"%1\">link to the uploaded album</a> has been placed in your clipboard.").arg(link),
+ QMessageBox::Information)
+ ->exec();
}
m_uploadActive = false;
}
@@ -478,8 +440,7 @@ void ScreenshotsPage::on_actionUpload_triggered()
void ScreenshotsPage::on_actionCopy_Image_triggered()
{
auto selection = ui->listView->selectionModel()->selectedRows();
- if(selection.size() < 1)
- {
+ if (selection.size() < 1) {
return;
}
@@ -494,15 +455,13 @@ void ScreenshotsPage::on_actionCopy_Image_triggered()
void ScreenshotsPage::on_actionCopy_File_s_triggered()
{
auto selection = ui->listView->selectionModel()->selectedRows();
- if(selection.size() < 1)
- {
+ if (selection.size() < 1) {
// Don't do anything so we don't empty the users clipboard
return;
}
QString buf = "";
- for (auto item : selection)
- {
+ for (auto item : selection) {
auto info = m_model->fileInfo(item);
buf += "file:///" + info.absoluteFilePath() + "\r\n";
}
@@ -534,8 +493,7 @@ void ScreenshotsPage::on_actionDelete_triggered()
if (response != QMessageBox::Yes)
return;
- for (auto item : selected)
- {
+ for (auto item : selected) {
if (FS::trash(m_model->filePath(item)))
continue;
@@ -554,23 +512,19 @@ void ScreenshotsPage::on_actionRename_triggered()
void ScreenshotsPage::openedImpl()
{
- if(!m_valid)
- {
+ if (!m_valid) {
m_valid = FS::ensureFolderPathExists(m_folder);
}
- if (m_valid)
- {
+ if (m_valid) {
QString path = QDir(m_folder).absolutePath();
auto idx = m_model->setRootPath(path);
- if(idx.isValid())
- {
+ if (idx.isValid()) {
ui->listView->setModel(m_filterModel.get());
- connect(ui->listView->selectionModel(), &QItemSelectionModel::selectionChanged, this, &ScreenshotsPage::onCurrentSelectionChanged);
- onCurrentSelectionChanged(ui->listView->selectionModel()->selection()); // set initial button enable states
+ connect(ui->listView->selectionModel(), &QItemSelectionModel::selectionChanged, this,
+ &ScreenshotsPage::onCurrentSelectionChanged);
+ onCurrentSelectionChanged(ui->listView->selectionModel()->selection()); // set initial button enable states
ui->listView->setRootIndex(m_filterModel->mapFromSource(idx));
- }
- else
- {
+ } else {
ui->listView->setModel(nullptr);
}
}
diff --git a/launcher/ui/pages/instance/ScreenshotsPage.h b/launcher/ui/pages/instance/ScreenshotsPage.h
index 89611b6d..bb127b42 100644
--- a/launcher/ui/pages/instance/ScreenshotsPage.h
+++ b/launcher/ui/pages/instance/ScreenshotsPage.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
@@ -37,16 +37,15 @@
#include <QMainWindow>
-#include "ui/pages/BasePage.h"
#include <Application.h>
+#include "ui/pages/BasePage.h"
#include "settings/Setting.h"
class QFileSystemModel;
class QIdentityProxyModel;
class QItemSelection;
-namespace Ui
-{
+namespace Ui {
class ScreenshotsPage;
}
@@ -54,49 +53,30 @@ struct ScreenShot;
class ScreenshotList;
class ImgurAlbumCreation;
-class ScreenshotsPage : public QMainWindow, public BasePage
-{
+class ScreenshotsPage : public QMainWindow, public BasePage {
Q_OBJECT
-public:
- explicit ScreenshotsPage(QString path, QWidget *parent = 0);
+ public:
+ explicit ScreenshotsPage(QString path, QWidget* parent = 0);
virtual ~ScreenshotsPage();
void openedImpl() override;
void closedImpl() override;
- enum
- {
- NothingDone = 0x42
- };
+ enum { NothingDone = 0x42 };
- virtual bool eventFilter(QObject *, QEvent *) override;
- virtual QString displayName() const override
- {
- return tr("Screenshots");
- }
- virtual QIcon icon() const override
- {
- return APPLICATION->getThemedIcon("screenshots");
- }
- virtual QString id() const override
- {
- return "screenshots";
- }
- virtual QString helpPage() const override
- {
- return "Screenshots-management";
- }
- virtual bool apply() override
- {
- return !m_uploadActive;
- }
+ virtual bool eventFilter(QObject*, QEvent*) override;
+ virtual QString displayName() const override { return tr("Screenshots"); }
+ virtual QIcon icon() const override { return APPLICATION->getThemedIcon("screenshots"); }
+ virtual QString id() const override { return "screenshots"; }
+ virtual QString helpPage() const override { return "Screenshots-management"; }
+ virtual bool apply() override { return !m_uploadActive; }
void retranslate() override;
-protected:
- QMenu * createPopupMenu() override;
+ protected:
+ QMenu* createPopupMenu() override;
-private slots:
+ private slots:
void on_actionUpload_triggered();
void on_actionCopy_Image_triggered();
void on_actionCopy_File_s_triggered();
@@ -104,11 +84,11 @@ private slots:
void on_actionRename_triggered();
void on_actionView_Folder_triggered();
void onItemActivated(QModelIndex);
- void onCurrentSelectionChanged(const QItemSelection &selected);
- void ShowContextMenu(const QPoint &pos);
+ void onCurrentSelectionChanged(const QItemSelection& selected);
+ void ShowContextMenu(const QPoint& pos);
-private:
- Ui::ScreenshotsPage *ui;
+ private:
+ Ui::ScreenshotsPage* ui;
std::shared_ptr<QFileSystemModel> m_model;
std::shared_ptr<QIdentityProxyModel> m_filterModel;
QString m_folder;
diff --git a/launcher/ui/pages/instance/ServersPage.cpp b/launcher/ui/pages/instance/ServersPage.cpp
index 4b1fa08a..07daca21 100644
--- a/launcher/ui/pages/instance/ServersPage.cpp
+++ b/launcher/ui/pages/instance/ServersPage.cpp
@@ -40,36 +40,27 @@
#include "ui_ServersPage.h"
#include <FileSystem.h>
-#include <sstream>
#include <io/stream_reader.h>
-#include <tag_string.h>
-#include <tag_primitive.h>
-#include <tag_list.h>
-#include <tag_compound.h>
#include <minecraft/MinecraftInstance.h>
+#include <tag_compound.h>
+#include <tag_list.h>
+#include <tag_primitive.h>
+#include <tag_string.h>
+#include <sstream>
#include <QFileSystemWatcher>
#include <QMenu>
#include <QTimer>
-static const int COLUMN_COUNT = 2; // 3 , TBD: latency and other nice things.
+static const int COLUMN_COUNT = 2; // 3 , TBD: latency and other nice things.
-struct Server
-{
+struct Server {
// Types
- enum class AcceptsTextures : int
- {
- ASK = 0,
- ALWAYS = 1,
- NEVER = 2
- };
+ enum class AcceptsTextures : int { ASK = 0, ALWAYS = 1, NEVER = 2 };
// Methods
- Server()
- {
- m_name = QObject::tr("Minecraft Server");
- }
- Server(const QString & name, const QString & address)
+ Server() { m_name = QObject::tr("Minecraft Server"); }
+ Server(const QString& name, const QString& address)
{
m_name = name;
m_address = address;
@@ -82,21 +73,16 @@ struct Server
std::string nameStr(server["name"]);
m_name = QString::fromUtf8(nameStr.c_str());
- if(server["icon"])
- {
+ if (server["icon"]) {
std::string base64str(server["icon"]);
m_icon = QByteArray::fromBase64(base64str.c_str());
}
- if(server.has_key("acceptTextures", nbt::tag_type::Byte))
- {
+ if (server.has_key("acceptTextures", nbt::tag_type::Byte)) {
bool value = server["acceptTextures"].as<nbt::tag_byte>().get();
- if(value)
- {
+ if (value) {
m_acceptsTextures = AcceptsTextures::ALWAYS;
- }
- else
- {
+ } else {
m_acceptsTextures = AcceptsTextures::NEVER;
}
}
@@ -106,12 +92,10 @@ struct Server
{
server.insert("name", m_name.trimmed().toUtf8().toStdString());
server.insert("ip", m_address.trimmed().toUtf8().toStdString());
- if(m_icon.size())
- {
+ if (m_icon.size()) {
server.insert("icon", m_icon.toBase64().toStdString());
}
- if(m_acceptsTextures != AcceptsTextures::ASK)
- {
+ if (m_acceptsTextures != AcceptsTextures::ASK) {
server.insert("acceptTextures", nbt::tag_byte(m_acceptsTextures == AcceptsTextures::ALWAYS));
}
}
@@ -127,64 +111,54 @@ struct Server
// Data - temporary
bool m_checked = false;
bool m_up = false;
- QString m_motd; // https://mctools.org/motd-creator
+ QString m_motd; // https://mctools.org/motd-creator
int m_ping = 0;
int m_currentPlayers = 0;
int m_maxPlayers = 0;
};
-static std::unique_ptr <nbt::tag_compound> parseServersDat(const QString& filename)
+static std::unique_ptr<nbt::tag_compound> parseServersDat(const QString& filename)
{
- try
- {
+ try {
QByteArray input = FS::read(filename);
std::istringstream foo(std::string(input.constData(), input.size()));
auto pair = nbt::io::read_compound(foo);
- if(pair.first != "")
+ if (pair.first != "")
return nullptr;
- if(pair.second == nullptr)
+ if (pair.second == nullptr)
return nullptr;
return std::move(pair.second);
- }
- catch (...)
- {
+ } catch (...) {
return nullptr;
}
}
-static bool serializeServerDat(const QString& filename, nbt::tag_compound * levelInfo)
+static bool serializeServerDat(const QString& filename, nbt::tag_compound* levelInfo)
{
- try
- {
- if(!FS::ensureFilePathExists(filename))
- {
+ try {
+ if (!FS::ensureFilePathExists(filename)) {
return false;
}
std::ostringstream s;
nbt::io::write_tag("", *levelInfo, s);
- QByteArray val(s.str().data(), (int) s.str().size() );
+ QByteArray val(s.str().data(), (int)s.str().size());
FS::write(filename, val);
return true;
- }
- catch (...)
- {
+ } catch (...) {
return false;
}
}
-class ServersModel: public QAbstractListModel
-{
+class ServersModel : public QAbstractListModel {
Q_OBJECT
-public:
- enum Roles
- {
+ public:
+ enum Roles {
ServerPtrRole = Qt::UserRole,
};
- explicit ServersModel(const QString &path, QObject *parent = 0)
- : QAbstractListModel(parent)
+ explicit ServersModel(const QString& path, QObject* parent = 0) : QAbstractListModel(parent)
{
m_path = path;
m_watcher = new QFileSystemWatcher(this);
@@ -194,18 +168,16 @@ public:
m_saveTimer.setInterval(5000);
connect(&m_saveTimer, &QTimer::timeout, this, &ServersModel::save_internal);
}
- virtual ~ServersModel() {};
+ virtual ~ServersModel(){};
void observe()
{
- if(m_observed)
- {
+ if (m_observed) {
return;
}
m_observed = true;
- if(!m_loaded)
- {
+ if (!m_loaded) {
load();
}
@@ -214,8 +186,7 @@ public:
void unobserve()
{
- if(!m_observed)
- {
+ if (!m_observed) {
return;
}
m_observed = false;
@@ -225,8 +196,7 @@ public:
void lock()
{
- if(m_locked)
- {
+ if (m_locked) {
return;
}
saveNow();
@@ -237,8 +207,7 @@ public:
void unlock()
{
- if(!m_locked)
- {
+ if (!m_locked) {
return;
}
m_locked = false;
@@ -248,12 +217,10 @@ public:
int addEmptyRow(int position)
{
- if(m_locked)
- {
+ if (m_locked) {
return -1;
}
- if(position < 0 || position >= rowCount())
- {
+ if (position < 0 || position >= rowCount()) {
position = rowCount();
}
beginInsertRows(QModelIndex(), position, position);
@@ -265,36 +232,32 @@ public:
bool removeRow(int row)
{
- if(m_locked)
- {
+ if (m_locked) {
return false;
}
- if(row < 0 || row >= rowCount())
- {
+ if (row < 0 || row >= rowCount()) {
return false;
}
beginRemoveRows(QModelIndex(), row, row);
m_servers.removeAt(row);
- endRemoveRows(); // does absolutely nothing, the selected server stays as the next line...
+ endRemoveRows(); // does absolutely nothing, the selected server stays as the next line...
scheduleSave();
return true;
}
bool moveUp(int row)
{
- if(m_locked)
- {
+ if (m_locked) {
return false;
}
- if(row <= 0)
- {
+ if (row <= 0) {
return false;
}
beginMoveRows(QModelIndex(), row, row, QModelIndex(), row - 1);
#if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0)
- m_servers.swapItemsAt(row-1, row);
+ m_servers.swapItemsAt(row - 1, row);
#else
- m_servers.swap(row-1, row);
+ m_servers.swap(row - 1, row);
#endif
endMoveRows();
scheduleSave();
@@ -303,20 +266,18 @@ public:
bool moveDown(int row)
{
- if(m_locked)
- {
+ if (m_locked) {
return false;
}
int count = rowCount();
- if(row + 1 >= count)
- {
+ if (row + 1 >= count) {
return false;
}
beginMoveRows(QModelIndex(), row, row, QModelIndex(), row + 2);
#if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0)
- m_servers.swapItemsAt(row+1, row);
+ m_servers.swapItemsAt(row + 1, row);
#else
- m_servers.swap(row+1, row);
+ m_servers.swap(row + 1, row);
#endif
endMoveRows();
scheduleSave();
@@ -328,10 +289,8 @@ public:
if (section < 0 || section >= COLUMN_COUNT)
return QVariant();
- if(role == Qt::DisplayRole)
- {
- switch(section)
- {
+ if (role == Qt::DisplayRole) {
+ switch (section) {
case 0:
return tr("Name");
case 1:
@@ -344,90 +303,81 @@ public:
return QAbstractListModel::headerData(section, orientation, role);
}
- virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override
+ virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override
{
if (!index.isValid())
return QVariant();
int row = index.row();
int column = index.column();
- if(column < 0 || column >= COLUMN_COUNT)
+ if (column < 0 || column >= COLUMN_COUNT)
return QVariant();
if (row < 0 || row >= m_servers.size())
return QVariant();
- switch(column)
- {
+ switch (column) {
case 0:
- switch (role)
- {
- case Qt::DecorationRole:
- {
- auto & bytes = m_servers[row].m_icon;
- if(bytes.size())
- {
- QPixmap px;
- if(px.loadFromData(bytes))
- return QIcon(px);
+ switch (role) {
+ case Qt::DecorationRole: {
+ auto& bytes = m_servers[row].m_icon;
+ if (bytes.size()) {
+ QPixmap px;
+ if (px.loadFromData(bytes))
+ return QIcon(px);
+ }
+ return APPLICATION->getThemedIcon("unknown_server");
}
- return APPLICATION->getThemedIcon("unknown_server");
- }
- case Qt::DisplayRole:
- return m_servers[row].m_name;
- case ServerPtrRole:
- return QVariant::fromValue<void *>((void *)&m_servers[row]);
- default:
- return QVariant();
+ case Qt::DisplayRole:
+ return m_servers[row].m_name;
+ case ServerPtrRole:
+ return QVariant::fromValue<void*>((void*)&m_servers[row]);
+ default:
+ return QVariant();
}
case 1:
- switch (role)
- {
- case Qt::DisplayRole:
- return m_servers[row].m_address;
- default:
- return QVariant();
+ switch (role) {
+ case Qt::DisplayRole:
+ return m_servers[row].m_address;
+ default:
+ return QVariant();
}
case 2:
- switch (role)
- {
- case Qt::DisplayRole:
- return m_servers[row].m_ping;
- default:
- return QVariant();
+ switch (role) {
+ case Qt::DisplayRole:
+ return m_servers[row].m_ping;
+ default:
+ return QVariant();
}
default:
return QVariant();
}
}
- virtual int rowCount(const QModelIndex &parent = QModelIndex()) const override
+ virtual int rowCount(const QModelIndex& parent = QModelIndex()) const override
{
return parent.isValid() ? 0 : m_servers.size();
}
- int columnCount(const QModelIndex & parent) const override
+ int columnCount(const QModelIndex& parent) const override
{
return parent.isValid() ? 0 : COLUMN_COUNT;
}
- Server * at(int index)
+ Server* at(int index)
{
- if(index < 0 || index >= rowCount())
- {
+ if (index < 0 || index >= rowCount()) {
return nullptr;
}
return &m_servers[index];
}
- void setName(int row, const QString & name)
+ void setName(int row, const QString& name)
{
- if(m_locked)
- {
+ if (m_locked) {
return;
}
auto server = at(row);
- if(!server || server->m_name == name)
- {
+ if (!server || server->m_name == name) {
return;
}
server->m_name = name;
@@ -435,15 +385,13 @@ public:
scheduleSave();
}
- void setAddress(int row, const QString & address)
+ void setAddress(int row, const QString& address)
{
- if(m_locked)
- {
+ if (m_locked) {
return;
}
auto server = at(row);
- if(!server || server->m_address == address)
- {
+ if (!server || server->m_address == address) {
return;
}
server->m_address = address;
@@ -453,13 +401,11 @@ public:
void setAcceptsTextures(int row, Server::AcceptsTextures textures)
{
- if(m_locked)
- {
+ if (m_locked) {
return;
}
auto server = at(row);
- if(!server || server->m_acceptsTextures == textures)
- {
+ if (!server || server->m_acceptsTextures == textures) {
return;
}
server->m_acceptsTextures = textures;
@@ -473,12 +419,10 @@ public:
beginResetModel();
QList<Server> servers;
auto serversDat = parseServersDat(serversPath());
- if(serversDat)
- {
- auto &serversList = serversDat->at("servers").as<nbt::tag_list>();
- for(auto iter = serversList.begin(); iter != serversList.end(); iter++)
- {
- auto & serverTag = (*iter).as<nbt::tag_compound>();
+ if (serversDat) {
+ auto& serversList = serversDat->at("servers").as<nbt::tag_list>();
+ for (auto iter = serversList.begin(); iter != serversList.end(); iter++) {
+ auto& serverTag = (*iter).as<nbt::tag_compound>();
Server s(serverTag);
servers.append(s);
}
@@ -490,14 +434,12 @@ public:
void saveNow()
{
- if(saveIsScheduled())
- {
+ if (saveIsScheduled()) {
save_internal();
}
}
-
-public slots:
+ public slots:
void dirChanged(const QString& path)
{
qDebug() << "Changed:" << path;
@@ -508,7 +450,7 @@ public slots:
qDebug() << "Changed:" << path;
}
-private slots:
+ private slots:
void save_internal()
{
cancelSave();
@@ -517,31 +459,27 @@ private slots:
nbt::tag_compound out;
nbt::tag_list list;
- for(auto & server: m_servers)
- {
+ for (auto& server : m_servers) {
nbt::tag_compound serverNbt;
server.serialize(serverNbt);
list.push_back(std::move(serverNbt));
}
out.insert("servers", nbt::value(std::move(list)));
- if(!serializeServerDat(path, &out))
- {
+ if (!serializeServerDat(path, &out)) {
qDebug() << "Failed to save server list:" << path << "Will try again.";
scheduleSave();
}
}
-private:
+ private:
void scheduleSave()
{
- if(!m_loaded)
- {
+ if (!m_loaded) {
qDebug() << "Server list should never save if it didn't successfully load, path:" << m_path;
return;
}
- if(!m_dirty)
- {
+ if (!m_dirty) {
m_dirty = true;
qDebug() << "Server list save is scheduled for" << m_path;
}
@@ -562,24 +500,17 @@ private:
void updateFSObserver()
{
bool observingFS = m_watcher->directories().contains(m_path);
- if(m_observed && m_locked)
- {
- if(!observingFS)
- {
+ if (m_observed && m_locked) {
+ if (!observingFS) {
qWarning() << "Will watch" << m_path;
- if(!m_watcher->addPath(m_path))
- {
+ if (!m_watcher->addPath(m_path)) {
qWarning() << "Failed to start watching" << m_path;
}
}
- }
- else
- {
- if(observingFS)
- {
+ } else {
+ if (observingFS) {
qWarning() << "Will stop watching" << m_path;
- if(!m_watcher->removePath(m_path))
- {
+ if (!m_watcher->removePath(m_path)) {
qWarning() << "Failed to stop watching" << m_path;
}
}
@@ -592,34 +523,31 @@ private:
return foo.filePath();
}
-private:
+ private:
bool m_loaded = false;
bool m_locked = false;
bool m_observed = false;
bool m_dirty = false;
QString m_path;
QList<Server> m_servers;
- QFileSystemWatcher *m_watcher = nullptr;
+ QFileSystemWatcher* m_watcher = nullptr;
QTimer m_saveTimer;
};
-ServersPage::ServersPage(InstancePtr inst, QWidget* parent)
- : QMainWindow(parent), ui(new Ui::ServersPage)
+ServersPage::ServersPage(InstancePtr inst, QWidget* parent) : QMainWindow(parent), ui(new Ui::ServersPage)
{
ui->setupUi(this);
m_inst = inst;
m_model = new ServersModel(inst->gameRoot(), this);
- ui->serversView->setIconSize(QSize(64,64));
+ ui->serversView->setIconSize(QSize(64, 64));
ui->serversView->setModel(m_model);
ui->serversView->setContextMenuPolicy(Qt::CustomContextMenu);
connect(ui->serversView, &QTreeView::customContextMenuRequested, this, &ServersPage::ShowContextMenu);
auto head = ui->serversView->header();
- if(head->count())
- {
+ if (head->count()) {
head->setSectionResizeMode(0, QHeaderView::Stretch);
- for(int i = 1; i < head->count(); i++)
- {
+ for (int i = 1; i < head->count(); i++) {
head->setSectionResizeMode(i, QHeaderView::ResizeToContents);
}
}
@@ -633,8 +561,7 @@ ServersPage::ServersPage(InstancePtr inst, QWidget* parent)
connect(m_model, &QAbstractItemModel::rowsRemoved, this, &ServersPage::rowsRemoved);
m_locked = m_inst->isRunning();
- if(m_locked)
- {
+ if (m_locked) {
m_model->lock();
}
@@ -659,40 +586,33 @@ void ServersPage::ShowContextMenu(const QPoint& pos)
delete menu;
}
-QMenu * ServersPage::createPopupMenu()
+QMenu* ServersPage::createPopupMenu()
{
QMenu* filteredMenu = QMainWindow::createPopupMenu();
- filteredMenu->removeAction( ui->toolBar->toggleViewAction() );
+ filteredMenu->removeAction(ui->toolBar->toggleViewAction());
return filteredMenu;
}
void ServersPage::runningStateChanged(bool running)
{
- if(m_locked == running)
- {
+ if (m_locked == running) {
return;
}
m_locked = running;
- if(m_locked)
- {
+ if (m_locked) {
m_model->lock();
- }
- else
- {
+ } else {
m_model->unlock();
}
updateState();
}
-void ServersPage::currentChanged(const QModelIndex &current, const QModelIndex &previous)
+void ServersPage::currentChanged(const QModelIndex& current, const QModelIndex& previous)
{
int nextServer = -1;
- if (!current.isValid())
- {
+ if (!current.isValid()) {
nextServer = -1;
- }
- else
- {
+ } else {
nextServer = current.row();
}
currentServer = nextServer;
@@ -702,18 +622,13 @@ void ServersPage::currentChanged(const QModelIndex &current, const QModelIndex &
// WARNING: this is here because currentChanged is not accurate when removing rows. the current item needs to be fixed up after removal.
void ServersPage::rowsRemoved(const QModelIndex& parent, int first, int last)
{
- if(currentServer < first)
- {
+ if (currentServer < first) {
// current was before the removal
return;
- }
- else if(currentServer >= first && currentServer <= last)
- {
+ } else if (currentServer >= first && currentServer <= last) {
// current got removed...
return;
- }
- else
- {
+ } else {
// current was past the removal
int count = last - first + 1;
currentServer -= count;
@@ -749,14 +664,11 @@ void ServersPage::updateState()
ui->actionRemove->setEnabled(serverEditEnabled);
ui->actionJoin->setEnabled(serverEditEnabled);
- if(server)
- {
+ if (server) {
ui->addressLine->setText(server->m_address);
ui->nameLine->setText(server->m_name);
ui->resourceComboBox->setCurrentIndex(int(server->m_acceptsTextures));
- }
- else
- {
+ } else {
ui->addressLine->setText(QString());
ui->nameLine->setText(QString());
ui->resourceComboBox->setCurrentIndex(0);
@@ -788,27 +700,25 @@ void ServersPage::closedImpl()
void ServersPage::on_actionAdd_triggered()
{
int position = m_model->addEmptyRow(currentServer + 1);
- if(position < 0)
- {
+ if (position < 0) {
return;
}
// select the new row
ui->serversView->selectionModel()->setCurrentIndex(
- m_model->index(position),
- QItemSelectionModel::SelectCurrent | QItemSelectionModel::Clear | QItemSelectionModel::Rows
- );
+ m_model->index(position), QItemSelectionModel::SelectCurrent | QItemSelectionModel::Clear | QItemSelectionModel::Rows);
currentServer = position;
}
void ServersPage::on_actionRemove_triggered()
{
- auto response = CustomMessageBox::selectable(this, tr("Confirm Removal"),
- tr("You are about to remove \"%1\".\n"
- "This is permanent and the server will be gone from your list forever (A LONG TIME).\n\n"
- "Are you sure?")
- .arg(m_model->at(currentServer)->m_name),
- QMessageBox::Warning, QMessageBox::Yes | QMessageBox::No, QMessageBox::No)
- ->exec();
+ auto response =
+ CustomMessageBox::selectable(this, tr("Confirm Removal"),
+ tr("You are about to remove \"%1\".\n"
+ "This is permanent and the server will be gone from your list forever (A LONG TIME).\n\n"
+ "Are you sure?")
+ .arg(m_model->at(currentServer)->m_name),
+ QMessageBox::Warning, QMessageBox::Yes | QMessageBox::No, QMessageBox::No)
+ ->exec();
if (response != QMessageBox::Yes)
return;
@@ -818,23 +728,21 @@ void ServersPage::on_actionRemove_triggered()
void ServersPage::on_actionMove_Up_triggered()
{
- if(m_model->moveUp(currentServer))
- {
- currentServer --;
+ if (m_model->moveUp(currentServer)) {
+ currentServer--;
}
}
void ServersPage::on_actionMove_Down_triggered()
{
- if(m_model->moveDown(currentServer))
- {
- currentServer ++;
+ if (m_model->moveDown(currentServer)) {
+ currentServer++;
}
}
void ServersPage::on_actionJoin_triggered()
{
- const auto &address = m_model->at(currentServer)->m_address;
+ const auto& address = m_model->at(currentServer)->m_address;
APPLICATION->launch(m_inst, true, false, nullptr, std::make_shared<MinecraftServerTarget>(MinecraftServerTarget::parse(address)));
}
diff --git a/launcher/ui/pages/instance/ServersPage.h b/launcher/ui/pages/instance/ServersPage.h
index 476e7d70..a27d1d29 100644
--- a/launcher/ui/pages/instance/ServersPage.h
+++ b/launcher/ui/pages/instance/ServersPage.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>
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
*
@@ -39,13 +39,12 @@
#include <QMainWindow>
#include <QString>
-#include "ui/pages/BasePage.h"
#include <Application.h>
+#include "ui/pages/BasePage.h"
#include "settings/Setting.h"
-namespace Ui
-{
+namespace Ui {
class ServersPage;
}
@@ -53,46 +52,33 @@ struct Server;
class ServersModel;
class MinecraftInstance;
-class ServersPage : public QMainWindow, public BasePage
-{
+class ServersPage : public QMainWindow, public BasePage {
Q_OBJECT
-public:
- explicit ServersPage(InstancePtr inst, QWidget *parent = 0);
+ public:
+ explicit ServersPage(InstancePtr inst, QWidget* parent = 0);
virtual ~ServersPage();
void openedImpl() override;
void closedImpl() override;
- virtual QString displayName() const override
- {
- return tr("Servers");
- }
- virtual QIcon icon() const override
- {
- return APPLICATION->getThemedIcon("server");
- }
- virtual QString id() const override
- {
- return "servers";
- }
- virtual QString helpPage() const override
- {
- return "Servers-management";
- }
+ virtual QString displayName() const override { return tr("Servers"); }
+ virtual QIcon icon() const override { return APPLICATION->getThemedIcon("server"); }
+ virtual QString id() const override { return "servers"; }
+ virtual QString helpPage() const override { return "Servers-management"; }
void retranslate() override;
-protected:
- QMenu * createPopupMenu() override;
+ protected:
+ QMenu* createPopupMenu() override;
-private:
+ private:
void updateState();
void scheduleSave();
bool saveIsScheduled() const;
-private slots:
- void currentChanged(const QModelIndex &current, const QModelIndex &previous);
- void rowsRemoved(const QModelIndex &parent, int first, int last);
+ private slots:
+ void currentChanged(const QModelIndex& current, const QModelIndex& previous);
+ void rowsRemoved(const QModelIndex& parent, int first, int last);
void on_actionAdd_triggered();
void on_actionRemove_triggered();
@@ -102,19 +88,18 @@ private slots:
void runningStateChanged(bool running);
- void nameEdited(const QString & name);
- void addressEdited(const QString & address);
- void resourceIndexChanged(int index);\
+ void nameEdited(const QString& name);
+ void addressEdited(const QString& address);
+ void resourceIndexChanged(int index);
- void ShowContextMenu(const QPoint &pos);
+ void ShowContextMenu(const QPoint& pos);
-private: // data
+ private: // data
int currentServer = -1;
bool m_locked = true;
- Ui::ServersPage *ui = nullptr;
- ServersModel * m_model = nullptr;
+ Ui::ServersPage* ui = nullptr;
+ ServersModel* m_model = nullptr;
InstancePtr m_inst = nullptr;
std::shared_ptr<Setting> m_wide_bar_setting = nullptr;
};
-
diff --git a/launcher/ui/pages/instance/ShaderPackPage.cpp b/launcher/ui/pages/instance/ShaderPackPage.cpp
index 2d0c10aa..dc8b0a05 100644
--- a/launcher/ui/pages/instance/ShaderPackPage.cpp
+++ b/launcher/ui/pages/instance/ShaderPackPage.cpp
@@ -46,7 +46,6 @@
#include "ui/dialogs/ProgressDialog.h"
#include "ui/dialogs/ResourceDownloadDialog.h"
-
ShaderPackPage::ShaderPackPage(MinecraftInstance* instance, std::shared_ptr<ShaderPackFolderModel> model, QWidget* parent)
: ExternalResourcesPage(instance, model, parent)
{
@@ -61,8 +60,6 @@ ShaderPackPage::ShaderPackPage(MinecraftInstance* instance, std::shared_ptr<Shad
void ShaderPackPage::downloadShaders()
{
- if (!m_controlsEnabled)
- return;
if (m_instance->typeName() != "Minecraft")
return; // this is a null instance or a legacy instance
diff --git a/launcher/ui/pages/instance/ShaderPackPage.h b/launcher/ui/pages/instance/ShaderPackPage.h
index a779fd8c..7c43a375 100644
--- a/launcher/ui/pages/instance/ShaderPackPage.h
+++ b/launcher/ui/pages/instance/ShaderPackPage.h
@@ -39,11 +39,10 @@
#include "ExternalResourcesPage.h"
-class ShaderPackPage : public ExternalResourcesPage
-{
+class ShaderPackPage : public ExternalResourcesPage {
Q_OBJECT
-public:
- explicit ShaderPackPage(MinecraftInstance *instance, std::shared_ptr<ShaderPackFolderModel> model, QWidget *parent = nullptr);
+ public:
+ explicit ShaderPackPage(MinecraftInstance* instance, std::shared_ptr<ShaderPackFolderModel> model, QWidget* parent = nullptr);
~ShaderPackPage() override = default;
QString displayName() const override { return tr("Shader packs"); }
diff --git a/launcher/ui/pages/instance/TexturePackPage.cpp b/launcher/ui/pages/instance/TexturePackPage.cpp
index 427aba11..e477ceda 100644
--- a/launcher/ui/pages/instance/TexturePackPage.cpp
+++ b/launcher/ui/pages/instance/TexturePackPage.cpp
@@ -69,8 +69,6 @@ bool TexturePackPage::onSelectionChanged(const QModelIndex& current, const QMode
void TexturePackPage::downloadTPs()
{
- if (!m_controlsEnabled)
- return;
if (m_instance->typeName() != "Minecraft")
return; // this is a null instance or a legacy instance
diff --git a/launcher/ui/pages/instance/TexturePackPage.h b/launcher/ui/pages/instance/TexturePackPage.h
index 47a8fa60..9c4f24b7 100644
--- a/launcher/ui/pages/instance/TexturePackPage.h
+++ b/launcher/ui/pages/instance/TexturePackPage.h
@@ -42,21 +42,17 @@
#include "minecraft/mod/TexturePackFolderModel.h"
-class TexturePackPage : public ExternalResourcesPage
-{
+class TexturePackPage : public ExternalResourcesPage {
Q_OBJECT
-public:
- explicit TexturePackPage(MinecraftInstance *instance, std::shared_ptr<TexturePackFolderModel> model, QWidget* parent = nullptr);
+ public:
+ explicit TexturePackPage(MinecraftInstance* instance, std::shared_ptr<TexturePackFolderModel> model, QWidget* parent = nullptr);
QString displayName() const override { return tr("Texture packs"); }
QIcon icon() const override { return APPLICATION->getThemedIcon("resourcepacks"); }
QString id() const override { return "texturepacks"; }
QString helpPage() const override { return "Texture-packs"; }
- virtual bool shouldDisplay() const override
- {
- return m_instance->traits().contains("texturepacks");
- }
+ virtual bool shouldDisplay() const override { return m_instance->traits().contains("texturepacks"); }
public slots:
bool onSelectionChanged(const QModelIndex& current, const QModelIndex& previous) override;
diff --git a/launcher/ui/pages/instance/VersionPage.cpp b/launcher/ui/pages/instance/VersionPage.cpp
index 59107c53..a180c804 100644
--- a/launcher/ui/pages/instance/VersionPage.cpp
+++ b/launcher/ui/pages/instance/VersionPage.cpp
@@ -40,14 +40,13 @@
#include "Application.h"
-#include <QMessageBox>
-#include <QLabel>
+#include <QAbstractItemModel>
#include <QEvent>
#include <QKeyEvent>
+#include <QLabel>
+#include <QListView>
#include <QMenu>
-#include <QAbstractItemModel>
#include <QMessageBox>
-#include <QListView>
#include <QString>
#include <QUrl>
@@ -55,49 +54,42 @@
#include "ui_VersionPage.h"
#include "ui/dialogs/CustomMessageBox.h"
-#include "ui/dialogs/VersionSelectDialog.h"
#include "ui/dialogs/NewComponentDialog.h"
#include "ui/dialogs/ProgressDialog.h"
+#include "ui/dialogs/VersionSelectDialog.h"
#include "ui/GuiUtil.h"
+#include "DesktopServices.h"
+#include "Exception.h"
+#include "Version.h"
+#include "icons/IconList.h"
#include "minecraft/PackProfile.h"
#include "minecraft/auth/AccountList.h"
#include "minecraft/mod/Mod.h"
-#include "icons/IconList.h"
-#include "Exception.h"
-#include "Version.h"
-#include "DesktopServices.h"
#include "meta/Index.h"
#include "meta/VersionList.h"
-class IconProxy : public QIdentityProxyModel
-{
+class IconProxy : public QIdentityProxyModel {
Q_OBJECT
-public:
-
- IconProxy(QWidget *parentWidget) : QIdentityProxyModel(parentWidget)
+ public:
+ IconProxy(QWidget* parentWidget) : QIdentityProxyModel(parentWidget)
{
connect(parentWidget, &QObject::destroyed, this, &IconProxy::widgetGone);
m_parentWidget = parentWidget;
}
- virtual QVariant data(const QModelIndex &proxyIndex, int role = Qt::DisplayRole) const override
+ virtual QVariant data(const QModelIndex& proxyIndex, int role = Qt::DisplayRole) const override
{
QVariant var = QIdentityProxyModel::data(proxyIndex, role);
int column = proxyIndex.column();
- if(column == 0 && role == Qt::DecorationRole && m_parentWidget)
- {
- if(!var.isNull())
- {
+ if (column == 0 && role == Qt::DecorationRole && m_parentWidget) {
+ if (!var.isNull()) {
auto string = var.toString();
- if(string == "warning")
- {
+ if (string == "warning") {
return APPLICATION->getThemedIcon("status-yellow");
- }
- else if(string == "error")
- {
+ } else if (string == "error") {
return APPLICATION->getThemedIcon("status-bad");
}
}
@@ -105,14 +97,11 @@ public:
}
return var;
}
-private slots:
- void widgetGone()
- {
- m_parentWidget = nullptr;
- }
+ private slots:
+ void widgetGone() { m_parentWidget = nullptr; }
-private:
- QWidget *m_parentWidget = nullptr;
+ private:
+ QWidget* m_parentWidget = nullptr;
};
QIcon VersionPage::icon() const
@@ -144,15 +133,14 @@ void VersionPage::closedImpl()
m_wide_bar_setting->set(ui->toolBar->getVisibilityState());
}
-QMenu * VersionPage::createPopupMenu()
+QMenu* VersionPage::createPopupMenu()
{
QMenu* filteredMenu = QMainWindow::createPopupMenu();
- filteredMenu->removeAction( ui->toolBar->toggleViewAction() );
+ filteredMenu->removeAction(ui->toolBar->toggleViewAction());
return filteredMenu;
}
-VersionPage::VersionPage(MinecraftInstance *inst, QWidget *parent)
- : QMainWindow(parent), ui(new Ui::VersionPage), m_inst(inst)
+VersionPage::VersionPage(MinecraftInstance* inst, QWidget* parent) : QMainWindow(parent), ui(new Ui::VersionPage), m_inst(inst)
{
ui->setupUi(this);
@@ -182,10 +170,8 @@ VersionPage::VersionPage(MinecraftInstance *inst, QWidget *parent)
connect(smodel, &QItemSelectionModel::currentChanged, this, &VersionPage::packageCurrent);
connect(m_profile.get(), &PackProfile::minecraftChanged, this, &VersionPage::updateVersionControls);
- controlsEnabled = !m_inst->isRunning();
updateVersionControls();
preselect(0);
- connect(m_inst, &BaseInstance::runningStatusChanged, this, &VersionPage::updateRunningStatus);
connect(ui->packageView, &ModListView::customContextMenuRequested, this, &VersionPage::showContextMenu);
connect(ui->filterEdit, &QLineEdit::textChanged, this, &VersionPage::onFilterTextChanged);
}
@@ -202,18 +188,16 @@ void VersionPage::showContextMenu(const QPoint& pos)
delete menu;
}
-void VersionPage::packageCurrent(const QModelIndex &current, const QModelIndex &previous)
+void VersionPage::packageCurrent(const QModelIndex& current, const QModelIndex& previous)
{
- if (!current.isValid())
- {
+ if (!current.isValid()) {
ui->frame->clear();
return;
}
int row = current.row();
auto patch = m_profile->getComponent(row);
auto severity = patch->getProblemSeverity();
- switch(severity)
- {
+ switch (severity) {
case ProblemSeverity::Warning:
ui->frame->setName(tr("%1 possibly has issues.").arg(patch->getName()));
break;
@@ -226,16 +210,12 @@ void VersionPage::packageCurrent(const QModelIndex &current, const QModelIndex &
return;
}
- auto &problems = patch->getProblems();
+ auto& problems = patch->getProblems();
QString problemOut;
- for (auto &problem: problems)
- {
- if(problem.m_severity == ProblemSeverity::Error)
- {
+ for (auto& problem : problems) {
+ if (problem.m_severity == ProblemSeverity::Error) {
problemOut += tr("Error: ");
- }
- else if(problem.m_severity == ProblemSeverity::Warning)
- {
+ } else if (problem.m_severity == ProblemSeverity::Warning) {
problemOut += tr("Warning: ");
}
problemOut += problem.m_description;
@@ -244,71 +224,47 @@ void VersionPage::packageCurrent(const QModelIndex &current, const QModelIndex &
ui->frame->setDescription(problemOut);
}
-void VersionPage::updateRunningStatus(bool running)
-{
- if(controlsEnabled == running) {
- controlsEnabled = !running;
- updateVersionControls();
- }
-}
-
void VersionPage::updateVersionControls()
{
// FIXME: this is a dirty hack
auto minecraftVersion = Version(m_profile->getComponentVersion("net.minecraft"));
- ui->actionInstall_Forge->setEnabled(controlsEnabled);
-
bool supportsFabric = minecraftVersion >= Version("1.14");
- ui->actionInstall_Fabric->setEnabled(controlsEnabled && supportsFabric);
+ ui->actionInstall_Fabric->setEnabled(supportsFabric);
bool supportsQuilt = minecraftVersion >= Version("1.14");
- ui->actionInstall_Quilt->setEnabled(controlsEnabled && supportsQuilt);
+ ui->actionInstall_Quilt->setEnabled(supportsQuilt);
bool supportsLiteLoader = minecraftVersion <= Version("1.12.2");
- ui->actionInstall_LiteLoader->setEnabled(controlsEnabled && supportsLiteLoader);
+ ui->actionInstall_LiteLoader->setEnabled(supportsLiteLoader);
updateButtons();
}
void VersionPage::updateButtons(int row)
{
- if(row == -1)
+ if (row == -1)
row = currentRow();
auto patch = m_profile->getComponent(row);
- ui->actionRemove->setEnabled(controlsEnabled && patch && patch->isRemovable());
- ui->actionMove_down->setEnabled(controlsEnabled && patch && patch->isMoveable());
- ui->actionMove_up->setEnabled(controlsEnabled && patch && patch->isMoveable());
- ui->actionChange_version->setEnabled(controlsEnabled && patch && patch->isVersionChangeable());
- ui->actionEdit->setEnabled(controlsEnabled && patch && patch->isCustom());
- ui->actionCustomize->setEnabled(controlsEnabled && patch && patch->isCustomizable());
- ui->actionRevert->setEnabled(controlsEnabled && patch && patch->isRevertible());
- ui->actionDownload_All->setEnabled(controlsEnabled);
- ui->actionAdd_Empty->setEnabled(controlsEnabled);
- ui->actionImport_Components->setEnabled(controlsEnabled);
- ui->actionReload->setEnabled(controlsEnabled);
- ui->actionReplace_Minecraft_jar->setEnabled(controlsEnabled);
- ui->actionAdd_to_Minecraft_jar->setEnabled(controlsEnabled);
- ui->actionAdd_Agents->setEnabled(controlsEnabled);
+ ui->actionRemove->setEnabled(patch && patch->isRemovable());
+ ui->actionMove_down->setEnabled(patch && patch->isMoveable());
+ ui->actionMove_up->setEnabled(patch && patch->isMoveable());
+ ui->actionChange_version->setEnabled(patch && patch->isVersionChangeable());
+ ui->actionEdit->setEnabled(patch && patch->isCustom());
+ ui->actionCustomize->setEnabled(patch && patch->isCustomizable());
+ ui->actionRevert->setEnabled(patch && patch->isRevertible());
}
bool VersionPage::reloadPackProfile()
{
- try
- {
+ try {
m_profile->reload(Net::Mode::Online);
return true;
- }
- catch (const Exception &e)
- {
+ } catch (const Exception& e) {
QMessageBox::critical(this, tr("Error"), e.cause());
return false;
- }
- catch (...)
- {
- QMessageBox::critical(
- this, tr("Error"),
- tr("Couldn't load the instance profile."));
+ } catch (...) {
+ QMessageBox::critical(this, tr("Error"), tr("Couldn't load the instance profile."));
return false;
}
}
@@ -321,14 +277,12 @@ void VersionPage::on_actionReload_triggered()
void VersionPage::on_actionRemove_triggered()
{
- if (!ui->packageView->currentIndex().isValid())
- {
+ if (!ui->packageView->currentIndex().isValid()) {
return;
}
int index = ui->packageView->currentIndex().row();
auto component = m_profile->getComponent(index);
- if (component->isCustom())
- {
+ if (component->isCustom()) {
auto response = CustomMessageBox::selectable(this, tr("Confirm Removal"),
tr("You are about to remove \"%1\".\n"
"This is permanent and will completely remove the custom component.\n\n"
@@ -341,8 +295,7 @@ void VersionPage::on_actionRemove_triggered()
return;
}
// FIXME: use actual model, not reloading.
- if (!m_profile->remove(index))
- {
+ if (!m_profile->remove(index)) {
QMessageBox::critical(this, tr("Error"), tr("Couldn't remove file"));
}
updateButtons();
@@ -352,17 +305,16 @@ void VersionPage::on_actionRemove_triggered()
void VersionPage::on_actionInstall_mods_triggered()
{
- if(m_container)
- {
+ if (m_container) {
m_container->selectPage("mods");
}
}
void VersionPage::on_actionAdd_to_Minecraft_jar_triggered()
{
- auto list = GuiUtil::BrowseForFiles("jarmod", tr("Select jar mods"), tr("Minecraft.jar mods (*.zip *.jar)"), APPLICATION->settings()->get("CentralModsDir").toString(), this->parentWidget());
- if(!list.empty())
- {
+ auto list = GuiUtil::BrowseForFiles("jarmod", tr("Select jar mods"), tr("Minecraft.jar mods (*.zip *.jar)"),
+ APPLICATION->settings()->get("CentralModsDir").toString(), this->parentWidget());
+ if (!list.empty()) {
m_profile->installJarMods(list);
}
updateButtons();
@@ -370,9 +322,9 @@ void VersionPage::on_actionAdd_to_Minecraft_jar_triggered()
void VersionPage::on_actionReplace_Minecraft_jar_triggered()
{
- auto jarPath = GuiUtil::BrowseForFile("jar", tr("Select jar"), tr("Minecraft.jar replacement (*.jar)"), APPLICATION->settings()->get("CentralModsDir").toString(), this->parentWidget());
- if(!jarPath.isEmpty())
- {
+ auto jarPath = GuiUtil::BrowseForFile("jar", tr("Select jar"), tr("Minecraft.jar replacement (*.jar)"),
+ APPLICATION->settings()->get("CentralModsDir").toString(), this->parentWidget());
+ if (!jarPath.isEmpty()) {
m_profile->installCustomJar(jarPath);
}
updateButtons();
@@ -406,12 +358,9 @@ void VersionPage::on_actionAdd_Agents_triggered()
void VersionPage::on_actionMove_up_triggered()
{
- try
- {
+ try {
m_profile->move(currentRow(), PackProfile::MoveUp);
- }
- catch (const Exception &e)
- {
+ } catch (const Exception& e) {
QMessageBox::critical(this, tr("Error"), e.cause());
}
updateButtons();
@@ -419,12 +368,9 @@ void VersionPage::on_actionMove_up_triggered()
void VersionPage::on_actionMove_down_triggered()
{
- try
- {
+ try {
m_profile->move(currentRow(), PackProfile::MoveDown);
- }
- catch (const Exception &e)
- {
+ } catch (const Exception& e) {
QMessageBox::critical(this, tr("Error"), e.cause());
}
updateButtons();
@@ -433,39 +379,32 @@ void VersionPage::on_actionMove_down_triggered()
void VersionPage::on_actionChange_version_triggered()
{
auto versionRow = currentRow();
- if(versionRow == -1)
- {
+ if (versionRow == -1) {
return;
}
auto patch = m_profile->getComponent(versionRow);
auto name = patch->getName();
auto list = patch->getVersionList();
- if(!list)
- {
+ if (!list) {
return;
}
auto uid = list->uid();
// FIXME: this is a horrible HACK. Get version filtering information from the actual metadata...
- if(uid == "net.minecraftforge")
- {
+ if (uid == "net.minecraftforge") {
on_actionInstall_Forge_triggered();
return;
- }
- else if (uid == "com.mumfrey.liteloader")
- {
+ } else if (uid == "com.mumfrey.liteloader") {
on_actionInstall_LiteLoader_triggered();
return;
}
VersionSelectDialog vselect(list.get(), tr("Change %1 version").arg(name), this);
- if (uid == "net.fabricmc.intermediary" || uid == "org.quiltmc.hashed")
- {
+ if (uid == "net.fabricmc.intermediary" || uid == "org.quiltmc.hashed") {
vselect.setEmptyString(tr("No intermediary mappings versions are currently available."));
vselect.setEmptyErrorString(tr("Couldn't load or download the intermediary mappings version lists!"));
vselect.setExactFilter(BaseVersionList::ParentVersionRole, m_profile->getComponentVersion("net.minecraft"));
}
auto currentVersion = patch->getVersion();
- if(!currentVersion.isEmpty())
- {
+ if (!currentVersion.isEmpty()) {
vselect.setCurrentVersion(currentVersion);
}
if (!vselect.exec() || !vselect.selectedVersion())
@@ -473,8 +412,7 @@ void VersionPage::on_actionChange_version_triggered()
qDebug() << "Change" << uid << "to" << vselect.selectedVersion()->descriptor();
bool important = false;
- if(uid == "net.minecraft")
- {
+ if (uid == "net.minecraft") {
important = true;
}
m_profile->setComponentVersion(uid, vselect.selectedVersion()->descriptor(), important);
@@ -484,19 +422,17 @@ void VersionPage::on_actionChange_version_triggered()
void VersionPage::on_actionDownload_All_triggered()
{
- if (!APPLICATION->accounts()->anyAccountIsValid())
- {
- CustomMessageBox::selectable(
- this, tr("Error"),
- tr("Cannot download Minecraft or update instances unless you have at least "
- "one account added.\nPlease add your Mojang or Minecraft account."),
- QMessageBox::Warning)->show();
+ if (!APPLICATION->accounts()->anyAccountIsValid()) {
+ CustomMessageBox::selectable(this, tr("Error"),
+ tr("Cannot download Minecraft or update instances unless you have at least "
+ "one account added.\nPlease add your Mojang or Minecraft account."),
+ QMessageBox::Warning)
+ ->show();
return;
}
auto updateTask = m_inst->createUpdateTask(Net::Mode::Online);
- if (!updateTask)
- {
+ if (!updateTask) {
return;
}
ProgressDialog tDialog(this);
@@ -510,28 +446,26 @@ void VersionPage::on_actionDownload_All_triggered()
void VersionPage::on_actionInstall_Forge_triggered()
{
auto vlist = APPLICATION->metadataIndex()->get("net.minecraftforge");
- if(!vlist)
- {
+ if (!vlist) {
return;
}
VersionSelectDialog vselect(vlist.get(), tr("Select Forge version"), this);
vselect.setExactFilter(BaseVersionList::ParentVersionRole, m_profile->getComponentVersion("net.minecraft"));
- vselect.setEmptyString(tr("No Forge versions are currently available for Minecraft ") + m_profile->getComponentVersion("net.minecraft"));
+ vselect.setEmptyString(tr("No Forge versions are currently available for Minecraft ") +
+ m_profile->getComponentVersion("net.minecraft"));
vselect.setEmptyErrorString(tr("Couldn't load or download the Forge version lists!"));
auto currentVersion = m_profile->getComponentVersion("net.minecraftforge");
- if(!currentVersion.isEmpty())
- {
+ if (!currentVersion.isEmpty()) {
vselect.setCurrentVersion(currentVersion);
}
- if (vselect.exec() && vselect.selectedVersion())
- {
+ if (vselect.exec() && vselect.selectedVersion()) {
auto vsn = vselect.selectedVersion();
m_profile->setComponentVersion("net.minecraftforge", vsn->descriptor());
m_profile->resolve(Net::Mode::Online);
// m_profile->installVersion();
- preselect(m_profile->rowCount(QModelIndex())-1);
+ preselect(m_profile->rowCount(QModelIndex()) - 1);
m_container->refreshContainer();
}
}
@@ -539,8 +473,7 @@ void VersionPage::on_actionInstall_Forge_triggered()
void VersionPage::on_actionInstall_Fabric_triggered()
{
auto vlist = APPLICATION->metadataIndex()->get("net.fabricmc.fabric-loader");
- if(!vlist)
- {
+ if (!vlist) {
return;
}
VersionSelectDialog vselect(vlist.get(), tr("Select Fabric Loader version"), this);
@@ -548,17 +481,15 @@ void VersionPage::on_actionInstall_Fabric_triggered()
vselect.setEmptyErrorString(tr("Couldn't load or download the Fabric Loader version lists!"));
auto currentVersion = m_profile->getComponentVersion("net.fabricmc.fabric-loader");
- if(!currentVersion.isEmpty())
- {
+ if (!currentVersion.isEmpty()) {
vselect.setCurrentVersion(currentVersion);
}
- if (vselect.exec() && vselect.selectedVersion())
- {
+ if (vselect.exec() && vselect.selectedVersion()) {
auto vsn = vselect.selectedVersion();
m_profile->setComponentVersion("net.fabricmc.fabric-loader", vsn->descriptor());
m_profile->resolve(Net::Mode::Online);
- preselect(m_profile->rowCount(QModelIndex())-1);
+ preselect(m_profile->rowCount(QModelIndex()) - 1);
m_container->refreshContainer();
}
}
@@ -566,8 +497,7 @@ void VersionPage::on_actionInstall_Fabric_triggered()
void VersionPage::on_actionInstall_Quilt_triggered()
{
auto vlist = APPLICATION->metadataIndex()->get("org.quiltmc.quilt-loader");
- if(!vlist)
- {
+ if (!vlist) {
return;
}
VersionSelectDialog vselect(vlist.get(), tr("Select Quilt Loader version"), this);
@@ -575,17 +505,15 @@ void VersionPage::on_actionInstall_Quilt_triggered()
vselect.setEmptyErrorString(tr("Couldn't load or download the Quilt Loader version lists!"));
auto currentVersion = m_profile->getComponentVersion("org.quiltmc.quilt-loader");
- if(!currentVersion.isEmpty())
- {
+ if (!currentVersion.isEmpty()) {
vselect.setCurrentVersion(currentVersion);
}
- if (vselect.exec() && vselect.selectedVersion())
- {
+ if (vselect.exec() && vselect.selectedVersion()) {
auto vsn = vselect.selectedVersion();
m_profile->setComponentVersion("org.quiltmc.quilt-loader", vsn->descriptor());
m_profile->resolve(Net::Mode::Online);
- preselect(m_profile->rowCount(QModelIndex())-1);
+ preselect(m_profile->rowCount(QModelIndex()) - 1);
m_container->refreshContainer();
}
}
@@ -594,14 +522,12 @@ void VersionPage::on_actionAdd_Empty_triggered()
{
NewComponentDialog compdialog(QString(), QString(), this);
QStringList blacklist;
- for(int i = 0; i < m_profile->rowCount(); i++)
- {
+ for (int i = 0; i < m_profile->rowCount(); i++) {
auto comp = m_profile->getComponent(i);
blacklist.push_back(comp->getID());
}
compdialog.setBlacklist(blacklist);
- if (compdialog.exec())
- {
+ if (compdialog.exec()) {
qDebug() << "name:" << compdialog.name();
qDebug() << "uid:" << compdialog.uid();
m_profile->installEmpty(compdialog.uid(), compdialog.name());
@@ -611,28 +537,26 @@ void VersionPage::on_actionAdd_Empty_triggered()
void VersionPage::on_actionInstall_LiteLoader_triggered()
{
auto vlist = APPLICATION->metadataIndex()->get("com.mumfrey.liteloader");
- if(!vlist)
- {
+ if (!vlist) {
return;
}
VersionSelectDialog vselect(vlist.get(), tr("Select LiteLoader version"), this);
vselect.setExactFilter(BaseVersionList::ParentVersionRole, m_profile->getComponentVersion("net.minecraft"));
- vselect.setEmptyString(tr("No LiteLoader versions are currently available for Minecraft ") + m_profile->getComponentVersion("net.minecraft"));
+ vselect.setEmptyString(tr("No LiteLoader versions are currently available for Minecraft ") +
+ m_profile->getComponentVersion("net.minecraft"));
vselect.setEmptyErrorString(tr("Couldn't load or download the LiteLoader version lists!"));
auto currentVersion = m_profile->getComponentVersion("com.mumfrey.liteloader");
- if(!currentVersion.isEmpty())
- {
+ if (!currentVersion.isEmpty()) {
vselect.setCurrentVersion(currentVersion);
}
- if (vselect.exec() && vselect.selectedVersion())
- {
+ if (vselect.exec() && vselect.selectedVersion()) {
auto vsn = vselect.selectedVersion();
m_profile->setComponentVersion("com.mumfrey.liteloader", vsn->descriptor());
m_profile->resolve(Net::Mode::Online);
// m_profile->installVersion(vselect.selectedVersion());
- preselect(m_profile->rowCount(QModelIndex())-1);
+ preselect(m_profile->rowCount(QModelIndex()) - 1);
m_container->refreshContainer();
}
}
@@ -647,7 +571,7 @@ void VersionPage::on_actionMinecraftFolder_triggered()
DesktopServices::openDirectory(m_inst->gameRoot(), true);
}
-void VersionPage::versionCurrent(const QModelIndex &current, const QModelIndex &previous)
+void VersionPage::versionCurrent(const QModelIndex& current, const QModelIndex& previous)
{
currentIdx = current.row();
updateButtons(currentIdx);
@@ -655,16 +579,13 @@ void VersionPage::versionCurrent(const QModelIndex &current, const QModelIndex &
void VersionPage::preselect(int row)
{
- if(row < 0)
- {
+ if (row < 0) {
row = 0;
}
- if(row >= m_profile->rowCount(QModelIndex()))
- {
+ if (row >= m_profile->rowCount(QModelIndex())) {
row = m_profile->rowCount(QModelIndex()) - 1;
}
- if(row < 0)
- {
+ if (row < 0) {
return;
}
auto model_index = m_profile->index(row);
@@ -680,8 +601,7 @@ void VersionPage::onGameUpdateError(QString error)
ComponentPtr VersionPage::current()
{
auto row = currentRow();
- if(row < 0)
- {
+ if (row < 0) {
return nullptr;
}
return m_profile->getComponent(row);
@@ -689,8 +609,7 @@ ComponentPtr VersionPage::current()
int VersionPage::currentRow()
{
- if (ui->packageView->selectionModel()->selectedRows().isEmpty())
- {
+ if (ui->packageView->selectionModel()->selectedRows().isEmpty()) {
return -1;
}
return ui->packageView->selectionModel()->selectedRows().first().row();
@@ -699,18 +618,15 @@ int VersionPage::currentRow()
void VersionPage::on_actionCustomize_triggered()
{
auto version = currentRow();
- if(version == -1)
- {
+ if (version == -1) {
return;
}
auto patch = m_profile->getComponent(version);
- if(!patch->getVersionFile())
- {
+ if (!patch->getVersionFile()) {
// TODO: wait for the update task to finish here...
return;
}
- if(!m_profile->customize(version))
- {
+ if (!m_profile->customize(version)) {
// TODO: some error box here
}
updateButtons();
@@ -720,13 +636,11 @@ void VersionPage::on_actionCustomize_triggered()
void VersionPage::on_actionEdit_triggered()
{
auto version = current();
- if(!version)
- {
+ if (!version) {
return;
}
auto filename = version->getFilename();
- if(!QFileInfo::exists(filename))
- {
+ if (!QFileInfo::exists(filename)) {
qWarning() << "file" << filename << "can't be opened for editing, doesn't exist!";
return;
}
@@ -736,8 +650,7 @@ void VersionPage::on_actionEdit_triggered()
void VersionPage::on_actionRevert_triggered()
{
auto version = currentRow();
- if(version == -1)
- {
+ if (version == -1) {
return;
}
auto component = m_profile->getComponent(version);
@@ -753,8 +666,7 @@ void VersionPage::on_actionRevert_triggered()
if (response != QMessageBox::Yes)
return;
- if(!m_profile->revertToBase(version))
- {
+ if (!m_profile->revertToBase(version)) {
// TODO: some error box here
}
updateButtons();
@@ -762,7 +674,7 @@ void VersionPage::on_actionRevert_triggered()
m_container->refreshContainer();
}
-void VersionPage::onFilterTextChanged(const QString &newContents)
+void VersionPage::onFilterTextChanged(const QString& newContents)
{
m_filterModel->setFilterFixedString(newContents);
}
diff --git a/launcher/ui/pages/instance/VersionPage.h b/launcher/ui/pages/instance/VersionPage.h
index d0087714..45d383f4 100644
--- a/launcher/ui/pages/instance/VersionPage.h
+++ b/launcher/ui/pages/instance/VersionPage.h
@@ -46,38 +46,27 @@
#include "minecraft/PackProfile.h"
#include "ui/pages/BasePage.h"
-namespace Ui
-{
+namespace Ui {
class VersionPage;
}
-class VersionPage : public QMainWindow, public BasePage
-{
+class VersionPage : public QMainWindow, public BasePage {
Q_OBJECT
-public:
- explicit VersionPage(MinecraftInstance *inst, QWidget *parent = 0);
+ public:
+ explicit VersionPage(MinecraftInstance* inst, QWidget* parent = 0);
virtual ~VersionPage();
- virtual QString displayName() const override
- {
- return tr("Version");
- }
+ virtual QString displayName() const override { return tr("Version"); }
virtual QIcon icon() const override;
- virtual QString id() const override
- {
- return "version";
- }
- virtual QString helpPage() const override
- {
- return "Instance-Version";
- }
+ virtual QString id() const override { return "version"; }
+ virtual QString helpPage() const override { return "Instance-Version"; }
virtual bool shouldDisplay() const override;
void retranslate() override;
void openedImpl() override;
void closedImpl() override;
-private slots:
+ private slots:
void on_actionChange_version_triggered();
void on_actionInstall_Forge_triggered();
void on_actionInstall_Fabric_triggered();
@@ -103,36 +92,34 @@ private slots:
void updateVersionControls();
-private:
+ private:
ComponentPtr current();
int currentRow();
void updateButtons(int row = -1);
void preselect(int row = 0);
int doUpdate();
-protected:
- QMenu * createPopupMenu() override;
+ protected:
+ QMenu* createPopupMenu() override;
/// FIXME: this shouldn't be necessary!
bool reloadPackProfile();
-private:
- Ui::VersionPage *ui;
- QSortFilterProxyModel *m_filterModel;
+ private:
+ Ui::VersionPage* ui;
+ QSortFilterProxyModel* m_filterModel;
std::shared_ptr<PackProfile> m_profile;
- MinecraftInstance *m_inst;
+ MinecraftInstance* m_inst;
int currentIdx = 0;
- bool controlsEnabled = false;
std::shared_ptr<Setting> m_wide_bar_setting = nullptr;
-public slots:
- void versionCurrent(const QModelIndex &current, const QModelIndex &previous);
+ public slots:
+ void versionCurrent(const QModelIndex& current, const QModelIndex& previous);
-private slots:
- void updateRunningStatus(bool running);
+ private slots:
void onGameUpdateError(QString error);
- void packageCurrent(const QModelIndex &current, const QModelIndex &previous);
- void showContextMenu(const QPoint &pos);
- void onFilterTextChanged(const QString & newContents);
+ void packageCurrent(const QModelIndex& current, const QModelIndex& previous);
+ void showContextMenu(const QPoint& pos);
+ void onFilterTextChanged(const QString& newContents);
};
diff --git a/launcher/ui/pages/instance/WorldListPage.cpp b/launcher/ui/pages/instance/WorldListPage.cpp
index b6ad159e..fe477616 100644
--- a/launcher/ui/pages/instance/WorldListPage.cpp
+++ b/launcher/ui/pages/instance/WorldListPage.cpp
@@ -36,45 +36,42 @@
*/
#include "WorldListPage.h"
+#include "minecraft/WorldList.h"
#include "ui/dialogs/CustomMessageBox.h"
#include "ui_WorldListPage.h"
-#include "minecraft/WorldList.h"
+#include <QClipboard>
#include <QEvent>
-#include <QMenu>
+#include <QInputDialog>
#include <QKeyEvent>
-#include <QClipboard>
+#include <QMenu>
#include <QMessageBox>
#include <QSortFilterProxyModel>
#include <QTreeView>
-#include <QInputDialog>
#include <Qt>
-#include "tools/MCEditTool.h"
#include "FileSystem.h"
+#include "tools/MCEditTool.h"
-#include "ui/GuiUtil.h"
#include "DesktopServices.h"
+#include "ui/GuiUtil.h"
#include "Application.h"
-
-class WorldListProxyModel : public QSortFilterProxyModel
-{
+class WorldListProxyModel : public QSortFilterProxyModel {
Q_OBJECT
-public:
- WorldListProxyModel(QObject *parent) : QSortFilterProxyModel(parent) {}
+ public:
+ WorldListProxyModel(QObject* parent) : QSortFilterProxyModel(parent) {}
- virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const
+ virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const
{
QModelIndex sourceIndex = mapToSource(index);
- if (index.column() == 0 && role == Qt::DecorationRole)
- {
- WorldList *worlds = qobject_cast<WorldList *>(sourceModel());
+ if (index.column() == 0 && role == Qt::DecorationRole) {
+ WorldList* worlds = qobject_cast<WorldList*>(sourceModel());
auto iconFile = worlds->data(sourceIndex, WorldList::IconFileRole).toString();
- if(iconFile.isNull()) {
+ if (iconFile.isNull()) {
// NOTE: Minecraft uses the same placeholder for servers AND worlds
return APPLICATION->getThemedIcon("unknown_server");
}
@@ -85,15 +82,14 @@ public:
}
};
-
-WorldListPage::WorldListPage(BaseInstance *inst, std::shared_ptr<WorldList> worlds, QWidget *parent)
+WorldListPage::WorldListPage(BaseInstance* inst, std::shared_ptr<WorldList> worlds, QWidget* parent)
: QMainWindow(parent), m_inst(inst), ui(new Ui::WorldListPage), m_worlds(worlds)
{
ui->setupUi(this);
ui->toolBar->insertSpacer(ui->actionRefresh);
- WorldListProxyModel * proxy = new WorldListProxyModel(this);
+ WorldListProxyModel* proxy = new WorldListProxyModel(this);
proxy->setSortCaseSensitivity(Qt::CaseInsensitive);
proxy->setSourceModel(m_worlds.get());
proxy->setSortRole(Qt::UserRole);
@@ -101,7 +97,7 @@ WorldListPage::WorldListPage(BaseInstance *inst, std::shared_ptr<WorldList> worl
ui->worldTreeView->setModel(proxy);
ui->worldTreeView->installEventFilter(this);
ui->worldTreeView->setContextMenuPolicy(Qt::CustomContextMenu);
- ui->worldTreeView->setIconSize(QSize(64,64));
+ ui->worldTreeView->setIconSize(QSize(64, 64));
connect(ui->worldTreeView, &QTreeView::customContextMenuRequested, this, &WorldListPage::ShowContextMenu);
auto head = ui->worldTreeView->header();
@@ -146,10 +142,10 @@ void WorldListPage::ShowContextMenu(const QPoint& pos)
delete menu;
}
-QMenu * WorldListPage::createPopupMenu()
+QMenu* WorldListPage::createPopupMenu()
{
QMenu* filteredMenu = QMainWindow::createPopupMenu();
- filteredMenu->removeAction( ui->toolBar->toggleViewAction() );
+ filteredMenu->removeAction(ui->toolBar->toggleViewAction());
return filteredMenu;
}
@@ -163,26 +159,24 @@ void WorldListPage::retranslate()
ui->retranslateUi(this);
}
-bool WorldListPage::worldListFilter(QKeyEvent *keyEvent)
+bool WorldListPage::worldListFilter(QKeyEvent* keyEvent)
{
- switch (keyEvent->key())
- {
- case Qt::Key_Delete:
- on_actionRemove_triggered();
- return true;
- default:
- break;
+ switch (keyEvent->key()) {
+ case Qt::Key_Delete:
+ on_actionRemove_triggered();
+ return true;
+ default:
+ break;
}
return QWidget::eventFilter(ui->worldTreeView, keyEvent);
}
-bool WorldListPage::eventFilter(QObject *obj, QEvent *ev)
+bool WorldListPage::eventFilter(QObject* obj, QEvent* ev)
{
- if (ev->type() != QEvent::KeyPress)
- {
+ if (ev->type() != QEvent::KeyPress) {
return QWidget::eventFilter(obj, ev);
}
- QKeyEvent *keyEvent = static_cast<QKeyEvent *>(ev);
+ QKeyEvent* keyEvent = static_cast<QKeyEvent*>(ev);
if (obj == ui->worldTreeView)
return worldListFilter(keyEvent);
return QWidget::eventFilter(obj, ev);
@@ -192,7 +186,7 @@ void WorldListPage::on_actionRemove_triggered()
{
auto proxiedIndex = getSelectedWorld();
- if(!proxiedIndex.isValid())
+ if (!proxiedIndex.isValid())
return;
auto result = CustomMessageBox::selectable(this, tr("Confirm Deletion"),
@@ -203,8 +197,7 @@ void WorldListPage::on_actionRemove_triggered()
QMessageBox::Warning, QMessageBox::Yes | QMessageBox::No, QMessageBox::No)
->exec();
- if(result != QMessageBox::Yes)
- {
+ if (result != QMessageBox::Yes) {
return;
}
m_worlds->stopWatching();
@@ -221,12 +214,11 @@ void WorldListPage::on_actionDatapacks_triggered()
{
QModelIndex index = getSelectedWorld();
- if (!index.isValid())
- {
+ if (!index.isValid()) {
return;
}
- if(!worldSafetyNagQuestion(tr("Open World Datapacks Folder")))
+ if (!worldSafetyNagQuestion(tr("Open World Datapacks Folder")))
return;
auto fullPath = m_worlds->data(index, WorldList::FolderRole).toString();
@@ -234,25 +226,23 @@ void WorldListPage::on_actionDatapacks_triggered()
DesktopServices::openDirectory(FS::PathCombine(fullPath, "datapacks"), true);
}
-
void WorldListPage::on_actionReset_Icon_triggered()
{
auto proxiedIndex = getSelectedWorld();
- if(!proxiedIndex.isValid())
+ if (!proxiedIndex.isValid())
return;
- if(m_worlds->resetIcon(proxiedIndex.row())) {
+ if (m_worlds->resetIcon(proxiedIndex.row())) {
ui->actionReset_Icon->setEnabled(false);
}
}
-
QModelIndex WorldListPage::getSelectedWorld()
{
auto index = ui->worldTreeView->selectionModel()->currentIndex();
- auto proxy = (QSortFilterProxyModel *) ui->worldTreeView->model();
+ auto proxy = (QSortFilterProxyModel*)ui->worldTreeView->model();
return proxy->mapToSource(index);
}
@@ -260,8 +250,7 @@ void WorldListPage::on_actionCopy_Seed_triggered()
{
QModelIndex index = getSelectedWorld();
- if (!index.isValid())
- {
+ if (!index.isValid()) {
return;
}
int64_t seed = m_worlds->data(index, WorldList::SeedRole).toLongLong();
@@ -270,7 +259,7 @@ void WorldListPage::on_actionCopy_Seed_triggered()
void WorldListPage::on_actionMCEdit_triggered()
{
- if(m_mceditStarting)
+ if (m_mceditStarting)
return;
auto mcedit = APPLICATION->mcedit();
@@ -279,80 +268,66 @@ void WorldListPage::on_actionMCEdit_triggered()
QModelIndex index = getSelectedWorld();
- if (!index.isValid())
- {
+ if (!index.isValid()) {
return;
}
- if(!worldSafetyNagQuestion(tr("Open World in MCEdit")))
+ if (!worldSafetyNagQuestion(tr("Open World in MCEdit")))
return;
auto fullPath = m_worlds->data(index, WorldList::FolderRole).toString();
auto program = mcedit->getProgramPath();
- if(program.size())
- {
+ if (program.size()) {
#ifdef Q_OS_WIN32
- if(!QProcess::startDetached(program, {fullPath}, mceditPath))
- {
+ if (!QProcess::startDetached(program, { fullPath }, mceditPath)) {
mceditError();
}
#else
m_mceditProcess.reset(new LoggedProcess());
m_mceditProcess->setDetachable(true);
connect(m_mceditProcess.get(), &LoggedProcess::stateChanged, this, &WorldListPage::mceditState);
- m_mceditProcess->start(program, {fullPath});
+ m_mceditProcess->start(program, { fullPath });
m_mceditProcess->setWorkingDirectory(mceditPath);
m_mceditStarting = true;
#endif
- }
- else
- {
- QMessageBox::warning(
- this->parentWidget(),
- tr("No MCEdit found or set up!"),
- tr("You do not have MCEdit set up or it was moved.\nYou can set it up in the global settings.")
- );
+ } else {
+ QMessageBox::warning(this->parentWidget(), tr("No MCEdit found or set up!"),
+ tr("You do not have MCEdit set up or it was moved.\nYou can set it up in the global settings."));
}
}
void WorldListPage::mceditError()
{
- QMessageBox::warning(
- this->parentWidget(),
- tr("MCEdit failed to start!"),
- tr("MCEdit failed to start.\nIt may be necessary to reinstall it.")
- );
+ QMessageBox::warning(this->parentWidget(), tr("MCEdit failed to start!"),
+ tr("MCEdit failed to start.\nIt may be necessary to reinstall it."));
}
void WorldListPage::mceditState(LoggedProcess::State state)
{
bool failed = false;
- switch(state)
- {
+ switch (state) {
case LoggedProcess::NotRunning:
case LoggedProcess::Starting:
return;
case LoggedProcess::FailedToStart:
case LoggedProcess::Crashed:
- case LoggedProcess::Aborted:
- {
+ case LoggedProcess::Aborted: {
failed = true;
}
+ /* fallthrough */
case LoggedProcess::Running:
- case LoggedProcess::Finished:
- {
+ case LoggedProcess::Finished: {
m_mceditStarting = false;
break;
}
}
- if(failed)
- {
+ if (failed) {
mceditError();
}
}
-void WorldListPage::worldChanged(const QModelIndex &current, const QModelIndex &previous)
+void WorldListPage::worldChanged(const QModelIndex& current, const QModelIndex& previous)
{
QModelIndex index = getSelectedWorld();
bool enable = index.isValid();
@@ -368,15 +343,11 @@ void WorldListPage::worldChanged(const QModelIndex &current, const QModelIndex &
void WorldListPage::on_actionAdd_triggered()
{
- auto list = GuiUtil::BrowseForFiles(
- displayName(),
- tr("Select a Minecraft world zip"),
- tr("Minecraft World Zip File (*.zip)"), QString(), this->parentWidget());
- if (!list.empty())
- {
+ auto list = GuiUtil::BrowseForFiles(displayName(), tr("Select a Minecraft world zip"), tr("Minecraft World Zip File (*.zip)"),
+ QString(), this->parentWidget());
+ if (!list.empty()) {
m_worlds->stopWatching();
- for (auto filename : list)
- {
+ for (auto filename : list) {
m_worlds->installWorld(QFileInfo(filename));
}
m_worlds->startWatching();
@@ -388,38 +359,35 @@ bool WorldListPage::isWorldSafe(QModelIndex)
return !m_inst->isRunning();
}
-bool WorldListPage::worldSafetyNagQuestion(const QString &actionType)
+bool WorldListPage::worldSafetyNagQuestion(const QString& actionType)
{
- if(!isWorldSafe(getSelectedWorld()))
- {
- auto result = QMessageBox::question(this, actionType, tr("Changing a world while Minecraft is running is potentially unsafe.\nDo you wish to proceed?"));
- if(result == QMessageBox::No)
- {
+ if (!isWorldSafe(getSelectedWorld())) {
+ auto result = QMessageBox::question(
+ this, actionType, tr("Changing a world while Minecraft is running is potentially unsafe.\nDo you wish to proceed?"));
+ if (result == QMessageBox::No) {
return false;
}
}
return true;
}
-
void WorldListPage::on_actionCopy_triggered()
{
QModelIndex index = getSelectedWorld();
- if (!index.isValid())
- {
+ if (!index.isValid()) {
return;
}
- if(!worldSafetyNagQuestion(tr("Copy World")))
+ if (!worldSafetyNagQuestion(tr("Copy World")))
return;
auto worldVariant = m_worlds->data(index, WorldList::ObjectRole);
- auto world = (World *) worldVariant.value<void *>();
+ auto world = (World*)worldVariant.value<void*>();
bool ok = false;
- QString name = QInputDialog::getText(this, tr("World name"), tr("Enter a new name for the copy."), QLineEdit::Normal, world->name(), &ok);
+ QString name =
+ QInputDialog::getText(this, tr("World name"), tr("Enter a new name for the copy."), QLineEdit::Normal, world->name(), &ok);
- if (ok && name.length() > 0)
- {
+ if (ok && name.length() > 0) {
world->install(m_worlds->dir().absolutePath(), name);
}
}
@@ -427,22 +395,20 @@ void WorldListPage::on_actionCopy_triggered()
void WorldListPage::on_actionRename_triggered()
{
QModelIndex index = getSelectedWorld();
- if (!index.isValid())
- {
+ if (!index.isValid()) {
return;
}
- if(!worldSafetyNagQuestion(tr("Rename World")))
+ if (!worldSafetyNagQuestion(tr("Rename World")))
return;
auto worldVariant = m_worlds->data(index, WorldList::ObjectRole);
- auto world = (World *) worldVariant.value<void *>();
+ auto world = (World*)worldVariant.value<void*>();
bool ok = false;
QString name = QInputDialog::getText(this, tr("World name"), tr("Enter a new world name."), QLineEdit::Normal, world->name(), &ok);
- if (ok && name.length() > 0)
- {
+ if (ok && name.length() > 0) {
world->rename(name);
}
}
diff --git a/launcher/ui/pages/instance/WorldListPage.h b/launcher/ui/pages/instance/WorldListPage.h
index 925521be..4f83002f 100644
--- a/launcher/ui/pages/instance/WorldListPage.h
+++ b/launcher/ui/pages/instance/WorldListPage.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
@@ -37,76 +37,58 @@
#include <QMainWindow>
-#include "minecraft/MinecraftInstance.h"
-#include "ui/pages/BasePage.h"
#include <Application.h>
#include <LoggedProcess.h>
+#include "minecraft/MinecraftInstance.h"
+#include "ui/pages/BasePage.h"
#include "settings/Setting.h"
class WorldList;
-namespace Ui
-{
+namespace Ui {
class WorldListPage;
}
-class WorldListPage : public QMainWindow, public BasePage
-{
+class WorldListPage : public QMainWindow, public BasePage {
Q_OBJECT
-public:
- explicit WorldListPage(
- BaseInstance *inst,
- std::shared_ptr<WorldList> worlds,
- QWidget *parent = 0
- );
+ public:
+ explicit WorldListPage(BaseInstance* inst, std::shared_ptr<WorldList> worlds, QWidget* parent = 0);
virtual ~WorldListPage();
- virtual QString displayName() const override
- {
- return tr("Worlds");
- }
- virtual QIcon icon() const override
- {
- return APPLICATION->getThemedIcon("worlds");
- }
- virtual QString id() const override
- {
- return "worlds";
- }
- virtual QString helpPage() const override
- {
- return "Worlds";
- }
+ virtual QString displayName() const override { return tr("Worlds"); }
+ virtual QIcon icon() const override { return APPLICATION->getThemedIcon("worlds"); }
+ virtual QString id() const override { return "worlds"; }
+ virtual QString helpPage() const override { return "Worlds"; }
virtual bool shouldDisplay() const override;
void retranslate() override;
virtual void openedImpl() override;
virtual void closedImpl() override;
-protected:
- bool eventFilter(QObject *obj, QEvent *ev) override;
- bool worldListFilter(QKeyEvent *ev);
- QMenu * createPopupMenu() override;
+ protected:
+ bool eventFilter(QObject* obj, QEvent* ev) override;
+ bool worldListFilter(QKeyEvent* ev);
+ QMenu* createPopupMenu() override;
-protected:
- BaseInstance *m_inst;
+ protected:
+ BaseInstance* m_inst;
-private:
+ private:
QModelIndex getSelectedWorld();
bool isWorldSafe(QModelIndex index);
- bool worldSafetyNagQuestion(const QString &actionType);
+ bool worldSafetyNagQuestion(const QString& actionType);
void mceditError();
-private:
- Ui::WorldListPage *ui;
+ private:
+ Ui::WorldListPage* ui;
std::shared_ptr<WorldList> m_worlds;
unique_qobject_ptr<LoggedProcess> m_mceditProcess;
bool m_mceditStarting = false;
std::shared_ptr<Setting> m_wide_bar_setting = nullptr;
-private slots:
+ private slots:
void on_actionCopy_Seed_triggered();
void on_actionMCEdit_triggered();
void on_actionRemove_triggered();
@@ -117,8 +99,8 @@ private slots:
void on_actionView_Folder_triggered();
void on_actionDatapacks_triggered();
void on_actionReset_Icon_triggered();
- void worldChanged(const QModelIndex &current, const QModelIndex &previous);
+ void worldChanged(const QModelIndex& current, const QModelIndex& previous);
void mceditState(LoggedProcess::State state);
- void ShowContextMenu(const QPoint &pos);
+ void ShowContextMenu(const QPoint& pos);
};
diff --git a/launcher/ui/pages/modplatform/CustomPage.cpp b/launcher/ui/pages/modplatform/CustomPage.cpp
index e164171a..4ac21b01 100644
--- a/launcher/ui/pages/modplatform/CustomPage.cpp
+++ b/launcher/ui/pages/modplatform/CustomPage.cpp
@@ -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
@@ -46,8 +46,7 @@
#include "minecraft/VanillaInstanceCreationTask.h"
#include "ui/dialogs/NewInstanceDialog.h"
-CustomPage::CustomPage(NewInstanceDialog *dialog, QWidget *parent)
- : QWidget(parent), dialog(dialog), ui(new Ui::CustomPage)
+CustomPage::CustomPage(NewInstanceDialog* dialog, QWidget* parent) : QWidget(parent), dialog(dialog), ui(new Ui::CustomPage)
{
ui->setupUi(this);
ui->tabWidget->tabBar()->hide();
@@ -68,19 +67,15 @@ CustomPage::CustomPage(NewInstanceDialog *dialog, QWidget *parent)
connect(ui->quiltFilter, &QRadioButton::toggled, this, &CustomPage::loaderFilterChanged);
connect(ui->liteLoaderFilter, &QRadioButton::toggled, this, &CustomPage::loaderFilterChanged);
connect(ui->loaderRefreshBtn, &QPushButton::clicked, this, &CustomPage::loaderRefresh);
-
}
void CustomPage::openedImpl()
{
- if(!initialized)
- {
+ if (!initialized) {
auto vlist = APPLICATION->metadataIndex()->get("net.minecraft");
ui->versionList->initialize(vlist.get());
initialized = true;
- }
- else
- {
+ } else {
suggestCurrent();
}
}
@@ -92,7 +87,7 @@ void CustomPage::refresh()
void CustomPage::loaderRefresh()
{
- if(ui->noneFilter->isChecked())
+ if (ui->noneFilter->isChecked())
return;
ui->loaderVersionList->loadList();
}
@@ -100,17 +95,17 @@ void CustomPage::loaderRefresh()
void CustomPage::filterChanged()
{
QStringList out;
- if(ui->alphaFilter->isChecked())
+ if (ui->alphaFilter->isChecked())
out << "(old_alpha)";
- if(ui->betaFilter->isChecked())
+ if (ui->betaFilter->isChecked())
out << "(old_beta)";
- if(ui->snapshotFilter->isChecked())
+ if (ui->snapshotFilter->isChecked())
out << "(snapshot)";
- if(ui->oldSnapshotFilter->isChecked())
+ if (ui->oldSnapshotFilter->isChecked())
out << "(old_snapshot)";
- if(ui->releaseFilter->isChecked())
+ if (ui->releaseFilter->isChecked())
out << "(release)";
- if(ui->experimentsFilter->isChecked())
+ if (ui->experimentsFilter->isChecked())
out << "(experiment)";
auto regexp = out.join('|');
ui->versionList->setFilter(BaseVersionList::TypeRole, new RegexpFilter(regexp, false));
@@ -119,49 +114,37 @@ void CustomPage::filterChanged()
void CustomPage::loaderFilterChanged()
{
QString minecraftVersion;
- if (m_selectedVersion)
- {
+ if (m_selectedVersion) {
minecraftVersion = m_selectedVersion->descriptor();
- }
- else
- {
- ui->loaderVersionList->setExactFilter(BaseVersionList::ParentVersionRole, "AAA"); // empty list
+ } else {
+ ui->loaderVersionList->setExactFilter(BaseVersionList::ParentVersionRole, "AAA"); // empty list
ui->loaderVersionList->setEmptyString(tr("No Minecraft version is selected."));
ui->loaderVersionList->setEmptyMode(VersionListView::String);
return;
}
- if(ui->noneFilter->isChecked())
- {
- ui->loaderVersionList->setExactFilter(BaseVersionList::ParentVersionRole, "AAA"); // empty list
+ if (ui->noneFilter->isChecked()) {
+ ui->loaderVersionList->setExactFilter(BaseVersionList::ParentVersionRole, "AAA"); // empty list
ui->loaderVersionList->setEmptyString(tr("No mod loader is selected."));
ui->loaderVersionList->setEmptyMode(VersionListView::String);
return;
- }
- else if(ui->forgeFilter->isChecked())
- {
+ } else if (ui->forgeFilter->isChecked()) {
ui->loaderVersionList->setExactFilter(BaseVersionList::ParentVersionRole, minecraftVersion);
m_selectedLoader = "net.minecraftforge";
- }
- else if(ui->fabricFilter->isChecked())
- {
+ } else if (ui->fabricFilter->isChecked()) {
// FIXME: dirty hack because the launcher is unaware of Fabric's dependencies
- if (Version(minecraftVersion) >= Version("1.14")) // Fabric/Quilt supported
+ if (Version(minecraftVersion) >= Version("1.14")) // Fabric/Quilt supported
ui->loaderVersionList->setExactFilter(BaseVersionList::ParentVersionRole, "");
- else // Fabric/Quilt unsupported
- ui->loaderVersionList->setExactFilter(BaseVersionList::ParentVersionRole, "AAA"); // clear list
+ else // Fabric/Quilt unsupported
+ ui->loaderVersionList->setExactFilter(BaseVersionList::ParentVersionRole, "AAA"); // clear list
m_selectedLoader = "net.fabricmc.fabric-loader";
- }
- else if(ui->quiltFilter->isChecked())
- {
+ } else if (ui->quiltFilter->isChecked()) {
// FIXME: dirty hack because the launcher is unaware of Quilt's dependencies (same as Fabric)
- if (Version(minecraftVersion) >= Version("1.14")) // Fabric/Quilt supported
+ if (Version(minecraftVersion) >= Version("1.14")) // Fabric/Quilt supported
ui->loaderVersionList->setExactFilter(BaseVersionList::ParentVersionRole, "");
- else // Fabric/Quilt unsupported
- ui->loaderVersionList->setExactFilter(BaseVersionList::ParentVersionRole, "AAA"); // clear list
+ else // Fabric/Quilt unsupported
+ ui->loaderVersionList->setExactFilter(BaseVersionList::ParentVersionRole, "AAA"); // clear list
m_selectedLoader = "org.quiltmc.quilt-loader";
- }
- else if(ui->liteLoaderFilter->isChecked())
- {
+ } else if (ui->liteLoaderFilter->isChecked()) {
ui->loaderVersionList->setExactFilter(BaseVersionList::ParentVersionRole, minecraftVersion);
m_selectedLoader = "com.mumfrey.liteloader";
}
@@ -204,25 +187,21 @@ QString CustomPage::selectedLoader() const
void CustomPage::suggestCurrent()
{
- if (!isOpened)
- {
+ if (!isOpened) {
return;
}
-
- if(!m_selectedVersion)
- {
+
+ if (!m_selectedVersion) {
dialog->setSuggestedPack();
return;
}
// There isn't a selected version if the version list is empty
- if(ui->loaderVersionList->selectedVersion() == nullptr)
+ if (ui->loaderVersionList->selectedVersion() == nullptr)
dialog->setSuggestedPack(m_selectedVersion->descriptor(), new VanillaCreationTask(m_selectedVersion));
- else
- {
+ else {
dialog->setSuggestedPack(m_selectedVersion->descriptor(),
- new VanillaCreationTask(m_selectedVersion, m_selectedLoader,
- m_selectedLoaderVersion));
+ new VanillaCreationTask(m_selectedVersion, m_selectedLoader, m_selectedLoaderVersion));
}
dialog->setSuggestedIcon("default");
}
diff --git a/launcher/ui/pages/modplatform/CustomPage.h b/launcher/ui/pages/modplatform/CustomPage.h
index 8b5a5011..c5d6d5af 100644
--- a/launcher/ui/pages/modplatform/CustomPage.h
+++ b/launcher/ui/pages/modplatform/CustomPage.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
@@ -37,40 +37,26 @@
#include <QWidget>
-#include "ui/pages/BasePage.h"
#include <Application.h>
#include "tasks/Task.h"
+#include "ui/pages/BasePage.h"
-namespace Ui
-{
+namespace Ui {
class CustomPage;
}
class NewInstanceDialog;
-class CustomPage : public QWidget, public BasePage
-{
+class CustomPage : public QWidget, public BasePage {
Q_OBJECT
-public:
- explicit CustomPage(NewInstanceDialog *dialog, QWidget *parent = 0);
+ public:
+ explicit CustomPage(NewInstanceDialog* dialog, QWidget* parent = 0);
virtual ~CustomPage();
- virtual QString displayName() const override
- {
- return tr("Custom");
- }
- virtual QIcon icon() const override
- {
- return APPLICATION->getThemedIcon("minecraft");
- }
- virtual QString id() const override
- {
- return "vanilla";
- }
- virtual QString helpPage() const override
- {
- return "Vanilla-platform";
- }
+ virtual QString displayName() const override { return tr("Custom"); }
+ virtual QIcon icon() const override { return APPLICATION->getThemedIcon("minecraft"); }
+ virtual QString id() const override { return "vanilla"; }
+ virtual QString helpPage() const override { return "Vanilla-platform"; }
virtual bool shouldDisplay() const override;
void retranslate() override;
@@ -80,23 +66,23 @@ public:
BaseVersion::Ptr selectedLoaderVersion() const;
QString selectedLoader() const;
-public slots:
+ public slots:
void setSelectedVersion(BaseVersion::Ptr version);
void setSelectedLoaderVersion(BaseVersion::Ptr version);
-private slots:
+ private slots:
void filterChanged();
void loaderFilterChanged();
-private:
+ private:
void refresh();
void loaderRefresh();
void suggestCurrent();
-private:
+ private:
bool initialized = false;
- NewInstanceDialog *dialog = nullptr;
- Ui::CustomPage *ui = nullptr;
+ NewInstanceDialog* dialog = nullptr;
+ Ui::CustomPage* ui = nullptr;
bool m_versionSetByUser = false;
BaseVersion::Ptr m_selectedVersion;
BaseVersion::Ptr m_selectedLoaderVersion;
diff --git a/launcher/ui/pages/modplatform/ImportPage.cpp b/launcher/ui/pages/modplatform/ImportPage.cpp
index 30196aad..ba53d033 100644
--- a/launcher/ui/pages/modplatform/ImportPage.cpp
+++ b/launcher/ui/pages/modplatform/ImportPage.cpp
@@ -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>
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
*
@@ -44,32 +44,24 @@
#include "InstanceImportTask.h"
-
-class UrlValidator : public QValidator
-{
-public:
+class UrlValidator : public QValidator {
+ public:
using QValidator::QValidator;
- State validate(QString &in, int &pos) const
+ State validate(QString& in, int& pos) const
{
const QUrl url(in);
- if (url.isValid() && !url.isRelative() && !url.isEmpty())
- {
+ if (url.isValid() && !url.isRelative() && !url.isEmpty()) {
return Acceptable;
- }
- else if (QFile::exists(in))
- {
+ } else if (QFile::exists(in)) {
return Acceptable;
- }
- else
- {
+ } else {
return Intermediate;
}
}
};
-ImportPage::ImportPage(NewInstanceDialog* dialog, QWidget *parent)
- : QWidget(parent), ui(new Ui::ImportPage), dialog(dialog)
+ImportPage::ImportPage(NewInstanceDialog* dialog, QWidget* parent) : QWidget(parent), ui(new Ui::ImportPage), dialog(dialog)
{
ui->setupUi(this);
ui->modpackEdit->setValidator(new UrlValidator(ui->modpackEdit));
@@ -98,16 +90,13 @@ void ImportPage::openedImpl()
void ImportPage::updateState()
{
- if(!isOpened)
- {
+ if (!isOpened) {
return;
}
- if(ui->modpackEdit->hasAcceptableInput())
- {
+ if (ui->modpackEdit->hasAcceptableInput()) {
QString input = ui->modpackEdit->text();
auto url = QUrl::fromUserInput(input);
- if(url.isLocalFile())
- {
+ if (url.isLocalFile()) {
// FIXME: actually do some validation of what's inside here... this is fake AF
QFileInfo fi(input);
@@ -116,28 +105,23 @@ void ImportPage::updateState()
// mrpack is a modrinth pack
bool isMRPack = fi.suffix() == "mrpack";
- if(fi.exists() && (isZip || isMRPack))
- {
+ if (fi.exists() && (isZip || isMRPack)) {
QFileInfo fi(url.fileName());
- dialog->setSuggestedPack(fi.completeBaseName(), new InstanceImportTask(url,this));
+ dialog->setSuggestedPack(fi.completeBaseName(), new InstanceImportTask(url, this));
dialog->setSuggestedIcon("default");
}
- }
- else
- {
- if(input.endsWith("?client=y")) {
+ } else {
+ if (input.endsWith("?client=y")) {
input.chop(9);
input.append("/file");
url = QUrl::fromUserInput(input);
}
// hook, line and sinker.
QFileInfo fi(url.fileName());
- dialog->setSuggestedPack(fi.completeBaseName(), new InstanceImportTask(url,this));
+ dialog->setSuggestedPack(fi.completeBaseName(), new InstanceImportTask(url, this));
dialog->setSuggestedIcon("default");
}
- }
- else
- {
+ } else {
dialog->setSuggestedPack();
}
}
@@ -154,29 +138,21 @@ void ImportPage::on_modpackBtn_clicked()
//: Option for filtering for *.mrpack files when importing
filter += ";;" + tr("Modrinth pack") + " (*.mrpack)";
const QUrl url = QFileDialog::getOpenFileUrl(this, tr("Choose modpack"), modpackUrl(), filter);
- if (url.isValid())
- {
- if (url.isLocalFile())
- {
+ if (url.isValid()) {
+ if (url.isLocalFile()) {
ui->modpackEdit->setText(url.toLocalFile());
- }
- else
- {
+ } else {
ui->modpackEdit->setText(url.toString());
}
}
}
-
QUrl ImportPage::modpackUrl() const
{
const QUrl url(ui->modpackEdit->text());
- if (url.isValid() && !url.isRelative() && !url.host().isEmpty())
- {
+ if (url.isValid() && !url.isRelative() && !url.host().isEmpty()) {
return url;
- }
- else
- {
+ } else {
return QUrl::fromLocalFile(ui->modpackEdit->text());
}
}
diff --git a/launcher/ui/pages/modplatform/ImportPage.h b/launcher/ui/pages/modplatform/ImportPage.h
index c2acb92d..d846d566 100644
--- a/launcher/ui/pages/modplatform/ImportPage.h
+++ b/launcher/ui/pages/modplatform/ImportPage.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
@@ -37,55 +37,40 @@
#include <QWidget>
-#include "ui/pages/BasePage.h"
#include <Application.h>
#include "tasks/Task.h"
+#include "ui/pages/BasePage.h"
-namespace Ui
-{
+namespace Ui {
class ImportPage;
}
class NewInstanceDialog;
-class ImportPage : public QWidget, public BasePage
-{
+class ImportPage : public QWidget, public BasePage {
Q_OBJECT
-public:
- explicit ImportPage(NewInstanceDialog* dialog, QWidget *parent = 0);
+ public:
+ explicit ImportPage(NewInstanceDialog* dialog, QWidget* parent = 0);
virtual ~ImportPage();
- virtual QString displayName() const override
- {
- return tr("Import");
- }
- virtual QIcon icon() const override
- {
- return APPLICATION->getThemedIcon("viewfolder");
- }
- virtual QString id() const override
- {
- return "import";
- }
- virtual QString helpPage() const override
- {
- return "Zip-import";
- }
+ virtual QString displayName() const override { return tr("Import"); }
+ virtual QIcon icon() const override { return APPLICATION->getThemedIcon("viewfolder"); }
+ virtual QString id() const override { return "import"; }
+ virtual QString helpPage() const override { return "Zip-import"; }
virtual bool shouldDisplay() const override;
void retranslate() override;
- void setUrl(const QString & url);
+ void setUrl(const QString& url);
void openedImpl() override;
-private slots:
+ private slots:
void on_modpackBtn_clicked();
void updateState();
-private:
+ private:
QUrl modpackUrl() const;
-private:
- Ui::ImportPage *ui = nullptr;
+ private:
+ Ui::ImportPage* ui = nullptr;
NewInstanceDialog* dialog = nullptr;
};
-
diff --git a/launcher/ui/pages/modplatform/ResourcePackPage.cpp b/launcher/ui/pages/modplatform/ResourcePackPage.cpp
index 52fb4802..2a4d0281 100644
--- a/launcher/ui/pages/modplatform/ResourcePackPage.cpp
+++ b/launcher/ui/pages/modplatform/ResourcePackPage.cpp
@@ -13,8 +13,7 @@
namespace ResourceDownload {
-ResourcePackResourcePage::ResourcePackResourcePage(ResourceDownloadDialog* dialog, BaseInstance& instance)
- : ResourcePage(dialog, instance)
+ResourcePackResourcePage::ResourcePackResourcePage(ResourceDownloadDialog* dialog, BaseInstance& instance) : ResourcePage(dialog, instance)
{
connect(m_ui->searchButton, &QPushButton::clicked, this, &ResourcePackResourcePage::triggerSearch);
connect(m_ui->packView, &QListView::doubleClicked, this, &ResourcePackResourcePage::onResourceSelected);
@@ -38,7 +37,8 @@ QMap<QString, QString> ResourcePackResourcePage::urlHandlers() const
{
QMap<QString, QString> map;
map.insert(QRegularExpression::anchoredPattern("(?:www\\.)?modrinth\\.com\\/resourcepack\\/([^\\/]+)\\/?"), "modrinth");
- map.insert(QRegularExpression::anchoredPattern("(?:www\\.)?curseforge\\.com\\/minecraft\\/texture-packs\\/([^\\/]+)\\/?"), "curseforge");
+ map.insert(QRegularExpression::anchoredPattern("(?:www\\.)?curseforge\\.com\\/minecraft\\/texture-packs\\/([^\\/]+)\\/?"),
+ "curseforge");
map.insert(QRegularExpression::anchoredPattern("minecraft\\.curseforge\\.com\\/projects\\/([^\\/]+)\\/?"), "curseforge");
return map;
}
diff --git a/launcher/ui/pages/modplatform/ResourcePackPage.h b/launcher/ui/pages/modplatform/ResourcePackPage.h
index 8c5cf08b..6015aec0 100644
--- a/launcher/ui/pages/modplatform/ResourcePackPage.h
+++ b/launcher/ui/pages/modplatform/ResourcePackPage.h
@@ -4,8 +4,8 @@
#pragma once
-#include "ui/pages/modplatform/ResourcePage.h"
#include "ui/pages/modplatform/ResourcePackModel.h"
+#include "ui/pages/modplatform/ResourcePage.h"
namespace Ui {
class ResourcePage;
diff --git a/launcher/ui/pages/modplatform/ResourcePage.cpp b/launcher/ui/pages/modplatform/ResourcePage.cpp
index 3619c51a..2925ec87 100644
--- a/launcher/ui/pages/modplatform/ResourcePage.cpp
+++ b/launcher/ui/pages/modplatform/ResourcePage.cpp
@@ -104,6 +104,7 @@ void ResourcePage::openedImpl()
updateSelectionButton();
triggerSearch();
+ m_ui->searchEdit->setFocus();
}
auto ResourcePage::eventFilter(QObject* watched, QEvent* event) -> bool
diff --git a/launcher/ui/pages/modplatform/TexturePackPage.h b/launcher/ui/pages/modplatform/TexturePackPage.h
index 0bdce2f9..948e5286 100644
--- a/launcher/ui/pages/modplatform/TexturePackPage.h
+++ b/launcher/ui/pages/modplatform/TexturePackPage.h
@@ -4,10 +4,10 @@
#pragma once
-#include "ui_ResourcePage.h"
#include "ui/dialogs/ResourceDownloadDialog.h"
#include "ui/pages/modplatform/ResourcePackPage.h"
#include "ui/pages/modplatform/TexturePackModel.h"
+#include "ui_ResourcePage.h"
namespace Ui {
class ResourcePage;
@@ -39,8 +39,7 @@ class TexturePackResourcePage : public ResourcePackResourcePage {
[[nodiscard]] inline QString resourceString() const override { return tr("texture pack"); }
protected:
- TexturePackResourcePage(TexturePackDownloadDialog* dialog, BaseInstance& instance)
- : ResourcePackResourcePage(dialog, instance)
+ TexturePackResourcePage(TexturePackDownloadDialog* dialog, BaseInstance& instance) : ResourcePackResourcePage(dialog, instance)
{
connect(m_ui->searchButton, &QPushButton::clicked, this, &TexturePackResourcePage::triggerSearch);
connect(m_ui->packView, &QListView::doubleClicked, this, &TexturePackResourcePage::onResourceSelected);
diff --git a/launcher/ui/pages/modplatform/atlauncher/AtlFilterModel.cpp b/launcher/ui/pages/modplatform/atlauncher/AtlFilterModel.cpp
index 0887ebee..9cd5eed5 100644
--- a/launcher/ui/pages/modplatform/atlauncher/AtlFilterModel.cpp
+++ b/launcher/ui/pages/modplatform/atlauncher/AtlFilterModel.cpp
@@ -18,14 +18,14 @@
#include <QDebug>
-#include <modplatform/atlauncher/ATLPackIndex.h>
#include <Version.h>
+#include <modplatform/atlauncher/ATLPackIndex.h>
#include "StringUtils.h"
namespace Atl {
-FilterModel::FilterModel(QObject *parent) : QSortFilterProxyModel(parent)
+FilterModel::FilterModel(QObject* parent) : QSortFilterProxyModel(parent)
{
currentSorting = Sorting::ByPopularity;
sortings.insert(tr("Sort by Popularity"), Sorting::ByPopularity);
@@ -62,7 +62,7 @@ void FilterModel::setSearchTerm(const QString term)
invalidate();
}
-bool FilterModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
+bool FilterModel::filterAcceptsRow(int sourceRow, const QModelIndex& sourceParent) const
{
if (searchTerm.isEmpty()) {
return true;
@@ -73,20 +73,18 @@ bool FilterModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParen
return pack.name.contains(searchTerm, Qt::CaseInsensitive);
}
-bool FilterModel::lessThan(const QModelIndex &left, const QModelIndex &right) const
+bool FilterModel::lessThan(const QModelIndex& left, const QModelIndex& right) const
{
ATLauncher::IndexedPack leftPack = sourceModel()->data(left, Qt::UserRole).value<ATLauncher::IndexedPack>();
ATLauncher::IndexedPack rightPack = sourceModel()->data(right, Qt::UserRole).value<ATLauncher::IndexedPack>();
if (currentSorting == ByPopularity) {
return leftPack.position > rightPack.position;
- }
- else if (currentSorting == ByGameVersion) {
+ } else if (currentSorting == ByGameVersion) {
Version lv(leftPack.versions.at(0).minecraft);
Version rv(rightPack.versions.at(0).minecraft);
return lv < rv;
- }
- else if (currentSorting == ByName) {
+ } else if (currentSorting == ByName) {
return StringUtils::naturalCompare(leftPack.name, rightPack.name, Qt::CaseSensitive) >= 0;
}
@@ -95,4 +93,4 @@ bool FilterModel::lessThan(const QModelIndex &left, const QModelIndex &right) co
return true;
}
-}
+} // namespace Atl
diff --git a/launcher/ui/pages/modplatform/atlauncher/AtlFilterModel.h b/launcher/ui/pages/modplatform/atlauncher/AtlFilterModel.h
index 5235ccdb..0ab46ed2 100644
--- a/launcher/ui/pages/modplatform/atlauncher/AtlFilterModel.h
+++ b/launcher/ui/pages/modplatform/atlauncher/AtlFilterModel.h
@@ -20,10 +20,9 @@
namespace Atl {
-class FilterModel : public QSortFilterProxyModel
-{
+class FilterModel : public QSortFilterProxyModel {
Q_OBJECT
-public:
+ public:
FilterModel(QObject* parent = Q_NULLPTR);
enum Sorting {
ByPopularity,
@@ -36,15 +35,14 @@ public:
Sorting getCurrentSorting();
void setSearchTerm(QString term);
-protected:
- bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
- bool lessThan(const QModelIndex &left, const QModelIndex &right) const override;
+ protected:
+ bool filterAcceptsRow(int sourceRow, const QModelIndex& sourceParent) const override;
+ bool lessThan(const QModelIndex& left, const QModelIndex& right) const override;
-private:
+ private:
QMap<QString, Sorting> sortings;
Sorting currentSorting;
QString searchTerm;
-
};
-}
+} // namespace Atl
diff --git a/launcher/ui/pages/modplatform/atlauncher/AtlOptionalModDialog.cpp b/launcher/ui/pages/modplatform/atlauncher/AtlOptionalModDialog.cpp
index 7b61daa7..62e406d3 100644
--- a/launcher/ui/pages/modplatform/atlauncher/AtlOptionalModDialog.cpp
+++ b/launcher/ui/pages/modplatform/atlauncher/AtlOptionalModDialog.cpp
@@ -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
@@ -38,15 +38,13 @@
#include <QInputDialog>
#include <QMessageBox>
+#include "Application.h"
#include "BuildConfig.h"
#include "Json.h"
#include "modplatform/atlauncher/ATLShareCode.h"
-#include "Application.h"
AtlOptionalModListModel::AtlOptionalModListModel(QWidget* parent, ATLauncher::PackVersion version, QVector<ATLauncher::VersionMod> mods)
- : QAbstractListModel(parent)
- , m_version(version)
- , m_mods(mods)
+ : QAbstractListModel(parent), m_version(version), m_mods(mods)
{
// fill mod index
for (int i = 0; i < m_mods.size(); i++) {
@@ -62,7 +60,8 @@ AtlOptionalModListModel::AtlOptionalModListModel(QWidget* parent, ATLauncher::Pa
}
}
-QVector<QString> AtlOptionalModListModel::getResult() {
+QVector<QString> AtlOptionalModListModel::getResult()
+{
QVector<QString> result;
for (const auto& mod : m_mods) {
@@ -74,16 +73,19 @@ QVector<QString> AtlOptionalModListModel::getResult() {
return result;
}
-int AtlOptionalModListModel::rowCount(const QModelIndex &parent) const {
+int AtlOptionalModListModel::rowCount(const QModelIndex& parent) const
+{
return parent.isValid() ? 0 : m_mods.size();
}
-int AtlOptionalModListModel::columnCount(const QModelIndex &parent) const {
+int AtlOptionalModListModel::columnCount(const QModelIndex& parent) const
+{
// Enabled, Name, Description
return parent.isValid() ? 0 : 3;
}
-QVariant AtlOptionalModListModel::data(const QModelIndex &index, int role) const {
+QVariant AtlOptionalModListModel::data(const QModelIndex& index, int role) const
+{
auto row = index.row();
auto mod = m_mods.at(row);
@@ -94,18 +96,15 @@ QVariant AtlOptionalModListModel::data(const QModelIndex &index, int role) const
if (index.column() == DescriptionColumn) {
return mod.description;
}
- }
- else if (role == Qt::ToolTipRole) {
+ } else if (role == Qt::ToolTipRole) {
if (index.column() == DescriptionColumn) {
return mod.description;
}
- }
- else if (role == Qt::ForegroundRole) {
+ } else if (role == Qt::ForegroundRole) {
if (!mod.colour.isEmpty() && m_version.colours.contains(mod.colour)) {
return QColor(QString("#%1").arg(m_version.colours[mod.colour]));
}
- }
- else if (role == Qt::CheckStateRole) {
+ } else if (role == Qt::CheckStateRole) {
if (index.column() == EnabledColumn) {
return m_selection[mod.name] ? Qt::Checked : Qt::Unchecked;
}
@@ -114,7 +113,8 @@ QVariant AtlOptionalModListModel::data(const QModelIndex &index, int role) const
return {};
}
-bool AtlOptionalModListModel::setData(const QModelIndex &index, const QVariant &value, int role) {
+bool AtlOptionalModListModel::setData(const QModelIndex& index, const QVariant& value, int role)
+{
if (role == Qt::CheckStateRole) {
auto row = index.row();
auto mod = m_mods.at(row);
@@ -126,7 +126,8 @@ bool AtlOptionalModListModel::setData(const QModelIndex &index, const QVariant &
return false;
}
-QVariant AtlOptionalModListModel::headerData(int section, Qt::Orientation orientation, int role) const {
+QVariant AtlOptionalModListModel::headerData(int section, Qt::Orientation orientation, int role) const
+{
if (role == Qt::DisplayRole && orientation == Qt::Horizontal) {
switch (section) {
case EnabledColumn:
@@ -141,7 +142,8 @@ QVariant AtlOptionalModListModel::headerData(int section, Qt::Orientation orient
return {};
}
-Qt::ItemFlags AtlOptionalModListModel::flags(const QModelIndex &index) const {
+Qt::ItemFlags AtlOptionalModListModel::flags(const QModelIndex& index) const
+{
auto flags = QAbstractListModel::flags(index);
if (index.isValid() && index.column() == EnabledColumn) {
flags |= Qt::ItemIsUserCheckable;
@@ -149,23 +151,23 @@ Qt::ItemFlags AtlOptionalModListModel::flags(const QModelIndex &index) const {
return flags;
}
-void AtlOptionalModListModel::useShareCode(const QString& code) {
+void AtlOptionalModListModel::useShareCode(const QString& code)
+{
m_jobPtr.reset(new NetJob("Atl::Request", APPLICATION->network()));
auto url = QString(BuildConfig.ATL_API_BASE_URL + "share-codes/" + code);
m_jobPtr->addNetAction(Net::Download::makeByteArray(QUrl(url), m_response));
- connect(m_jobPtr.get(), &NetJob::succeeded,
- this, &AtlOptionalModListModel::shareCodeSuccess);
- connect(m_jobPtr.get(), &NetJob::failed,
- this, &AtlOptionalModListModel::shareCodeFailure);
+ connect(m_jobPtr.get(), &NetJob::succeeded, this, &AtlOptionalModListModel::shareCodeSuccess);
+ connect(m_jobPtr.get(), &NetJob::failed, this, &AtlOptionalModListModel::shareCodeFailure);
m_jobPtr->start();
}
-void AtlOptionalModListModel::shareCodeSuccess() {
+void AtlOptionalModListModel::shareCodeSuccess()
+{
m_jobPtr.reset();
- QJsonParseError parse_error {};
+ QJsonParseError parse_error{};
auto doc = QJsonDocument::fromJson(*m_response, &parse_error);
if (parse_error.error != QJsonParseError::NoError) {
qWarning() << "Error while parsing JSON response from ATL at " << parse_error.offset << " reason: " << parse_error.errorString();
@@ -177,8 +179,7 @@ void AtlOptionalModListModel::shareCodeSuccess() {
ATLauncher::ShareCodeResponse response;
try {
ATLauncher::loadShareCodeResponse(response, obj);
- }
- catch (const JSONValidationError& e) {
+ } catch (const JSONValidationError& e) {
qDebug() << QString::fromUtf8(*m_response);
qWarning() << "Error while reading response from ATLauncher: " << e.cause();
return;
@@ -202,44 +203,44 @@ void AtlOptionalModListModel::shareCodeSuccess() {
m_selection[mod.name] = mod.selected;
}
- emit dataChanged(AtlOptionalModListModel::index(0, EnabledColumn),
- AtlOptionalModListModel::index(m_mods.size() - 1, EnabledColumn));
+ emit dataChanged(AtlOptionalModListModel::index(0, EnabledColumn), AtlOptionalModListModel::index(m_mods.size() - 1, EnabledColumn));
}
-void AtlOptionalModListModel::shareCodeFailure(const QString& reason) {
+void AtlOptionalModListModel::shareCodeFailure(const QString& reason)
+{
m_jobPtr.reset();
// fixme: plumb in an error message
}
-void AtlOptionalModListModel::selectRecommended() {
+void AtlOptionalModListModel::selectRecommended()
+{
for (const auto& mod : m_mods) {
m_selection[mod.name] = mod.recommended;
}
- emit dataChanged(AtlOptionalModListModel::index(0, EnabledColumn),
- AtlOptionalModListModel::index(m_mods.size() - 1, EnabledColumn));
+ emit dataChanged(AtlOptionalModListModel::index(0, EnabledColumn), AtlOptionalModListModel::index(m_mods.size() - 1, EnabledColumn));
}
-void AtlOptionalModListModel::clearAll() {
+void AtlOptionalModListModel::clearAll()
+{
for (const auto& mod : m_mods) {
m_selection[mod.name] = false;
}
- emit dataChanged(AtlOptionalModListModel::index(0, EnabledColumn),
- AtlOptionalModListModel::index(m_mods.size() - 1, EnabledColumn));
+ emit dataChanged(AtlOptionalModListModel::index(0, EnabledColumn), AtlOptionalModListModel::index(m_mods.size() - 1, EnabledColumn));
}
-void AtlOptionalModListModel::toggleMod(ATLauncher::VersionMod mod, int index) {
+void AtlOptionalModListModel::toggleMod(ATLauncher::VersionMod mod, int index)
+{
auto enable = !m_selection[mod.name];
// If there is a warning for the mod, display that first (if we would be enabling the mod)
if (enable && !mod.warning.isEmpty() && m_version.warnings.contains(mod.warning)) {
- auto message = QString("%1<br><br>%2")
- .arg(m_version.warnings[mod.warning], tr("Are you sure that you want to enable this mod?"));
+ auto message = QString("%1<br><br>%2").arg(m_version.warnings[mod.warning], tr("Are you sure that you want to enable this mod?"));
// fixme: avoid casting here
- auto result = QMessageBox::warning((QWidget*) this->parent(), tr("Warning"), message, QMessageBox::Yes | QMessageBox::No);
+ auto result = QMessageBox::warning((QWidget*)this->parent(), tr("Warning"), message, QMessageBox::Yes | QMessageBox::No);
if (result != QMessageBox::Yes) {
return;
}
@@ -248,15 +249,18 @@ void AtlOptionalModListModel::toggleMod(ATLauncher::VersionMod mod, int index) {
setMod(mod, index, enable);
}
-void AtlOptionalModListModel::setMod(ATLauncher::VersionMod mod, int index, bool enable, bool shouldEmit) {
- if (m_selection[mod.name] == enable) return;
+void AtlOptionalModListModel::setMod(ATLauncher::VersionMod mod, int index, bool enable, bool shouldEmit)
+{
+ if (m_selection[mod.name] == enable)
+ return;
m_selection[mod.name] = enable;
// disable other mods in the group, if applicable
if (enable && !mod.group.isEmpty()) {
for (int i = 0; i < m_mods.size(); i++) {
- if (index == i) continue;
+ if (index == i)
+ continue;
auto other = m_mods.at(i);
if (mod.group == other.group) {
@@ -281,8 +285,7 @@ void AtlOptionalModListModel::setMod(ATLauncher::VersionMod mod, int index, bool
if (enable) {
dependants.append(mod.name);
- }
- else {
+ } else {
dependants.removeAll(mod.name);
// if there are no longer any dependents, let's disable the mod
@@ -304,14 +307,12 @@ void AtlOptionalModListModel::setMod(ATLauncher::VersionMod mod, int index, bool
}
if (shouldEmit) {
- emit dataChanged(AtlOptionalModListModel::index(index, EnabledColumn),
- AtlOptionalModListModel::index(index, EnabledColumn));
+ emit dataChanged(AtlOptionalModListModel::index(index, EnabledColumn), AtlOptionalModListModel::index(index, EnabledColumn));
}
}
AtlOptionalModDialog::AtlOptionalModDialog(QWidget* parent, ATLauncher::PackVersion version, QVector<ATLauncher::VersionMod> mods)
- : QDialog(parent)
- , ui(new Ui::AtlOptionalModDialog)
+ : QDialog(parent), ui(new Ui::AtlOptionalModDialog)
{
ui->setupUi(this);
@@ -319,35 +320,24 @@ AtlOptionalModDialog::AtlOptionalModDialog(QWidget* parent, ATLauncher::PackVers
ui->treeView->setModel(listModel);
ui->treeView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
- ui->treeView->header()->setSectionResizeMode(
- AtlOptionalModListModel::NameColumn, QHeaderView::ResizeToContents);
- ui->treeView->header()->setSectionResizeMode(
- AtlOptionalModListModel::DescriptionColumn, QHeaderView::Stretch);
-
- connect(ui->shareCodeButton, &QPushButton::clicked,
- this, &AtlOptionalModDialog::useShareCode);
- connect(ui->selectRecommendedButton, &QPushButton::clicked,
- listModel, &AtlOptionalModListModel::selectRecommended);
- connect(ui->clearAllButton, &QPushButton::clicked,
- listModel, &AtlOptionalModListModel::clearAll);
- connect(ui->installButton, &QPushButton::clicked,
- this, &QDialog::accept);
+ ui->treeView->header()->setSectionResizeMode(AtlOptionalModListModel::NameColumn, QHeaderView::ResizeToContents);
+ ui->treeView->header()->setSectionResizeMode(AtlOptionalModListModel::DescriptionColumn, QHeaderView::Stretch);
+
+ connect(ui->shareCodeButton, &QPushButton::clicked, this, &AtlOptionalModDialog::useShareCode);
+ connect(ui->selectRecommendedButton, &QPushButton::clicked, listModel, &AtlOptionalModListModel::selectRecommended);
+ connect(ui->clearAllButton, &QPushButton::clicked, listModel, &AtlOptionalModListModel::clearAll);
+ connect(ui->installButton, &QPushButton::clicked, this, &QDialog::accept);
}
-AtlOptionalModDialog::~AtlOptionalModDialog() {
+AtlOptionalModDialog::~AtlOptionalModDialog()
+{
delete ui;
}
-void AtlOptionalModDialog::useShareCode() {
+void AtlOptionalModDialog::useShareCode()
+{
bool ok;
- auto shareCode = QInputDialog::getText(
- this,
- tr("Select a share code"),
- tr("Share code:"),
- QLineEdit::Normal,
- "",
- &ok
- );
+ auto shareCode = QInputDialog::getText(this, tr("Select a share code"), tr("Share code:"), QLineEdit::Normal, "", &ok);
if (!ok) {
// If the user cancels the dialog, we don't need to show any error dialogs.
diff --git a/launcher/ui/pages/modplatform/atlauncher/AtlOptionalModDialog.h b/launcher/ui/pages/modplatform/atlauncher/AtlOptionalModDialog.h
index 639f0d48..72a946da 100644
--- a/launcher/ui/pages/modplatform/atlauncher/AtlOptionalModDialog.h
+++ b/launcher/ui/pages/modplatform/atlauncher/AtlOptionalModDialog.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
@@ -35,8 +35,8 @@
#pragma once
-#include <QDialog>
#include <QAbstractListModel>
+#include <QDialog>
#include "modplatform/atlauncher/ATLPackIndex.h"
#include "net/NetJob.h"
@@ -48,37 +48,36 @@ class AtlOptionalModDialog;
class AtlOptionalModListModel : public QAbstractListModel {
Q_OBJECT
-public:
- enum Columns
- {
+ public:
+ enum Columns {
EnabledColumn = 0,
NameColumn,
DescriptionColumn,
};
- AtlOptionalModListModel(QWidget *parent, ATLauncher::PackVersion version, QVector<ATLauncher::VersionMod> mods);
+ AtlOptionalModListModel(QWidget* parent, ATLauncher::PackVersion version, QVector<ATLauncher::VersionMod> mods);
QVector<QString> getResult();
- int rowCount(const QModelIndex &parent) const override;
- int columnCount(const QModelIndex &parent) const override;
+ int rowCount(const QModelIndex& parent) const override;
+ int columnCount(const QModelIndex& parent) const override;
- QVariant data(const QModelIndex &index, int role) const override;
- bool setData(const QModelIndex &index, const QVariant &value, int role) override;
+ QVariant data(const QModelIndex& index, int role) const override;
+ bool setData(const QModelIndex& index, const QVariant& value, int role) override;
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
- Qt::ItemFlags flags(const QModelIndex &index) const override;
+ Qt::ItemFlags flags(const QModelIndex& index) const override;
void useShareCode(const QString& code);
-public slots:
+ public slots:
void shareCodeSuccess();
void shareCodeFailure(const QString& reason);
void selectRecommended();
void clearAll();
-private:
+ private:
void toggleMod(ATLauncher::VersionMod mod, int index);
void setMod(ATLauncher::VersionMod mod, int index, bool enable, bool shouldEmit = true);
@@ -97,18 +96,16 @@ private:
class AtlOptionalModDialog : public QDialog {
Q_OBJECT
-public:
- AtlOptionalModDialog(QWidget *parent, ATLauncher::PackVersion version, QVector<ATLauncher::VersionMod> mods);
+ public:
+ AtlOptionalModDialog(QWidget* parent, ATLauncher::PackVersion version, QVector<ATLauncher::VersionMod> mods);
~AtlOptionalModDialog() override;
- QVector<QString> getResult() {
- return listModel->getResult();
- }
+ QVector<QString> getResult() { return listModel->getResult(); }
void useShareCode();
-private:
- Ui::AtlOptionalModDialog *ui;
+ private:
+ Ui::AtlOptionalModDialog* ui;
- AtlOptionalModListModel *listModel;
+ AtlOptionalModListModel* listModel;
};
diff --git a/launcher/ui/pages/modplatform/atlauncher/AtlPage.cpp b/launcher/ui/pages/modplatform/atlauncher/AtlPage.cpp
index 87544445..4c9dec58 100644
--- a/launcher/ui/pages/modplatform/atlauncher/AtlPage.cpp
+++ b/launcher/ui/pages/modplatform/atlauncher/AtlPage.cpp
@@ -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
@@ -46,10 +46,7 @@
#include <QMessageBox>
-AtlPage::AtlPage(NewInstanceDialog* dialog, QWidget* parent)
- : QWidget(parent)
- , ui(new Ui::AtlPage)
- , dialog(dialog)
+AtlPage::AtlPage(NewInstanceDialog* dialog, QWidget* parent) : QWidget(parent), ui(new Ui::AtlPage), dialog(dialog)
{
ui->setupUi(this);
@@ -65,8 +62,7 @@ AtlPage::AtlPage(NewInstanceDialog* dialog, QWidget* parent)
ui->versionSelectionBox->view()->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
ui->versionSelectionBox->view()->parentWidget()->setMaximumHeight(300);
- for(int i = 0; i < filterModel->getAvailableSortings().size(); i++)
- {
+ for (int i = 0; i < filterModel->getAvailableSortings().size(); i++) {
ui->sortByBox->addItem(filterModel->getAvailableSortings().keys().at(i));
}
ui->sortByBox->setCurrentText(filterModel->translateCurrentSorting());
@@ -94,8 +90,7 @@ void AtlPage::retranslate()
void AtlPage::openedImpl()
{
- if(!initialized)
- {
+ if (!initialized) {
listModel->request();
initialized = true;
}
@@ -105,13 +100,11 @@ void AtlPage::openedImpl()
void AtlPage::suggestCurrent()
{
- if(!isOpened)
- {
+ if (!isOpened) {
return;
}
- if (selectedVersion.isEmpty())
- {
+ if (selectedVersion.isEmpty()) {
dialog->setSuggestedPack();
return;
}
@@ -121,10 +114,8 @@ void AtlPage::suggestCurrent()
auto editedLogoName = selected.safeName;
auto url = QString(BuildConfig.ATL_DOWNLOAD_SERVER_URL + "launcher/images/%1.png").arg(selected.safeName.toLower());
- listModel->getLogo(selected.safeName, url, [this, editedLogoName](QString logo)
- {
- dialog->setSuggestedIconFromFile(logo, editedLogoName);
- });
+ listModel->getLogo(selected.safeName, url,
+ [this, editedLogoName](QString logo) { dialog->setSuggestedIconFromFile(logo, editedLogoName); });
}
void AtlPage::triggerSearch()
@@ -142,10 +133,8 @@ void AtlPage::onSelectionChanged(QModelIndex first, QModelIndex second)
{
ui->versionSelectionBox->clear();
- if(!first.isValid())
- {
- if(isOpened)
- {
+ if (!first.isValid()) {
+ if (isOpened) {
dialog->setSuggestedPack();
}
return;
@@ -155,7 +144,7 @@ void AtlPage::onSelectionChanged(QModelIndex first, QModelIndex second)
ui->packDescription->setHtml(selected.description.replace("\n", "<br>"));
- for(const auto& version : selected.versions) {
+ for (const auto& version : selected.versions) {
ui->versionSelectionBox->addItem(version.version);
}
@@ -164,8 +153,7 @@ void AtlPage::onSelectionChanged(QModelIndex first, QModelIndex second)
void AtlPage::onVersionSelectionChanged(QString data)
{
- if(data.isNull() || data.isEmpty())
- {
+ if (data.isNull() || data.isEmpty()) {
selectedVersion = "";
return;
}
diff --git a/launcher/ui/pages/modplatform/atlauncher/AtlPage.h b/launcher/ui/pages/modplatform/atlauncher/AtlPage.h
index 1b3b15c1..6bc44964 100644
--- a/launcher/ui/pages/modplatform/atlauncher/AtlPage.h
+++ b/launcher/ui/pages/modplatform/atlauncher/AtlPage.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
@@ -38,52 +38,38 @@
#include "AtlFilterModel.h"
#include "AtlListModel.h"
-#include <QWidget>
#include <modplatform/atlauncher/ATLPackInstallTask.h>
+#include <QWidget>
#include "Application.h"
-#include "ui/pages/BasePage.h"
#include "tasks/Task.h"
+#include "ui/pages/BasePage.h"
-namespace Ui
-{
- class AtlPage;
+namespace Ui {
+class AtlPage;
}
class NewInstanceDialog;
-class AtlPage : public QWidget, public BasePage
-{
-Q_OBJECT
+class AtlPage : public QWidget, public BasePage {
+ Q_OBJECT
-public:
- explicit AtlPage(NewInstanceDialog* dialog, QWidget *parent = 0);
+ public:
+ explicit AtlPage(NewInstanceDialog* dialog, QWidget* parent = 0);
virtual ~AtlPage();
- virtual QString displayName() const override
- {
- return "ATLauncher";
- }
- virtual QIcon icon() const override
- {
- return APPLICATION->getThemedIcon("atlauncher");
- }
- virtual QString id() const override
- {
- return "atl";
- }
- virtual QString helpPage() const override
- {
- return "ATL-platform";
- }
+ virtual QString displayName() const override { return "ATLauncher"; }
+ virtual QIcon icon() const override { return APPLICATION->getThemedIcon("atlauncher"); }
+ virtual QString id() const override { return "atl"; }
+ virtual QString helpPage() const override { return "ATL-platform"; }
virtual bool shouldDisplay() const override;
void retranslate() override;
void openedImpl() override;
-private:
+ private:
void suggestCurrent();
-private slots:
+ private slots:
void triggerSearch();
void onSortingSelectionChanged(QString data);
@@ -91,8 +77,8 @@ private slots:
void onSelectionChanged(QModelIndex first, QModelIndex second);
void onVersionSelectionChanged(QString data);
-private:
- Ui::AtlPage *ui = nullptr;
+ private:
+ Ui::AtlPage* ui = nullptr;
NewInstanceDialog* dialog = nullptr;
Atl::ListModel* listModel = nullptr;
Atl::FilterModel* filterModel = nullptr;
diff --git a/launcher/ui/pages/modplatform/atlauncher/AtlUserInteractionSupportImpl.cpp b/launcher/ui/pages/modplatform/atlauncher/AtlUserInteractionSupportImpl.cpp
index 3d2d568a..0c725785 100644
--- a/launcher/ui/pages/modplatform/atlauncher/AtlUserInteractionSupportImpl.cpp
+++ b/launcher/ui/pages/modplatform/atlauncher/AtlUserInteractionSupportImpl.cpp
@@ -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
@@ -33,17 +33,16 @@
* limitations under the License.
*/
-#include <QMessageBox>
#include "AtlUserInteractionSupportImpl.h"
+#include <QMessageBox>
#include "AtlOptionalModDialog.h"
#include "ui/dialogs/VersionSelectDialog.h"
-AtlUserInteractionSupportImpl::AtlUserInteractionSupportImpl(QWidget *parent) : m_parent(parent)
-{
-}
+AtlUserInteractionSupportImpl::AtlUserInteractionSupportImpl(QWidget* parent) : m_parent(parent) {}
-std::optional<QVector<QString>> AtlUserInteractionSupportImpl::chooseOptionalMods(ATLauncher::PackVersion version, QVector<ATLauncher::VersionMod> mods)
+std::optional<QVector<QString>> AtlUserInteractionSupportImpl::chooseOptionalMods(ATLauncher::PackVersion version,
+ QVector<ATLauncher::VersionMod> mods)
{
AtlOptionalModDialog optionalModDialog(m_parent, version, mods);
auto result = optionalModDialog.exec();
@@ -59,8 +58,7 @@ QString AtlUserInteractionSupportImpl::chooseVersion(Meta::VersionList::Ptr vlis
if (minecraftVersion != nullptr) {
vselect.setExactFilter(BaseVersionList::ParentVersionRole, minecraftVersion);
vselect.setEmptyString(tr("No versions are currently available for Minecraft %1").arg(minecraftVersion));
- }
- else {
+ } else {
vselect.setEmptyString(tr("No versions are currently available"));
}
vselect.setEmptyErrorString(tr("Couldn't load or download the version lists!"));
@@ -72,9 +70,7 @@ QString AtlUserInteractionSupportImpl::chooseVersion(Meta::VersionList::Ptr vlis
// filter by minecraft version, if the loader depends on a certain version.
if (minecraftVersion != nullptr) {
- auto iter = std::find_if(reqs.begin(), reqs.end(), [](const Meta::Require& req) {
- return req.uid == "net.minecraft";
- });
+ auto iter = std::find_if(reqs.begin(), reqs.end(), [](const Meta::Require& req) { return req.uid == "net.minecraft"; });
if (iter == reqs.end())
continue;
if (iter->equalsVersion != minecraftVersion)
diff --git a/launcher/ui/pages/modplatform/atlauncher/AtlUserInteractionSupportImpl.h b/launcher/ui/pages/modplatform/atlauncher/AtlUserInteractionSupportImpl.h
index adeb53cb..52ced261 100644
--- a/launcher/ui/pages/modplatform/atlauncher/AtlUserInteractionSupportImpl.h
+++ b/launcher/ui/pages/modplatform/atlauncher/AtlUserInteractionSupportImpl.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/modplatform/flame/FlameModel.cpp b/launcher/ui/pages/modplatform/flame/FlameModel.cpp
index fa55aa68..83c1270b 100644
--- a/launcher/ui/pages/modplatform/flame/FlameModel.cpp
+++ b/launcher/ui/pages/modplatform/flame/FlameModel.cpp
@@ -40,14 +40,16 @@ QVariant ListModel::data(const QModelIndex& index, int role) const
return edit;
}
return pack.description;
- } case Qt::DecorationRole: {
+ }
+ case Qt::DecorationRole: {
if (m_logoMap.contains(pack.logoName)) {
return (m_logoMap.value(pack.logoName));
}
QIcon icon = APPLICATION->getThemedIcon("screenshot-placeholder");
((ListModel*)this)->requestLogo(pack.logoName, pack.logoUrl);
return icon;
- } case Qt::UserRole: {
+ }
+ case Qt::UserRole: {
QVariant v;
v.setValue(pack);
return v;
@@ -68,7 +70,7 @@ QVariant ListModel::data(const QModelIndex& index, int role) const
return QVariant();
}
-bool ListModel::setData(const QModelIndex &index, const QVariant &value, int role)
+bool ListModel::setData(const QModelIndex& index, const QVariant& value, int role)
{
int pos = index.row();
if (pos >= modpacks.size() || pos < 0 || !index.isValid())
diff --git a/launcher/ui/pages/modplatform/flame/FlamePage.cpp b/launcher/ui/pages/modplatform/flame/FlamePage.cpp
index aad37694..9be7ce8b 100644
--- a/launcher/ui/pages/modplatform/flame/FlamePage.cpp
+++ b/launcher/ui/pages/modplatform/flame/FlamePage.cpp
@@ -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/modplatform/flame/FlamePage.h b/launcher/ui/pages/modplatform/flame/FlamePage.h
index 8bdca38e..ff5c7975 100644
--- a/launcher/ui/pages/modplatform/flame/FlamePage.h
+++ b/launcher/ui/pages/modplatform/flame/FlamePage.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
@@ -37,45 +37,31 @@
#include <QWidget>
-#include "ui/pages/BasePage.h"
#include <Application.h>
-#include "tasks/Task.h"
#include <modplatform/flame/FlamePackIndex.h>
+#include "tasks/Task.h"
+#include "ui/pages/BasePage.h"
-namespace Ui
-{
+namespace Ui {
class FlamePage;
}
class NewInstanceDialog;
namespace Flame {
- class ListModel;
+class ListModel;
}
-class FlamePage : public QWidget, public BasePage
-{
+class FlamePage : public QWidget, public BasePage {
Q_OBJECT
-public:
- explicit FlamePage(NewInstanceDialog* dialog, QWidget *parent = 0);
+ public:
+ explicit FlamePage(NewInstanceDialog* dialog, QWidget* parent = 0);
virtual ~FlamePage();
- virtual QString displayName() const override
- {
- return "CurseForge";
- }
- virtual QIcon icon() const override
- {
- return APPLICATION->getThemedIcon("flame");
- }
- virtual QString id() const override
- {
- return "flame";
- }
- virtual QString helpPage() const override
- {
- return "Flame-platform";
- }
+ virtual QString displayName() const override { return "CurseForge"; }
+ virtual QIcon icon() const override { return APPLICATION->getThemedIcon("flame"); }
+ virtual QString id() const override { return "flame"; }
+ virtual QString helpPage() const override { return "Flame-platform"; }
virtual bool shouldDisplay() const override;
void retranslate() override;
@@ -83,18 +69,18 @@ public:
void openedImpl() override;
- bool eventFilter(QObject * watched, QEvent * event) override;
+ bool eventFilter(QObject* watched, QEvent* event) override;
-private:
+ private:
void suggestCurrent();
-private slots:
+ private slots:
void triggerSearch();
void onSelectionChanged(QModelIndex first, QModelIndex second);
void onVersionSelectionChanged(QString data);
-private:
- Ui::FlamePage *ui = nullptr;
+ private:
+ Ui::FlamePage* ui = nullptr;
NewInstanceDialog* dialog = nullptr;
Flame::ListModel* listModel = nullptr;
Flame::IndexedPack current;
diff --git a/launcher/ui/pages/modplatform/flame/FlameResourcePages.cpp b/launcher/ui/pages/modplatform/flame/FlameResourcePages.cpp
index f93e27e6..dc17e705 100644
--- a/launcher/ui/pages/modplatform/flame/FlameResourcePages.cpp
+++ b/launcher/ui/pages/modplatform/flame/FlameResourcePages.cpp
@@ -49,8 +49,7 @@ static bool isOptedOut(ModPlatform::IndexedVersion const& ver)
return ver.downloadUrl.isEmpty();
}
-FlameModPage::FlameModPage(ModDownloadDialog* dialog, BaseInstance& instance)
- : ModPage(dialog, instance)
+FlameModPage::FlameModPage(ModDownloadDialog* dialog, BaseInstance& instance) : ModPage(dialog, instance)
{
m_model = new FlameModModel(instance);
m_ui->packView->setModel(m_model);
@@ -67,7 +66,9 @@ FlameModPage::FlameModPage(ModDownloadDialog* dialog, BaseInstance& instance)
m_ui->packDescription->setMetaEntry(metaEntryBase());
}
-auto FlameModPage::validateVersion(ModPlatform::IndexedVersion& ver, QString mineVer, std::optional<ResourceAPI::ModLoaderTypes> loaders) const -> bool
+auto FlameModPage::validateVersion(ModPlatform::IndexedVersion& ver,
+ QString mineVer,
+ std::optional<ResourceAPI::ModLoaderTypes> loaders) const -> bool
{
Q_UNUSED(loaders);
return ver.mcVersion.contains(mineVer) && !ver.downloadUrl.isEmpty();
@@ -86,7 +87,7 @@ void FlameModPage::openUrl(const QUrl& url)
if (query.startsWith("remoteUrl=")) {
// attempt to resolve url from warning page
query.remove(0, 10);
- ModPage::openUrl({QUrl::fromPercentEncoding(query.toUtf8())}); // double decoding is necessary
+ ModPage::openUrl({ QUrl::fromPercentEncoding(query.toUtf8()) }); // double decoding is necessary
return;
}
}
@@ -125,7 +126,7 @@ void FlameResourcePackPage::openUrl(const QUrl& url)
if (query.startsWith("remoteUrl=")) {
// attempt to resolve url from warning page
query.remove(0, 10);
- ResourcePackResourcePage::openUrl({QUrl::fromPercentEncoding(query.toUtf8())}); // double decoding is necessary
+ ResourcePackResourcePage::openUrl({ QUrl::fromPercentEncoding(query.toUtf8()) }); // double decoding is necessary
return;
}
}
@@ -164,7 +165,7 @@ void FlameTexturePackPage::openUrl(const QUrl& url)
if (query.startsWith("remoteUrl=")) {
// attempt to resolve url from warning page
query.remove(0, 10);
- ResourcePackResourcePage::openUrl({QUrl::fromPercentEncoding(query.toUtf8())}); // double decoding is necessary
+ ResourcePackResourcePage::openUrl({ QUrl::fromPercentEncoding(query.toUtf8()) }); // double decoding is necessary
return;
}
}
@@ -175,8 +176,17 @@ void FlameTexturePackPage::openUrl(const QUrl& url)
// I don't know why, but doing this on the parent class makes it so that
// other mod providers start loading before being selected, at least with
// my Qt, so we need to implement this in every derived class...
-auto FlameModPage::shouldDisplay() const -> bool { return true; }
-auto FlameResourcePackPage::shouldDisplay() const -> bool { return true; }
-auto FlameTexturePackPage::shouldDisplay() const -> bool { return true; }
+auto FlameModPage::shouldDisplay() const -> bool
+{
+ return true;
+}
+auto FlameResourcePackPage::shouldDisplay() const -> bool
+{
+ return true;
+}
+auto FlameTexturePackPage::shouldDisplay() const -> bool
+{
+ return true;
+}
} // namespace ResourceDownload
diff --git a/launcher/ui/pages/modplatform/flame/FlameResourcePages.h b/launcher/ui/pages/modplatform/flame/FlameResourcePages.h
index 103a6bb9..c6ebc1ea 100644
--- a/launcher/ui/pages/modplatform/flame/FlameResourcePages.h
+++ b/launcher/ui/pages/modplatform/flame/FlameResourcePages.h
@@ -49,12 +49,27 @@
namespace ResourceDownload {
namespace Flame {
-static inline QString displayName() { return "CurseForge"; }
-static inline QIcon icon() { return APPLICATION->getThemedIcon("flame"); }
-static inline QString id() { return "curseforge"; }
-static inline QString debugName() { return "Flame"; }
-static inline QString metaEntryBase() { return "FlameMods"; }
+static inline QString displayName()
+{
+ return "CurseForge";
}
+static inline QIcon icon()
+{
+ return APPLICATION->getThemedIcon("flame");
+}
+static inline QString id()
+{
+ return "curseforge";
+}
+static inline QString debugName()
+{
+ return "Flame";
+}
+static inline QString metaEntryBase()
+{
+ return "FlameMods";
+}
+} // namespace Flame
class FlameModPage : public ModPage {
Q_OBJECT
@@ -78,7 +93,9 @@ class FlameModPage : public ModPage {
[[nodiscard]] inline auto helpPage() const -> QString override { return "Mod-platform"; }
- bool validateVersion(ModPlatform::IndexedVersion& ver, QString mineVer, std::optional<ResourceAPI::ModLoaderTypes> loaders = {}) const override;
+ bool validateVersion(ModPlatform::IndexedVersion& ver,
+ QString mineVer,
+ std::optional<ResourceAPI::ModLoaderTypes> loaders = {}) const override;
bool optedOut(ModPlatform::IndexedVersion& ver) const override;
void openUrl(const QUrl& url) override;
diff --git a/launcher/ui/pages/modplatform/import_ftb/ImportFTBPage.cpp b/launcher/ui/pages/modplatform/import_ftb/ImportFTBPage.cpp
new file mode 100644
index 00000000..5c9ff63b
--- /dev/null
+++ b/launcher/ui/pages/modplatform/import_ftb/ImportFTBPage.cpp
@@ -0,0 +1,104 @@
+// SPDX-License-Identifier: GPL-3.0-only
+/*
+ * Prism Launcher - Minecraft Launcher
+ * Copyright (c) 2023 Trial97 <alexandru.tripon97@gmail.com>
+ *
+ * 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, version 3.
+ *
+ * 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 "ImportFTBPage.h"
+#include "ui_ImportFTBPage.h"
+
+#include <QWidget>
+#include "FileSystem.h"
+#include "ListModel.h"
+#include "modplatform/import_ftb/PackInstallTask.h"
+#include "ui/dialogs/NewInstanceDialog.h"
+
+namespace FTBImportAPP {
+
+ImportFTBPage::ImportFTBPage(NewInstanceDialog* dialog, QWidget* parent) : QWidget(parent), dialog(dialog), ui(new Ui::ImportFTBPage)
+{
+ ui->setupUi(this);
+
+ {
+ listModel = new ListModel(this);
+
+ ui->modpackList->setModel(listModel);
+ ui->modpackList->setSortingEnabled(true);
+ ui->modpackList->header()->hide();
+ ui->modpackList->setIndentation(0);
+ ui->modpackList->setIconSize(QSize(42, 42));
+ }
+
+ connect(ui->modpackList->selectionModel(), &QItemSelectionModel::currentChanged, this, &ImportFTBPage::onPublicPackSelectionChanged);
+
+ ui->modpackList->selectionModel()->reset();
+}
+
+ImportFTBPage::~ImportFTBPage()
+{
+ delete ui;
+}
+
+void ImportFTBPage::openedImpl()
+{
+ if (!initialized) {
+ listModel->update();
+ initialized = true;
+ }
+ suggestCurrent();
+}
+
+void ImportFTBPage::retranslate()
+{
+ ui->retranslateUi(this);
+}
+
+void ImportFTBPage::suggestCurrent()
+{
+ if (!isOpened)
+ return;
+
+ if (selected.path.isEmpty()) {
+ dialog->setSuggestedPack();
+ return;
+ }
+
+ dialog->setSuggestedPack(selected.name, new PackInstallTask(selected));
+ QString editedLogoName = QString("ftb_%1").arg(selected.id);
+ dialog->setSuggestedIconFromFile(FS::PathCombine(selected.path, "folder.jpg"), editedLogoName);
+}
+
+void ImportFTBPage::onPublicPackSelectionChanged(QModelIndex now, QModelIndex prev)
+{
+ if (!now.isValid()) {
+ onPackSelectionChanged();
+ return;
+ }
+ Modpack selectedPack = listModel->data(now, Qt::UserRole).value<Modpack>();
+ onPackSelectionChanged(&selectedPack);
+}
+
+void ImportFTBPage::onPackSelectionChanged(Modpack* pack)
+{
+ if (pack) {
+ selected = *pack;
+ suggestCurrent();
+ return;
+ }
+ if (isOpened)
+ dialog->setSuggestedPack();
+}
+
+} // namespace FTBImportAPP
diff --git a/launcher/ui/pages/modplatform/import_ftb/ImportFTBPage.h b/launcher/ui/pages/modplatform/import_ftb/ImportFTBPage.h
new file mode 100644
index 00000000..54c49f7b
--- /dev/null
+++ b/launcher/ui/pages/modplatform/import_ftb/ImportFTBPage.h
@@ -0,0 +1,67 @@
+// SPDX-License-Identifier: GPL-3.0-only
+/*
+ * Prism Launcher - Minecraft Launcher
+ * Copyright (c) 2023 Trial97 <alexandru.tripon97@gmail.com>
+ *
+ * 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, version 3.
+ *
+ * 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 <QDialog>
+#include <QTextBrowser>
+#include <QTreeView>
+#include <QWidget>
+
+#include <Application.h>
+#include "modplatform/import_ftb/PackHelpers.h"
+#include "ui/pages/BasePage.h"
+#include "ui/pages/modplatform/import_ftb/ListModel.h"
+
+class NewInstanceDialog;
+
+namespace FTBImportAPP {
+namespace Ui {
+class ImportFTBPage;
+}
+
+class ImportFTBPage : public QWidget, public BasePage {
+ Q_OBJECT
+
+ public:
+ explicit ImportFTBPage(NewInstanceDialog* dialog, QWidget* parent = 0);
+ virtual ~ImportFTBPage();
+ QString displayName() const override { return tr("FTB App Import"); }
+ QIcon icon() const override { return APPLICATION->getThemedIcon("ftb_logo"); }
+ QString id() const override { return "import_ftb"; }
+ QString helpPage() const override { return "FTB-platform"; }
+ bool shouldDisplay() const override { return true; }
+ void openedImpl() override;
+ void retranslate() override;
+
+ private:
+ void suggestCurrent();
+ void onPackSelectionChanged(Modpack* pack = nullptr);
+ private slots:
+ void onPublicPackSelectionChanged(QModelIndex first, QModelIndex second);
+
+ private:
+ bool initialized = false;
+ Modpack selected;
+ ListModel* listModel = nullptr;
+
+ NewInstanceDialog* dialog = nullptr;
+ Ui::ImportFTBPage* ui = nullptr;
+};
+
+} // namespace FTBImportAPP
diff --git a/launcher/ui/pages/modplatform/import_ftb/ImportFTBPage.ui b/launcher/ui/pages/modplatform/import_ftb/ImportFTBPage.ui
new file mode 100644
index 00000000..32d548b0
--- /dev/null
+++ b/launcher/ui/pages/modplatform/import_ftb/ImportFTBPage.ui
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>FTBImportAPP::ImportFTBPage</class>
+ <widget class="QWidget" name="FTBImportAPP::ImportFTBPage">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>1461</width>
+ <height>1011</height>
+ </rect>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QTreeView" name="modpackList">
+ <property name="maximumSize">
+ <size>
+ <width>16777215</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/launcher/ui/pages/modplatform/import_ftb/ListModel.cpp b/launcher/ui/pages/modplatform/import_ftb/ListModel.cpp
new file mode 100644
index 00000000..dc78f451
--- /dev/null
+++ b/launcher/ui/pages/modplatform/import_ftb/ListModel.cpp
@@ -0,0 +1,88 @@
+// SPDX-License-Identifier: GPL-3.0-only
+/*
+ * Prism Launcher - Minecraft Launcher
+ * Copyright (c) 2023 Trial97 <alexandru.tripon97@gmail.com>
+ *
+ * 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, version 3.
+ *
+ * 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 "ListModel.h"
+#include <QDir>
+#include <QDirIterator>
+#include <QFileInfo>
+#include <QIcon>
+#include <QProcessEnvironment>
+#include "FileSystem.h"
+#include "modplatform/import_ftb/PackHelpers.h"
+
+namespace FTBImportAPP {
+
+QString getPath()
+{
+ QString partialPath;
+#if defined(Q_OS_OSX)
+ partialPath = FS::PathCombine(QDir::homePath(), "Library/Application Support");
+#elif defined(Q_OS_WIN32)
+ partialPath = QProcessEnvironment::systemEnvironment().value("LOCALAPPDATA", "");
+#else
+ partialPath = QDir::homePath();
+#endif
+ return FS::PathCombine(partialPath, ".ftba");
+}
+
+const QString ListModel::FTB_APP_PATH = getPath();
+
+void ListModel::update()
+{
+ beginResetModel();
+ modpacks.clear();
+
+ QString instancesPath = FS::PathCombine(FTB_APP_PATH, "instances");
+ if (auto instancesInfo = QFileInfo(instancesPath); instancesInfo.exists() && instancesInfo.isDir()) {
+ QDirIterator directoryIterator(instancesPath, QDir::Dirs | QDir::NoDotAndDotDot | QDir::Readable | QDir::Hidden,
+ QDirIterator::FollowSymlinks);
+ while (directoryIterator.hasNext()) {
+ auto modpack = parseDirectory(directoryIterator.next());
+ if (!modpack.path.isEmpty())
+ modpacks.append(modpack);
+ }
+ } else {
+ qDebug() << "Couldn't find ftb instances folder: " << instancesPath;
+ }
+
+ endResetModel();
+}
+
+QVariant ListModel::data(const QModelIndex& index, int role) const
+{
+ int pos = index.row();
+ if (pos >= modpacks.size() || pos < 0 || !index.isValid()) {
+ return QVariant();
+ }
+
+ auto pack = modpacks.at(pos);
+ if (role == Qt::DisplayRole) {
+ return pack.name;
+ } else if (role == Qt::DecorationRole) {
+ return pack.icon;
+ } else if (role == Qt::UserRole) {
+ QVariant v;
+ v.setValue(pack);
+ return v;
+ } else if (role == Qt::ToolTipRole) {
+ return tr("Minecraft %1").arg(pack.mcVersion);
+ }
+
+ return QVariant();
+}
+} // namespace FTBImportAPP \ No newline at end of file
diff --git a/launcher/ui/pages/modplatform/import_ftb/ListModel.h b/launcher/ui/pages/modplatform/import_ftb/ListModel.h
new file mode 100644
index 00000000..c67aa896
--- /dev/null
+++ b/launcher/ui/pages/modplatform/import_ftb/ListModel.h
@@ -0,0 +1,46 @@
+// SPDX-License-Identifier: GPL-3.0-only
+/*
+ * Prism Launcher - Minecraft Launcher
+ * Copyright (c) 2023 Trial97 <alexandru.tripon97@gmail.com>
+ *
+ * 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, version 3.
+ *
+ * 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 <QAbstractListModel>
+#include <QIcon>
+#include <QVariant>
+#include "modplatform/import_ftb/PackHelpers.h"
+
+namespace FTBImportAPP {
+
+class ListModel : public QAbstractListModel {
+ Q_OBJECT
+
+ public:
+ ListModel(QObject* parent) : QAbstractListModel(parent) {}
+ virtual ~ListModel() = default;
+
+ int rowCount(const QModelIndex& parent) const { return modpacks.size(); }
+ int columnCount(const QModelIndex& parent) const { return 1; }
+ QVariant data(const QModelIndex& index, int role) const;
+
+ void update();
+
+ static const QString FTB_APP_PATH;
+
+ private:
+ ModpackList modpacks;
+};
+} // namespace FTBImportAPP \ No newline at end of file
diff --git a/launcher/ui/pages/modplatform/legacy_ftb/ListModel.cpp b/launcher/ui/pages/modplatform/legacy_ftb/ListModel.cpp
index 330dd4fb..1731ff2c 100644
--- a/launcher/ui/pages/modplatform/legacy_ftb/ListModel.cpp
+++ b/launcher/ui/pages/modplatform/legacy_ftb/ListModel.cpp
@@ -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>
*
* This program is free software: you can redistribute it and/or modify
diff --git a/launcher/ui/pages/modplatform/legacy_ftb/ListModel.h b/launcher/ui/pages/modplatform/legacy_ftb/ListModel.h
index c55df000..51a58d99 100644
--- a/launcher/ui/pages/modplatform/legacy_ftb/ListModel.h
+++ b/launcher/ui/pages/modplatform/legacy_ftb/ListModel.h
@@ -1,13 +1,13 @@
#pragma once
-#include <modplatform/legacy_ftb/PackHelpers.h>
#include <RWStorage.h>
+#include <modplatform/legacy_ftb/PackHelpers.h>
#include <QAbstractListModel>
-#include <QSortFilterProxyModel>
-#include <QThreadPool>
#include <QIcon>
+#include <QSortFilterProxyModel>
#include <QStyledItemDelegate>
+#include <QThreadPool>
#include <functional>
@@ -16,34 +16,28 @@ namespace LegacyFTB {
typedef QMap<QString, QIcon> FTBLogoMap;
typedef std::function<void(QString)> LogoCallback;
-class FilterModel : public QSortFilterProxyModel
-{
+class FilterModel : public QSortFilterProxyModel {
Q_OBJECT
-public:
+ public:
FilterModel(QObject* parent = Q_NULLPTR);
- enum Sorting {
- ByName,
- ByGameVersion
- };
+ enum Sorting { ByName, ByGameVersion };
const QMap<QString, Sorting> getAvailableSortings();
QString translateCurrentSorting();
void setSorting(Sorting sorting);
Sorting getCurrentSorting();
-protected:
- bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
- bool lessThan(const QModelIndex &left, const QModelIndex &right) const override;
+ protected:
+ bool filterAcceptsRow(int sourceRow, const QModelIndex& sourceParent) const override;
+ bool lessThan(const QModelIndex& left, const QModelIndex& right) const override;
-private:
+ private:
QMap<QString, Sorting> sortings;
Sorting currentSorting;
-
};
-class ListModel : public QAbstractListModel
-{
+class ListModel : public QAbstractListModel {
Q_OBJECT
-private:
+ private:
ModpackList modpacks;
QStringList m_failedLogos;
QStringList m_loadingLogos;
@@ -53,18 +47,17 @@ private:
void requestLogo(QString file);
QString translatePackType(PackType type) const;
-
-private slots:
+ private slots:
void logoFailed(QString logo);
void logoLoaded(QString logo, QIcon out);
-public:
- ListModel(QObject *parent);
+ public:
+ ListModel(QObject* parent);
~ListModel();
- int rowCount(const QModelIndex &parent) const override;
- int columnCount(const QModelIndex &parent) const override;
- QVariant data(const QModelIndex &index, int role) const override;
- Qt::ItemFlags flags(const QModelIndex &index) const override;
+ int rowCount(const QModelIndex& parent) const override;
+ int columnCount(const QModelIndex& parent) const override;
+ QVariant data(const QModelIndex& index, int role) const override;
+ Qt::ItemFlags flags(const QModelIndex& index) const override;
void fill(ModpackList modpacks);
void addPack(Modpack modpack);
@@ -72,7 +65,7 @@ public:
void remove(int row);
Modpack at(int row);
- void getLogo(const QString &logo, LogoCallback callback);
+ void getLogo(const QString& logo, LogoCallback callback);
};
-}
+} // namespace LegacyFTB
diff --git a/launcher/ui/pages/modplatform/legacy_ftb/Page.cpp b/launcher/ui/pages/modplatform/legacy_ftb/Page.cpp
index b3f6261f..ef8e9892 100644
--- a/launcher/ui/pages/modplatform/legacy_ftb/Page.cpp
+++ b/launcher/ui/pages/modplatform/legacy_ftb/Page.cpp
@@ -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>
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
*
@@ -44,15 +44,14 @@
#include "ui/dialogs/CustomMessageBox.h"
#include "ui/dialogs/NewInstanceDialog.h"
+#include "ListModel.h"
#include "modplatform/legacy_ftb/PackFetchTask.h"
#include "modplatform/legacy_ftb/PackInstallTask.h"
#include "modplatform/legacy_ftb/PrivatePackManager.h"
-#include "ListModel.h"
namespace LegacyFTB {
-Page::Page(NewInstanceDialog* dialog, QWidget *parent)
- : QWidget(parent), dialog(dialog), ui(new Ui::Page)
+Page::Page(NewInstanceDialog* dialog, QWidget* parent) : QWidget(parent), dialog(dialog), ui(new Ui::Page)
{
ftbFetchTask.reset(new PackFetchTask(APPLICATION->network()));
ftbPrivatePacks.reset(new PrivatePackManager());
@@ -70,8 +69,7 @@ Page::Page(NewInstanceDialog* dialog, QWidget *parent)
ui->publicPackList->setIndentation(0);
ui->publicPackList->setIconSize(QSize(42, 42));
- for(int i = 0; i < publicFilterModel->getAvailableSortings().size(); i++)
- {
+ for (int i = 0; i < publicFilterModel->getAvailableSortings().size(); i++) {
ui->sortByBox->addItem(publicFilterModel->getAvailableSortings().keys().at(i));
}
@@ -142,8 +140,7 @@ bool Page::shouldDisplay() const
void Page::openedImpl()
{
- if(!initialized)
- {
+ if (!initialized) {
connect(ftbFetchTask.get(), &PackFetchTask::finished, this, &Page::ftbPackDataDownloadSuccessfully);
connect(ftbFetchTask.get(), &PackFetchTask::failed, this, &Page::ftbPackDataDownloadFailed);
connect(ftbFetchTask.get(), &PackFetchTask::aborted, this, &Page::ftbPackDataDownloadAborted);
@@ -166,50 +163,34 @@ void Page::retranslate()
void Page::suggestCurrent()
{
- if(!isOpened)
- {
+ if (!isOpened) {
return;
}
- if(selected.broken || selectedVersion.isEmpty())
- {
+ if (selected.broken || selectedVersion.isEmpty()) {
dialog->setSuggestedPack();
return;
}
dialog->setSuggestedPack(selected.name, selectedVersion, new PackInstallTask(APPLICATION->network(), selected, selectedVersion));
QString editedLogoName;
- if(selected.logo.toLower().startsWith("ftb"))
- {
+ if (selected.logo.toLower().startsWith("ftb")) {
editedLogoName = selected.logo;
- }
- else
- {
+ } else {
editedLogoName = "ftb_" + selected.logo;
}
editedLogoName = editedLogoName.left(editedLogoName.lastIndexOf(".png"));
- if(selected.type == PackType::Public)
- {
- publicListModel->getLogo(selected.logo, [this, editedLogoName](QString logo)
- {
- dialog->setSuggestedIconFromFile(logo, editedLogoName);
- });
- }
- else if (selected.type == PackType::ThirdParty)
- {
- thirdPartyModel->getLogo(selected.logo, [this, editedLogoName](QString logo)
- {
- dialog->setSuggestedIconFromFile(logo, editedLogoName);
- });
- }
- else if (selected.type == PackType::Private)
- {
- privateListModel->getLogo(selected.logo, [this, editedLogoName](QString logo)
- {
- dialog->setSuggestedIconFromFile(logo, editedLogoName);
- });
+ if (selected.type == PackType::Public) {
+ publicListModel->getLogo(selected.logo,
+ [this, editedLogoName](QString logo) { dialog->setSuggestedIconFromFile(logo, editedLogoName); });
+ } else if (selected.type == PackType::ThirdParty) {
+ thirdPartyModel->getLogo(selected.logo,
+ [this, editedLogoName](QString logo) { dialog->setSuggestedIconFromFile(logo, editedLogoName); });
+ } else if (selected.type == PackType::Private) {
+ privateListModel->getLogo(selected.logo,
+ [this, editedLogoName](QString logo) { dialog->setSuggestedIconFromFile(logo, editedLogoName); });
}
}
@@ -236,21 +217,16 @@ void Page::ftbPrivatePackDataDownloadSuccessfully(Modpack pack)
void Page::ftbPrivatePackDataDownloadFailed(QString reason, QString packCode)
{
- auto reply = QMessageBox::question(
- this,
- tr("FTB private packs"),
- tr("Failed to download pack information for code %1.\nShould it be removed now?").arg(packCode)
- );
- if(reply == QMessageBox::Yes)
- {
+ auto reply = QMessageBox::question(this, tr("FTB private packs"),
+ tr("Failed to download pack information for code %1.\nShould it be removed now?").arg(packCode));
+ if (reply == QMessageBox::Yes) {
ftbPrivatePacks->remove(packCode);
}
}
void Page::onPublicPackSelectionChanged(QModelIndex now, QModelIndex prev)
{
- if(!now.isValid())
- {
+ if (!now.isValid()) {
onPackSelectionChanged();
return;
}
@@ -260,8 +236,7 @@ void Page::onPublicPackSelectionChanged(QModelIndex now, QModelIndex prev)
void Page::onThirdPartyPackSelectionChanged(QModelIndex now, QModelIndex prev)
{
- if(!now.isValid())
- {
+ if (!now.isValid()) {
onPackSelectionChanged();
return;
}
@@ -271,8 +246,7 @@ void Page::onThirdPartyPackSelectionChanged(QModelIndex now, QModelIndex prev)
void Page::onPrivatePackSelectionChanged(QModelIndex now, QModelIndex prev)
{
- if(!now.isValid())
- {
+ if (!now.isValid()) {
onPackSelectionChanged();
return;
}
@@ -283,34 +257,26 @@ void Page::onPrivatePackSelectionChanged(QModelIndex now, QModelIndex prev)
void Page::onPackSelectionChanged(Modpack* pack)
{
ui->versionSelectionBox->clear();
- if(pack)
- {
- currentModpackInfo->setHtml("Pack by <b>" + pack->author + "</b>" +
- "<br>Minecraft " + pack->mcVersion + "<br>" + "<br>" + pack->description + "<ul><li>" + pack->mods.replace(";", "</li><li>")
- + "</li></ul>");
+ if (pack) {
+ currentModpackInfo->setHtml("Pack by <b>" + pack->author + "</b>" + "<br>Minecraft " + pack->mcVersion + "<br>" + "<br>" +
+ pack->description + "<ul><li>" + pack->mods.replace(";", "</li><li>") + "</li></ul>");
bool currentAdded = false;
- for(int i = 0; i < pack->oldVersions.size(); i++)
- {
- if(pack->currentVersion == pack->oldVersions.at(i))
- {
+ for (int i = 0; i < pack->oldVersions.size(); i++) {
+ if (pack->currentVersion == pack->oldVersions.at(i)) {
currentAdded = true;
}
ui->versionSelectionBox->addItem(pack->oldVersions.at(i));
}
- if(!currentAdded)
- {
+ if (!currentAdded) {
ui->versionSelectionBox->addItem(pack->currentVersion);
}
selected = *pack;
- }
- else
- {
+ } else {
currentModpackInfo->setHtml("");
ui->versionSelectionBox->clear();
- if(isOpened)
- {
+ if (isOpened) {
dialog->setSuggestedPack();
}
return;
@@ -320,8 +286,7 @@ void Page::onPackSelectionChanged(Modpack* pack)
void Page::onVersionSelectionItemChanged(QString data)
{
- if(data.isNull() || data.isEmpty())
- {
+ if (data.isNull() || data.isEmpty()) {
selectedVersion = "";
return;
}
@@ -340,20 +305,15 @@ void Page::onSortingSelectionChanged(QString data)
void Page::onTabChanged(int tab)
{
- if(tab == 1)
- {
+ if (tab == 1) {
currentModel = thirdPartyFilterModel;
currentList = ui->thirdPartyPackList;
currentModpackInfo = ui->thirdPartyPackDescription;
- }
- else if(tab == 2)
- {
+ } else if (tab == 2) {
currentModel = privateFilterModel;
currentList = ui->privatePackList;
currentModpackInfo = ui->privatePackDescription;
- }
- else
- {
+ } else {
currentModel = publicFilterModel;
currentList = ui->publicPackList;
currentModpackInfo = ui->publicPackDescription;
@@ -361,13 +321,10 @@ void Page::onTabChanged(int tab)
currentList->selectionModel()->reset();
QModelIndex idx = currentList->currentIndex();
- if(idx.isValid())
- {
+ if (idx.isValid()) {
auto pack = currentModel->data(idx, Qt::UserRole).value<Modpack>();
onPackSelectionChanged(&pack);
- }
- else
- {
+ } else {
onPackSelectionChanged();
}
}
@@ -375,38 +332,24 @@ void Page::onTabChanged(int tab)
void Page::onAddPackClicked()
{
bool ok;
- QString text = QInputDialog::getText(
- this,
- tr("Add FTB pack"),
- tr("Enter pack code:"),
- QLineEdit::Normal,
- QString(),
- &ok
- );
- if(ok && !text.isEmpty())
- {
+ QString text = QInputDialog::getText(this, tr("Add FTB pack"), tr("Enter pack code:"), QLineEdit::Normal, QString(), &ok);
+ if (ok && !text.isEmpty()) {
ftbPrivatePacks->add(text);
- ftbFetchTask->fetchPrivate({text});
+ ftbFetchTask->fetchPrivate({ text });
}
}
void Page::onRemovePackClicked()
{
auto index = ui->privatePackList->currentIndex();
- if(!index.isValid())
- {
+ if (!index.isValid()) {
return;
}
auto row = index.row();
Modpack pack = privateListModel->at(row);
- auto answer = QMessageBox::question(
- this,
- tr("Remove pack"),
- tr("Are you sure you want to remove pack %1?").arg(pack.name),
- QMessageBox::Yes | QMessageBox::No
- );
- if(answer != QMessageBox::Yes)
- {
+ auto answer = QMessageBox::question(this, tr("Remove pack"), tr("Are you sure you want to remove pack %1?").arg(pack.name),
+ QMessageBox::Yes | QMessageBox::No);
+ if (answer != QMessageBox::Yes) {
return;
}
@@ -415,4 +358,4 @@ void Page::onRemovePackClicked()
onPackSelectionChanged();
}
-}
+} // namespace LegacyFTB
diff --git a/launcher/ui/pages/modplatform/legacy_ftb/Page.h b/launcher/ui/pages/modplatform/legacy_ftb/Page.h
index 1de8b40a..a12b0745 100644
--- a/launcher/ui/pages/modplatform/legacy_ftb/Page.h
+++ b/launcher/ui/pages/modplatform/legacy_ftb/Page.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
@@ -35,23 +35,22 @@
#pragma once
-#include <QWidget>
-#include <QTreeView>
#include <QTextBrowser>
+#include <QTreeView>
+#include <QWidget>
-#include "ui/pages/BasePage.h"
#include <Application.h>
-#include "tasks/Task.h"
-#include "modplatform/legacy_ftb/PackHelpers.h"
-#include "modplatform/legacy_ftb/PackFetchTask.h"
#include "QObjectPtr.h"
+#include "modplatform/legacy_ftb/PackFetchTask.h"
+#include "modplatform/legacy_ftb/PackHelpers.h"
+#include "tasks/Task.h"
+#include "ui/pages/BasePage.h"
class NewInstanceDialog;
namespace LegacyFTB {
-namespace Ui
-{
+namespace Ui {
class Page;
}
@@ -61,38 +60,25 @@ class PrivatePackListModel;
class PrivatePackFilterModel;
class PrivatePackManager;
-class Page : public QWidget, public BasePage
-{
+class Page : public QWidget, public BasePage {
Q_OBJECT
-public:
- explicit Page(NewInstanceDialog * dialog, QWidget *parent = 0);
+ public:
+ explicit Page(NewInstanceDialog* dialog, QWidget* parent = 0);
virtual ~Page();
- QString displayName() const override
- {
- return "FTB Legacy";
- }
- QIcon icon() const override
- {
- return APPLICATION->getThemedIcon("ftb_logo");
- }
- QString id() const override
- {
- return "legacy_ftb";
- }
- QString helpPage() const override
- {
- return "FTB-platform";
- }
+ QString displayName() const override { return "FTB Legacy"; }
+ QIcon icon() const override { return APPLICATION->getThemedIcon("ftb_logo"); }
+ QString id() const override { return "legacy_ftb"; }
+ QString helpPage() const override { return "FTB-platform"; }
bool shouldDisplay() const override;
void openedImpl() override;
void retranslate() override;
-private:
+ private:
void suggestCurrent();
- void onPackSelectionChanged(Modpack *pack = nullptr);
+ void onPackSelectionChanged(Modpack* pack = nullptr);
-private slots:
+ private slots:
void ftbPackDataDownloadSuccessfully(ModpackList publicPacks, ModpackList thirdPartyPacks);
void ftbPackDataDownloadFailed(QString reason);
void ftbPackDataDownloadAborted();
@@ -112,7 +98,7 @@ private slots:
void onAddPackClicked();
void onRemovePackClicked();
-private:
+ private:
FilterModel* currentModel = nullptr;
QTreeView* currentList = nullptr;
QTextBrowser* currentModpackInfo = nullptr;
@@ -124,18 +110,18 @@ private:
ListModel* publicListModel = nullptr;
FilterModel* publicFilterModel = nullptr;
- ListModel *thirdPartyModel = nullptr;
- FilterModel *thirdPartyFilterModel = nullptr;
+ ListModel* thirdPartyModel = nullptr;
+ FilterModel* thirdPartyFilterModel = nullptr;
- ListModel *privateListModel = nullptr;
- FilterModel *privateFilterModel = nullptr;
+ ListModel* privateListModel = nullptr;
+ FilterModel* privateFilterModel = nullptr;
unique_qobject_ptr<PackFetchTask> ftbFetchTask;
std::unique_ptr<PrivatePackManager> ftbPrivatePacks;
NewInstanceDialog* dialog = nullptr;
- Ui::Page *ui = nullptr;
+ Ui::Page* ui = nullptr;
};
-}
+} // namespace LegacyFTB
diff --git a/launcher/ui/pages/modplatform/modrinth/ModrinthModel.cpp b/launcher/ui/pages/modplatform/modrinth/ModrinthModel.cpp
index e0046d88..761e265d 100644
--- a/launcher/ui/pages/modplatform/modrinth/ModrinthModel.cpp
+++ b/launcher/ui/pages/modplatform/modrinth/ModrinthModel.cpp
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
- * PolyMC - Minecraft Launcher
+ * Prism Launcher - Minecraft Launcher
* Copyright (c) 2022 flowln <flowlnlnln@gmail.com>
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
*
@@ -115,7 +115,7 @@ auto ModpackListModel::data(const QModelIndex& index, int role) const -> QVarian
return {};
}
-bool ModpackListModel::setData(const QModelIndex &index, const QVariant &value, int role)
+bool ModpackListModel::setData(const QModelIndex& index, const QVariant& value, int role)
{
int pos = index.row();
if (pos >= modpacks.size() || pos < 0 || !index.isValid())
@@ -181,18 +181,18 @@ void ModpackListModel::refresh()
static auto sortFromIndex(int index) -> QString
{
- switch(index){
- default:
- case 0:
- return "relevance";
- case 1:
- return "downloads";
- case 2:
- return "follows";
- case 3:
- return "newest";
- case 4:
- return "updated";
+ switch (index) {
+ default:
+ case 0:
+ return "relevance";
+ case 1:
+ return "downloads";
+ case 2:
+ return "follows";
+ case 3:
+ return "newest";
+ case 4:
+ return "updated";
}
return {};
@@ -200,7 +200,7 @@ static auto sortFromIndex(int index) -> QString
void ModpackListModel::searchWithTerm(const QString& term, const int sort)
{
- if(sort > 5 || sort < 0)
+ if (sort > 5 || sort < 0)
return;
auto sort_str = sortFromIndex(sort);
diff --git a/launcher/ui/pages/modplatform/modrinth/ModrinthModel.h b/launcher/ui/pages/modplatform/modrinth/ModrinthModel.h
index b9e9c3da..721c69f5 100644
--- a/launcher/ui/pages/modplatform/modrinth/ModrinthModel.h
+++ b/launcher/ui/pages/modplatform/modrinth/ModrinthModel.h
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
- * PolyMC - Minecraft Launcher
+ * Prism Launcher - Minecraft Launcher
* Copyright (c) 2022 flowln <flowlnlnln@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
@@ -47,7 +47,7 @@ class Version;
namespace Modrinth {
using LogoMap = QMap<QString, QIcon>;
-using LogoCallback = std::function<void (QString)>;
+using LogoCallback = std::function<void(QString)>;
class ModpackListModel : public QAbstractListModel {
Q_OBJECT
@@ -64,7 +64,7 @@ class ModpackListModel : public QAbstractListModel {
/* Retrieve information from the model at a given index with the given role */
auto data(const QModelIndex& index, int role) const -> QVariant override;
- bool setData(const QModelIndex &index, const QVariant &value, int role) override;
+ bool setData(const QModelIndex& index, const QVariant& value, int role) override;
inline void setActiveJob(NetJob::Ptr ptr) { jobPtr = ptr; }
@@ -75,7 +75,10 @@ class ModpackListModel : public QAbstractListModel {
void getLogo(const QString& logo, const QString& logoUrl, LogoCallback callback);
- inline auto canFetchMore(const QModelIndex& parent) const -> bool override { return parent.isValid() ? false : searchState == CanPossiblyFetchMore; };
+ inline auto canFetchMore(const QModelIndex& parent) const -> bool override
+ {
+ return parent.isValid() ? false : searchState == CanPossiblyFetchMore;
+ };
public slots:
void searchRequestFinished(QJsonDocument& doc_all);
diff --git a/launcher/ui/pages/modplatform/modrinth/ModrinthPage.cpp b/launcher/ui/pages/modplatform/modrinth/ModrinthPage.cpp
index c41f118a..b4d73b2f 100644
--- a/launcher/ui/pages/modplatform/modrinth/ModrinthPage.cpp
+++ b/launcher/ui/pages/modplatform/modrinth/ModrinthPage.cpp
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
- * PolyMC - Minecraft Launcher
+ * Prism Launcher - Minecraft Launcher
* Copyright (c) 2022 flowln <flowlnlnln@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
diff --git a/launcher/ui/pages/modplatform/modrinth/ModrinthPage.h b/launcher/ui/pages/modplatform/modrinth/ModrinthPage.h
index db5e1a3d..b7054c88 100644
--- a/launcher/ui/pages/modplatform/modrinth/ModrinthPage.h
+++ b/launcher/ui/pages/modplatform/modrinth/ModrinthPage.h
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
- * PolyMC - Minecraft Launcher
+ * Prism Launcher - Minecraft Launcher
* Copyright (c) 2022 flowln <flowlnlnln@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
diff --git a/launcher/ui/pages/modplatform/modrinth/ModrinthResourceModels.cpp b/launcher/ui/pages/modplatform/modrinth/ModrinthResourceModels.cpp
index 8aa64989..00a0108a 100644
--- a/launcher/ui/pages/modplatform/modrinth/ModrinthResourceModels.cpp
+++ b/launcher/ui/pages/modplatform/modrinth/ModrinthResourceModels.cpp
@@ -2,7 +2,7 @@
//
// SPDX-License-Identifier: GPL-3.0-only
/*
- * PolyMC - Minecraft Launcher
+ * Prism Launcher - Minecraft Launcher
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
*
* This program is free software: you can redistribute it and/or modify
diff --git a/launcher/ui/pages/modplatform/modrinth/ModrinthResourceModels.h b/launcher/ui/pages/modplatform/modrinth/ModrinthResourceModels.h
index d7c858f8..15cd5854 100644
--- a/launcher/ui/pages/modplatform/modrinth/ModrinthResourceModels.h
+++ b/launcher/ui/pages/modplatform/modrinth/ModrinthResourceModels.h
@@ -2,7 +2,7 @@
//
// SPDX-License-Identifier: GPL-3.0-only
/*
- * PolyMC - Minecraft Launcher
+ * Prism Launcher - Minecraft Launcher
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
*
* This program is free software: you can redistribute it and/or modify
diff --git a/launcher/ui/pages/modplatform/modrinth/ModrinthResourcePages.cpp b/launcher/ui/pages/modplatform/modrinth/ModrinthResourcePages.cpp
index dd143700..616c1a81 100644
--- a/launcher/ui/pages/modplatform/modrinth/ModrinthResourcePages.cpp
+++ b/launcher/ui/pages/modplatform/modrinth/ModrinthResourcePages.cpp
@@ -2,7 +2,7 @@
//
// SPDX-License-Identifier: GPL-3.0-only
/*
- * PolyMC - Minecraft Launcher
+ * Prism Launcher - Minecraft Launcher
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
*
* This program is free software: you can redistribute it and/or modify
@@ -46,8 +46,7 @@
namespace ResourceDownload {
-ModrinthModPage::ModrinthModPage(ModDownloadDialog* dialog, BaseInstance& instance)
- : ModPage(dialog, instance)
+ModrinthModPage::ModrinthModPage(ModDownloadDialog* dialog, BaseInstance& instance) : ModPage(dialog, instance)
{
m_model = new ModrinthModModel(instance);
m_ui->packView->setModel(m_model);
@@ -64,14 +63,15 @@ ModrinthModPage::ModrinthModPage(ModDownloadDialog* dialog, BaseInstance& instan
m_ui->packDescription->setMetaEntry(metaEntryBase());
}
-auto ModrinthModPage::validateVersion(ModPlatform::IndexedVersion& ver, QString mineVer, std::optional<ResourceAPI::ModLoaderTypes> loaders) const -> bool
+auto ModrinthModPage::validateVersion(ModPlatform::IndexedVersion& ver,
+ QString mineVer,
+ std::optional<ResourceAPI::ModLoaderTypes> loaders) const -> bool
{
auto loaderCompatible = !loaders.has_value();
if (!loaderCompatible) {
auto loaderStrings = ModrinthAPI::getModLoaderStrings(loaders.value());
- for (auto remoteLoader : ver.loaders)
- {
+ for (auto remoteLoader : ver.loaders) {
if (loaderStrings.contains(remoteLoader)) {
loaderCompatible = true;
break;
@@ -139,9 +139,21 @@ ModrinthShaderPackPage::ModrinthShaderPackPage(ShaderPackDownloadDialog* dialog,
// I don't know why, but doing this on the parent class makes it so that
// other mod providers start loading before being selected, at least with
// my Qt, so we need to implement this in every derived class...
-auto ModrinthModPage::shouldDisplay() const -> bool { return true; }
-auto ModrinthResourcePackPage::shouldDisplay() const -> bool { return true; }
-auto ModrinthTexturePackPage::shouldDisplay() const -> bool { return true; }
-auto ModrinthShaderPackPage::shouldDisplay() const -> bool { return true; }
+auto ModrinthModPage::shouldDisplay() const -> bool
+{
+ return true;
+}
+auto ModrinthResourcePackPage::shouldDisplay() const -> bool
+{
+ return true;
+}
+auto ModrinthTexturePackPage::shouldDisplay() const -> bool
+{
+ return true;
+}
+auto ModrinthShaderPackPage::shouldDisplay() const -> bool
+{
+ return true;
+}
} // namespace ResourceDownload
diff --git a/launcher/ui/pages/modplatform/modrinth/ModrinthResourcePages.h b/launcher/ui/pages/modplatform/modrinth/ModrinthResourcePages.h
index f4eb5ce0..86ba1ccb 100644
--- a/launcher/ui/pages/modplatform/modrinth/ModrinthResourcePages.h
+++ b/launcher/ui/pages/modplatform/modrinth/ModrinthResourcePages.h
@@ -2,7 +2,7 @@
//
// SPDX-License-Identifier: GPL-3.0-only AND Apache-2.0
/*
- * PolyMC - Minecraft Launcher
+ * Prism Launcher - Minecraft Launcher
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
*
* This program is free software: you can redistribute it and/or modify
@@ -43,18 +43,33 @@
#include "ui/pages/modplatform/ModPage.h"
#include "ui/pages/modplatform/ResourcePackPage.h"
-#include "ui/pages/modplatform/TexturePackPage.h"
#include "ui/pages/modplatform/ShaderPackPage.h"
+#include "ui/pages/modplatform/TexturePackPage.h"
namespace ResourceDownload {
namespace Modrinth {
-static inline QString displayName() { return "Modrinth"; }
-static inline QIcon icon() { return APPLICATION->getThemedIcon("modrinth"); }
-static inline QString id() { return "modrinth"; }
-static inline QString debugName() { return "Modrinth"; }
-static inline QString metaEntryBase() { return "ModrinthPacks"; }
+static inline QString displayName()
+{
+ return "Modrinth";
+}
+static inline QIcon icon()
+{
+ return APPLICATION->getThemedIcon("modrinth");
+}
+static inline QString id()
+{
+ return "modrinth";
+}
+static inline QString debugName()
+{
+ return "Modrinth";
+}
+static inline QString metaEntryBase()
+{
+ return "ModrinthPacks";
}
+} // namespace Modrinth
class ModrinthModPage : public ModPage {
Q_OBJECT
@@ -78,7 +93,8 @@ class ModrinthModPage : public ModPage {
[[nodiscard]] inline auto helpPage() const -> QString override { return "Mod-platform"; }
- auto validateVersion(ModPlatform::IndexedVersion& ver, QString mineVer, std::optional<ResourceAPI::ModLoaderTypes> loaders = {}) const -> bool override;
+ auto validateVersion(ModPlatform::IndexedVersion& ver, QString mineVer, std::optional<ResourceAPI::ModLoaderTypes> loaders = {}) const
+ -> bool override;
};
class ModrinthResourcePackPage : public ResourcePackResourcePage {
diff --git a/launcher/ui/pages/modplatform/technic/TechnicData.h b/launcher/ui/pages/modplatform/technic/TechnicData.h
index cd2ea8e1..fc7fa4d3 100644
--- a/launcher/ui/pages/modplatform/technic/TechnicData.h
+++ b/launcher/ui/pages/modplatform/technic/TechnicData.h
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
- * PolyMC - Minecraft Launcher
+ * Prism Launcher - Minecraft Launcher
* Copyright (c) 2021-2022 Jamie Mansfield <jmansfield@cadixdev.org>
*
* This program is free software: you can redistribute it and/or modify
@@ -63,6 +63,6 @@ struct Modpack {
QString recommended;
QVector<QString> versions;
};
-}
+} // namespace Technic
Q_DECLARE_METATYPE(Technic::Modpack)
diff --git a/launcher/ui/pages/modplatform/technic/TechnicModel.cpp b/launcher/ui/pages/modplatform/technic/TechnicModel.cpp
index f08eb289..02d7fd5b 100644
--- a/launcher/ui/pages/modplatform/technic/TechnicModel.cpp
+++ b/launcher/ui/pages/modplatform/technic/TechnicModel.cpp
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
- * PolyMC - Minecraft Launcher
+ * Prism Launcher - Minecraft Launcher
* Copyright (c) 2021 Jamie Mansfield <jmansfield@cadixdev.org>
*
* This program is free software: you can redistribute it and/or modify
diff --git a/launcher/ui/pages/modplatform/technic/TechnicModel.h b/launcher/ui/pages/modplatform/technic/TechnicModel.h
index 0f1a814e..d7a635d4 100644
--- a/launcher/ui/pages/modplatform/technic/TechnicModel.h
+++ b/launcher/ui/pages/modplatform/technic/TechnicModel.h
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
- * PolyMC - Minecraft Launcher
+ * Prism Launcher - Minecraft Launcher
* Copyright (c) 2021 Jamie Mansfield <jmansfield@cadixdev.org>
*
* This program is free software: you can redistribute it and/or modify
diff --git a/launcher/ui/pages/modplatform/technic/TechnicPage.cpp b/launcher/ui/pages/modplatform/technic/TechnicPage.cpp
index fc678fa2..88132754 100644
--- a/launcher/ui/pages/modplatform/technic/TechnicPage.cpp
+++ b/launcher/ui/pages/modplatform/technic/TechnicPage.cpp
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
- * PolyMC - Minecraft Launcher
+ * Prism Launcher - Minecraft Launcher
* Copyright (c) 2021-2022 Jamie Mansfield <jmansfield@cadixdev.org>
*
* This program is free software: you can redistribute it and/or modify
@@ -41,16 +41,15 @@
#include "ui/dialogs/NewInstanceDialog.h"
#include "BuildConfig.h"
+#include "Json.h"
#include "TechnicModel.h"
#include "modplatform/technic/SingleZipPackInstallTask.h"
#include "modplatform/technic/SolderPackInstallTask.h"
-#include "Json.h"
#include "Application.h"
#include "modplatform/technic/SolderPackManifest.h"
-TechnicPage::TechnicPage(NewInstanceDialog* dialog, QWidget *parent)
- : QWidget(parent), ui(new Ui::TechnicPage), dialog(dialog)
+TechnicPage::TechnicPage(NewInstanceDialog* dialog, QWidget* parent) : QWidget(parent), ui(new Ui::TechnicPage), dialog(dialog)
{
ui->setupUi(this);
connect(ui->searchButton, &QPushButton::clicked, this, &TechnicPage::triggerSearch);
@@ -96,7 +95,8 @@ void TechnicPage::openedImpl()
triggerSearch();
}
-void TechnicPage::triggerSearch() {
+void TechnicPage::triggerSearch()
+{
model->searchWithTerm(ui->searchEdit->text());
}
@@ -104,10 +104,8 @@ void TechnicPage::onSelectionChanged(QModelIndex first, QModelIndex second)
{
ui->versionSelectionBox->clear();
- if(!first.isValid())
- {
- if(isOpened)
- {
+ if (!first.isValid()) {
+ if (isOpened) {
dialog->setSuggestedPack();
}
return;
@@ -119,74 +117,60 @@ void TechnicPage::onSelectionChanged(QModelIndex first, QModelIndex second)
void TechnicPage::suggestCurrent()
{
- if (!isOpened)
- {
+ if (!isOpened) {
return;
}
- if (current.broken)
- {
+ if (current.broken) {
dialog->setSuggestedPack();
return;
}
QString editedLogoName = "technic_" + current.logoName.section(".", 0, 0);
- model->getLogo(current.logoName, current.logoUrl, [this, editedLogoName](QString logo)
- {
- dialog->setSuggestedIconFromFile(logo, editedLogoName);
- });
+ model->getLogo(current.logoName, current.logoUrl,
+ [this, editedLogoName](QString logo) { dialog->setSuggestedIconFromFile(logo, editedLogoName); });
- if (current.metadataLoaded)
- {
+ if (current.metadataLoaded) {
metadataLoaded();
return;
}
auto netJob = makeShared<NetJob>(QString("Technic::PackMeta(%1)").arg(current.name), APPLICATION->network());
QString slug = current.slug;
- netJob->addNetAction(Net::Download::makeByteArray(QString("%1modpack/%2?build=%3").arg(BuildConfig.TECHNIC_API_BASE_URL, slug, BuildConfig.TECHNIC_API_BUILD), response));
- QObject::connect(netJob.get(), &NetJob::succeeded, this, [this, slug]
- {
+ netJob->addNetAction(Net::Download::makeByteArray(
+ QString("%1modpack/%2?build=%3").arg(BuildConfig.TECHNIC_API_BASE_URL, slug, BuildConfig.TECHNIC_API_BUILD), response));
+ QObject::connect(netJob.get(), &NetJob::succeeded, this, [this, slug] {
jobPtr.reset();
- if (current.slug != slug)
- {
+ if (current.slug != slug) {
return;
}
- QJsonParseError parse_error {};
+ QJsonParseError parse_error{};
QJsonDocument doc = QJsonDocument::fromJson(*response, &parse_error);
QJsonObject obj = doc.object();
- if(parse_error.error != QJsonParseError::NoError)
- {
- qWarning() << "Error while parsing JSON response from Technic at " << parse_error.offset << " reason: " << parse_error.errorString();
+ if (parse_error.error != QJsonParseError::NoError) {
+ qWarning() << "Error while parsing JSON response from Technic at " << parse_error.offset
+ << " reason: " << parse_error.errorString();
qWarning() << *response;
return;
}
- if (!obj.contains("url"))
- {
+ if (!obj.contains("url")) {
qWarning() << "Json doesn't contain an url key";
return;
}
QJsonValueRef url = obj["url"];
- if (url.isString())
- {
+ if (url.isString()) {
current.url = url.toString();
- }
- else
- {
- if (!obj.contains("solder"))
- {
+ } else {
+ if (!obj.contains("solder")) {
qWarning() << "Json doesn't contain a valid url or solder key";
return;
}
QJsonValueRef solderUrl = obj["solder"];
- if (solderUrl.isString())
- {
+ if (solderUrl.isString()) {
current.url = solderUrl.toString();
current.isSolder = true;
- }
- else
- {
+ } else {
qWarning() << "Json doesn't contain a valid url or solder key";
return;
}
@@ -227,22 +211,21 @@ void TechnicPage::metadataLoaded()
// Strip trailing forward-slashes from Solder URL's
if (current.isSolder) {
- while (current.url.endsWith('/')) current.url.chop(1);
+ while (current.url.endsWith('/'))
+ current.url.chop(1);
}
// Display versions from Solder
if (!current.isSolder) {
// If the pack isn't a Solder pack, it only has the single version
ui->versionSelectionBox->addItem(current.currentVersion);
- }
- else if (current.versionsLoaded) {
+ } else if (current.versionsLoaded) {
// reverse foreach, so that the newest versions are first
for (auto i = current.versions.size(); i--;) {
ui->versionSelectionBox->addItem(current.versions.at(i));
}
ui->versionSelectionBox->setCurrentText(current.recommended);
- }
- else {
+ } else {
// For now, until the versions are pulled from the Solder instance, display the current
// version so we can display something quicker
ui->versionSelectionBox->addItem(current.currentVersion);
@@ -260,7 +243,8 @@ void TechnicPage::metadataLoaded()
selectVersion();
}
-void TechnicPage::selectVersion() {
+void TechnicPage::selectVersion()
+{
if (!isOpened) {
return;
}
@@ -269,17 +253,18 @@ void TechnicPage::selectVersion() {
return;
}
- if (!current.isSolder)
- {
- dialog->setSuggestedPack(current.name, selectedVersion, new Technic::SingleZipPackInstallTask(current.url, current.minecraftVersion));
- }
- else
- {
- dialog->setSuggestedPack(current.name, selectedVersion, new Technic::SolderPackInstallTask(APPLICATION->network(), current.url, current.slug, selectedVersion, current.minecraftVersion));
+ if (!current.isSolder) {
+ dialog->setSuggestedPack(current.name, selectedVersion,
+ new Technic::SingleZipPackInstallTask(current.url, current.minecraftVersion));
+ } else {
+ dialog->setSuggestedPack(current.name, selectedVersion,
+ new Technic::SolderPackInstallTask(APPLICATION->network(), current.url, current.slug, selectedVersion,
+ current.minecraftVersion));
}
}
-void TechnicPage::onSolderLoaded() {
+void TechnicPage::onSolderLoaded()
+{
jobPtr.reset();
auto fallback = [this]() {
@@ -319,7 +304,8 @@ void TechnicPage::onSolderLoaded() {
metadataLoaded();
}
-void TechnicPage::onVersionSelectionChanged(QString data) {
+void TechnicPage::onVersionSelectionChanged(QString data)
+{
if (data.isNull() || data.isEmpty()) {
selectedVersion = "";
return;
diff --git a/launcher/ui/pages/modplatform/technic/TechnicPage.h b/launcher/ui/pages/modplatform/technic/TechnicPage.h
index 753261b3..91b61eaf 100644
--- a/launcher/ui/pages/modplatform/technic/TechnicPage.h
+++ b/launcher/ui/pages/modplatform/technic/TechnicPage.h
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
- * PolyMC - Minecraft Launcher
+ * Prism Launcher - Minecraft Launcher
* Copyright (c) 2021-2022 Jamie Mansfield <jmansfield@cadixdev.org>
*
* This program is free software: you can redistribute it and/or modify
@@ -37,46 +37,32 @@
#include <QWidget>
-#include "ui/pages/BasePage.h"
#include <Application.h>
+#include "TechnicData.h"
#include "net/NetJob.h"
#include "tasks/Task.h"
-#include "TechnicData.h"
+#include "ui/pages/BasePage.h"
-namespace Ui
-{
+namespace Ui {
class TechnicPage;
}
class NewInstanceDialog;
namespace Technic {
- class ListModel;
+class ListModel;
}
-class TechnicPage : public QWidget, public BasePage
-{
+class TechnicPage : public QWidget, public BasePage {
Q_OBJECT
-public:
- explicit TechnicPage(NewInstanceDialog* dialog, QWidget *parent = 0);
+ public:
+ explicit TechnicPage(NewInstanceDialog* dialog, QWidget* parent = 0);
virtual ~TechnicPage();
- virtual QString displayName() const override
- {
- return "Technic";
- }
- virtual QIcon icon() const override
- {
- return APPLICATION->getThemedIcon("technic");
- }
- virtual QString id() const override
- {
- return "technic";
- }
- virtual QString helpPage() const override
- {
- return "Technic-platform";
- }
+ virtual QString displayName() const override { return "Technic"; }
+ virtual QIcon icon() const override { return APPLICATION->getThemedIcon("technic"); }
+ virtual QString id() const override { return "technic"; }
+ virtual QString helpPage() const override { return "Technic-platform"; }
virtual bool shouldDisplay() const override;
void retranslate() override;
@@ -84,19 +70,19 @@ public:
bool eventFilter(QObject* watched, QEvent* event) override;
-private:
+ private:
void suggestCurrent();
void metadataLoaded();
void selectVersion();
-private slots:
+ private slots:
void triggerSearch();
void onSelectionChanged(QModelIndex first, QModelIndex second);
void onSolderLoaded();
void onVersionSelectionChanged(QString data);
-private:
- Ui::TechnicPage *ui = nullptr;
+ private:
+ Ui::TechnicPage* ui = nullptr;
NewInstanceDialog* dialog = nullptr;
Technic::ListModel* model = nullptr;