From 6ccc7e77f918503125c363eb8ac9455aa9fc095e Mon Sep 17 00:00:00 2001 From: TheKodeToad Date: Mon, 19 Jun 2023 22:42:27 +0100 Subject: Basic, unfinished & broken impl Signed-off-by: TheKodeToad --- launcher/ui/pages/instance/VersionPage.cpp | 140 ++--------------------------- launcher/ui/pages/instance/VersionPage.h | 5 +- launcher/ui/pages/instance/VersionPage.ui | 71 ++++----------- 3 files changed, 23 insertions(+), 193 deletions(-) (limited to 'launcher/ui/pages/instance') diff --git a/launcher/ui/pages/instance/VersionPage.cpp b/launcher/ui/pages/instance/VersionPage.cpp index 74b7ec7c..97a6bbe4 100644 --- a/launcher/ui/pages/instance/VersionPage.cpp +++ b/launcher/ui/pages/instance/VersionPage.cpp @@ -52,6 +52,7 @@ #include #include "VersionPage.h" +#include "ui/dialogs/InstallLoaderDialog.h" #include "ui_VersionPage.h" #include "ui/dialogs/CustomMessageBox.h" @@ -254,20 +255,6 @@ void VersionPage::updateRunningStatus(bool running) 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); - - bool supportsQuilt = minecraftVersion >= Version("1.14"); - ui->actionInstall_Quilt->setEnabled(controlsEnabled && supportsQuilt); - - bool supportsLiteLoader = minecraftVersion <= Version("1.12.2"); - ui->actionInstall_LiteLoader->setEnabled(controlsEnabled && supportsLiteLoader); - updateButtons(); } @@ -287,7 +274,6 @@ void VersionPage::updateButtons(int row) ui->actionAdd_Empty->setEnabled(controlsEnabled); ui->actionImport_Components->setEnabled(controlsEnabled); ui->actionReload->setEnabled(controlsEnabled); - ui->actionInstall_mods->setEnabled(controlsEnabled); ui->actionReplace_Minecraft_jar->setEnabled(controlsEnabled); ui->actionAdd_to_Minecraft_jar->setEnabled(controlsEnabled); ui->actionAdd_Agents->setEnabled(controlsEnabled); @@ -446,17 +432,6 @@ void VersionPage::on_actionChange_version_triggered() return; } auto uid = list->uid(); - // FIXME: this is a horrible HACK. Get version filtering information from the actual metadata... - if(uid == "net.minecraftforge") - { - on_actionInstall_Forge_triggered(); - return; - } - 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") { @@ -508,87 +483,11 @@ void VersionPage::on_actionDownload_All_triggered() m_container->refreshContainer(); } -void VersionPage::on_actionInstall_Forge_triggered() +void VersionPage::on_actionInstall_Loader_triggered() { - auto vlist = APPLICATION->metadataIndex()->get("net.minecraftforge"); - 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.setEmptyErrorString(tr("Couldn't load or download the Forge version lists!")); - - auto currentVersion = m_profile->getComponentVersion("net.minecraftforge"); - if(!currentVersion.isEmpty()) - { - vselect.setCurrentVersion(currentVersion); - } - - 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); - m_container->refreshContainer(); - } -} - -void VersionPage::on_actionInstall_Fabric_triggered() -{ - auto vlist = APPLICATION->metadataIndex()->get("net.fabricmc.fabric-loader"); - if(!vlist) - { - return; - } - VersionSelectDialog vselect(vlist.get(), tr("Select Fabric Loader version"), this); - vselect.setEmptyString(tr("No Fabric Loader versions are currently available.")); - 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()) - { - vselect.setCurrentVersion(currentVersion); - } - - 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); - m_container->refreshContainer(); - } -} - -void VersionPage::on_actionInstall_Quilt_triggered() -{ - auto vlist = APPLICATION->metadataIndex()->get("org.quiltmc.quilt-loader"); - if(!vlist) - { - return; - } - VersionSelectDialog vselect(vlist.get(), tr("Select Quilt Loader version"), this); - vselect.setEmptyString(tr("No Quilt Loader versions are currently available.")); - 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()) - { - vselect.setCurrentVersion(currentVersion); - } - - 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); - m_container->refreshContainer(); - } + InstallLoaderDialog dialog(m_inst->getPackProfile(), this); + dialog.exec(); + m_container->refreshContainer(); } void VersionPage::on_actionAdd_Empty_triggered() @@ -609,35 +508,6 @@ void VersionPage::on_actionAdd_Empty_triggered() } } -void VersionPage::on_actionInstall_LiteLoader_triggered() -{ - auto vlist = APPLICATION->metadataIndex()->get("com.mumfrey.liteloader"); - 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.setEmptyErrorString(tr("Couldn't load or download the LiteLoader version lists!")); - - auto currentVersion = m_profile->getComponentVersion("com.mumfrey.liteloader"); - if(!currentVersion.isEmpty()) - { - vselect.setCurrentVersion(currentVersion); - } - - 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); - m_container->refreshContainer(); - } -} - void VersionPage::on_actionLibrariesFolder_triggered() { DesktopServices::openDirectory(m_inst->getLocalLibraryPath(), true); diff --git a/launcher/ui/pages/instance/VersionPage.h b/launcher/ui/pages/instance/VersionPage.h index d0087714..0dcb4635 100644 --- a/launcher/ui/pages/instance/VersionPage.h +++ b/launcher/ui/pages/instance/VersionPage.h @@ -79,11 +79,8 @@ public: private slots: void on_actionChange_version_triggered(); - void on_actionInstall_Forge_triggered(); - void on_actionInstall_Fabric_triggered(); - void on_actionInstall_Quilt_triggered(); + void on_actionInstall_Loader_triggered(); void on_actionAdd_Empty_triggered(); - void on_actionInstall_LiteLoader_triggered(); void on_actionReload_triggered(); void on_actionRemove_triggered(); void on_actionMove_up_triggered(); diff --git a/launcher/ui/pages/instance/VersionPage.ui b/launcher/ui/pages/instance/VersionPage.ui index 4777eafe..cf7c659b 100644 --- a/launcher/ui/pages/instance/VersionPage.ui +++ b/launcher/ui/pages/instance/VersionPage.ui @@ -98,12 +98,7 @@ - - - - - - + @@ -118,26 +113,26 @@ - Change version + Change Version - Change version of the selected package. + Change version of the selected component. - Move up + Move Up - Make the selected package apply sooner. + Make the selected component apply sooner. - Move down + Move Down - Make the selected package apply later. + Make the selected component apply later. @@ -145,7 +140,7 @@ Remove - Remove selected package from the instance. + Remove selected component from the instance. @@ -153,7 +148,7 @@ Customize - Customize selected package. + Customize selected component. @@ -161,7 +156,7 @@ Edit - Edit selected package. + Edit selected component. @@ -169,47 +164,15 @@ Revert - Revert the selected package to default. - - - - - Install Forge - - - Install the Minecraft Forge package. - - - - - Install Fabric - - - Install the Fabric Loader package. - - - - - Install Quilt - - - Install the Quilt Loader package. - - - - - Install LiteLoader - - - Install the LiteLoader package. + Revert the selected component to default. - + - Install mods + Install Loader - Install normal mods. + Install a mod loader. @@ -238,7 +201,7 @@ Add Empty - Add an empty custom package. + Add an empty custom component. @@ -246,12 +209,12 @@ Reload - Reload all packages. + Reload all components. - Download All + Download all Download the files needed to launch the instance now. -- cgit From 82d3755e25fc01e3468e6940abab9dcc0a819e22 Mon Sep 17 00:00:00 2001 From: TheKodeToad Date: Mon, 19 Jun 2023 23:36:18 +0100 Subject: License all the things Signed-off-by: TheKodeToad --- launcher/ui/pages/instance/VersionPage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'launcher/ui/pages/instance') diff --git a/launcher/ui/pages/instance/VersionPage.cpp b/launcher/ui/pages/instance/VersionPage.cpp index 97a6bbe4..53a71008 100644 --- a/launcher/ui/pages/instance/VersionPage.cpp +++ b/launcher/ui/pages/instance/VersionPage.cpp @@ -6,7 +6,7 @@ * Prism Launcher - Minecraft Launcher * Copyright (c) 2022 Jamie Mansfield * Copyright (C) 2022-2023 Sefa Eyeoglu - * Copyright (C) 2022 TheKodeToad + * Copyright (C) 2023 TheKodeToad * * 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 -- cgit From 9c10965997d873b0de56deef5d5ec5e768db1d8f Mon Sep 17 00:00:00 2001 From: Rachel Powers <508861+Ryex@users.noreply.github.com> Date: Thu, 1 Jun 2023 16:39:04 -0700 Subject: refactor: split out setting api headers for downloads Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com> --- launcher/ui/pages/instance/ManagedPackPage.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'launcher/ui/pages/instance') diff --git a/launcher/ui/pages/instance/ManagedPackPage.cpp b/launcher/ui/pages/instance/ManagedPackPage.cpp index d0701a7a..68119f06 100644 --- a/launcher/ui/pages/instance/ManagedPackPage.cpp +++ b/launcher/ui/pages/instance/ManagedPackPage.cpp @@ -23,6 +23,8 @@ #include "ui/dialogs/CustomMessageBox.h" #include "ui/dialogs/ProgressDialog.h" +#include "net/ApiDownload.h" + /** This is just to override the combo box popup behavior so that the combo box doesn't take the whole screen. * ... thanks Qt. */ @@ -226,7 +228,7 @@ 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.get())); + m_fetch_job->addNetAction(Net::ApiDownload::makeByteArray(QString("%1/project/%2/version").arg(BuildConfig.MODRINTH_PROD_URL, id), response.get())); QObject::connect(m_fetch_job.get(), &NetJob::succeeded, this, [this, response, id] { QJsonParseError parse_error{}; @@ -369,7 +371,7 @@ void FlameManagedPackPage::parseManagedPack() QString id = m_inst->getManagedPackID(); - m_fetch_job->addNetAction(Net::Download::makeByteArray(QString("%1/mods/%2/files").arg(BuildConfig.FLAME_BASE_URL, id), response.get())); + m_fetch_job->addNetAction(Net::ApiDownload::makeByteArray(QString("%1/mods/%2/files").arg(BuildConfig.FLAME_BASE_URL, id), response.get())); QObject::connect(m_fetch_job.get(), &NetJob::succeeded, this, [this, response, id] { QJsonParseError parse_error{}; -- cgit From 4cdf669154327b764ea2f7371e3d29f71d06daa7 Mon Sep 17 00:00:00 2001 From: TheKodeToad Date: Sat, 1 Jul 2023 17:02:39 +0100 Subject: Modify "Change Version" to use "Install Loader" dialog Signed-off-by: TheKodeToad --- launcher/ui/pages/instance/VersionPage.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'launcher/ui/pages/instance') diff --git a/launcher/ui/pages/instance/VersionPage.cpp b/launcher/ui/pages/instance/VersionPage.cpp index 53a71008..86ba5c27 100644 --- a/launcher/ui/pages/instance/VersionPage.cpp +++ b/launcher/ui/pages/instance/VersionPage.cpp @@ -432,6 +432,16 @@ void VersionPage::on_actionChange_version_triggered() return; } auto uid = list->uid(); + + // FIXME: this is still a horrible HACK. + if (uid == "net.minecraftforge" || uid == "com.mumfrey.liteloader" || uid == "net.fabricmc.fabric-loader" || + uid == "org.quiltmc.quilt-loader") { + InstallLoaderDialog dialog(m_inst->getPackProfile(), uid, this); + dialog.exec(); + m_container->refreshContainer(); + return; + } + VersionSelectDialog vselect(list.get(), tr("Change %1 version").arg(name), this); if (uid == "net.fabricmc.intermediary" || uid == "org.quiltmc.hashed") { @@ -485,7 +495,7 @@ void VersionPage::on_actionDownload_All_triggered() void VersionPage::on_actionInstall_Loader_triggered() { - InstallLoaderDialog dialog(m_inst->getPackProfile(), this); + InstallLoaderDialog dialog(m_inst->getPackProfile(), QString(), this); dialog.exec(); m_container->refreshContainer(); } -- cgit From 6cc3587da2a87c87d37f205fd39a31a5a136814a Mon Sep 17 00:00:00 2001 From: TheKodeToad Date: Sat, 1 Jul 2023 20:10:38 +0100 Subject: Disable as intended Signed-off-by: TheKodeToad --- launcher/ui/pages/instance/VersionPage.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'launcher/ui/pages/instance') diff --git a/launcher/ui/pages/instance/VersionPage.cpp b/launcher/ui/pages/instance/VersionPage.cpp index 86ba5c27..31e0b9b3 100644 --- a/launcher/ui/pages/instance/VersionPage.cpp +++ b/launcher/ui/pages/instance/VersionPage.cpp @@ -274,8 +274,9 @@ void VersionPage::updateButtons(int row) ui->actionAdd_Empty->setEnabled(controlsEnabled); ui->actionImport_Components->setEnabled(controlsEnabled); ui->actionReload->setEnabled(controlsEnabled); - ui->actionReplace_Minecraft_jar->setEnabled(controlsEnabled); + ui->actionInstall_Loader->setEnabled(controlsEnabled); ui->actionAdd_to_Minecraft_jar->setEnabled(controlsEnabled); + ui->actionReplace_Minecraft_jar->setEnabled(controlsEnabled); ui->actionAdd_Agents->setEnabled(controlsEnabled); } -- cgit From 8d7dcdfc5b2a231a1304878e25929e6f4ff4e338 Mon Sep 17 00:00:00 2001 From: Rachel Powers <508861+Ryex@users.noreply.github.com> Date: Fri, 30 Jun 2023 23:51:15 -0700 Subject: chore: fix shadowed member and signed/unsigned mismatch Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com> chore: supress unused with [[maybe_unused]] Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com> chore: unshadow ^&^& static_cast implicit return Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com> chore: deshadow and mark unused in parse task Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com> chore: mark unused in folder models Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com> chore: deshadow and mark unused with instances Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com> chore: more deshadow and unused Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com> chore: remove uneeded simicolons Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com> chore: mark unused Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com> chore: prevent shadow Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com> --- .../ui/pages/instance/ExternalResourcesPage.cpp | 2 +- .../ui/pages/instance/InstanceSettingsPage.cpp | 2 +- launcher/ui/pages/instance/ModFolderPage.cpp | 2 +- launcher/ui/pages/instance/OtherLogsPage.cpp | 22 +++++++++++----------- launcher/ui/pages/instance/ResourcePackPage.cpp | 2 +- launcher/ui/pages/instance/ServersPage.cpp | 4 ++-- launcher/ui/pages/instance/TexturePackPage.cpp | 2 +- launcher/ui/pages/instance/VersionPage.cpp | 4 ++-- launcher/ui/pages/instance/WorldListPage.cpp | 2 +- 9 files changed, 21 insertions(+), 21 deletions(-) (limited to 'launcher/ui/pages/instance') diff --git a/launcher/ui/pages/instance/ExternalResourcesPage.cpp b/launcher/ui/pages/instance/ExternalResourcesPage.cpp index 173bcb66..5a7100b1 100644 --- a/launcher/ui/pages/instance/ExternalResourcesPage.cpp +++ b/launcher/ui/pages/instance/ExternalResourcesPage.cpp @@ -300,7 +300,7 @@ bool ExternalResourcesPage::current(const QModelIndex& current, const QModelInde return onSelectionChanged(current, previous); } -bool ExternalResourcesPage::onSelectionChanged(const QModelIndex& current, const QModelIndex& previous) +bool ExternalResourcesPage::onSelectionChanged(const QModelIndex& current, [[maybe_unused]] const QModelIndex& previous) { auto sourceCurrent = m_filterModel->mapToSource(current); int row = sourceCurrent.row(); diff --git a/launcher/ui/pages/instance/InstanceSettingsPage.cpp b/launcher/ui/pages/instance/InstanceSettingsPage.cpp index 2a7c5b27..311ebc86 100644 --- a/launcher/ui/pages/instance/InstanceSettingsPage.cpp +++ b/launcher/ui/pages/instance/InstanceSettingsPage.cpp @@ -482,7 +482,7 @@ void InstanceSettingsPage::changeInstanceAccount(int index) } } -void InstanceSettingsPage::on_maxMemSpinBox_valueChanged(int i) +void InstanceSettingsPage::on_maxMemSpinBox_valueChanged([[maybe_unused]] int i) { updateThresholds(); } diff --git a/launcher/ui/pages/instance/ModFolderPage.cpp b/launcher/ui/pages/instance/ModFolderPage.cpp index 90e7d0d6..f6b1a71c 100644 --- a/launcher/ui/pages/instance/ModFolderPage.cpp +++ b/launcher/ui/pages/instance/ModFolderPage.cpp @@ -122,7 +122,7 @@ bool ModFolderPage::shouldDisplay() const return true; } -bool ModFolderPage::onSelectionChanged(const QModelIndex& current, const QModelIndex& previous) +bool ModFolderPage::onSelectionChanged(const QModelIndex& current, [[maybe_unused]] const QModelIndex& previous) { auto sourceCurrent = m_filterModel->mapToSource(current); int row = sourceCurrent.row(); diff --git a/launcher/ui/pages/instance/OtherLogsPage.cpp b/launcher/ui/pages/instance/OtherLogsPage.cpp index bbdd7324..f2b13f32 100644 --- a/launcher/ui/pages/instance/OtherLogsPage.cpp +++ b/launcher/ui/pages/instance/OtherLogsPage.cpp @@ -287,23 +287,23 @@ void OtherLogsPage::on_btnClean_clicked() } if(!failed.empty()) { - QMessageBox *messageBox = new QMessageBox(this); - messageBox->setWindowTitle(tr("Error")); + QMessageBox *messageBoxFailure = new QMessageBox(this); + messageBoxFailure->setWindowTitle(tr("Error")); if(failed.size() > 5) { - messageBox->setText(tr("Couldn't delete some files!")); - messageBox->setDetailedText(failed.join('\n')); + messageBoxFailure->setText(tr("Couldn't delete some files!")); + messageBoxFailure->setDetailedText(failed.join('\n')); } else { - messageBox->setText(tr("Couldn't delete some files:\n%1").arg(failed.join('\n'))); + messageBoxFailure->setText(tr("Couldn't delete some files:\n%1").arg(failed.join('\n'))); } - messageBox->setStandardButtons(QMessageBox::Ok); - messageBox->setDefaultButton(QMessageBox::Ok); - messageBox->setTextInteractionFlags(Qt::TextSelectableByMouse); - messageBox->setIcon(QMessageBox::Critical); - messageBox->setTextInteractionFlags(Qt::TextBrowserInteraction); - messageBox->exec(); + messageBoxFailure->setStandardButtons(QMessageBox::Ok); + messageBoxFailure->setDefaultButton(QMessageBox::Ok); + messageBoxFailure->setTextInteractionFlags(Qt::TextSelectableByMouse); + messageBoxFailure->setIcon(QMessageBox::Critical); + messageBoxFailure->setTextInteractionFlags(Qt::TextBrowserInteraction); + messageBoxFailure->exec(); } } diff --git a/launcher/ui/pages/instance/ResourcePackPage.cpp b/launcher/ui/pages/instance/ResourcePackPage.cpp index 24bfb38d..2696acfc 100644 --- a/launcher/ui/pages/instance/ResourcePackPage.cpp +++ b/launcher/ui/pages/instance/ResourcePackPage.cpp @@ -55,7 +55,7 @@ ResourcePackPage::ResourcePackPage(MinecraftInstance* instance, std::shared_ptr< ui->actionViewConfigs->setVisible(false); } -bool ResourcePackPage::onSelectionChanged(const QModelIndex& current, const QModelIndex& previous) +bool ResourcePackPage::onSelectionChanged(const QModelIndex& current, [[maybe_unused]] const QModelIndex& previous) { auto sourceCurrent = m_filterModel->mapToSource(current); int row = sourceCurrent.row(); diff --git a/launcher/ui/pages/instance/ServersPage.cpp b/launcher/ui/pages/instance/ServersPage.cpp index 4b1fa08a..09ed9e40 100644 --- a/launcher/ui/pages/instance/ServersPage.cpp +++ b/launcher/ui/pages/instance/ServersPage.cpp @@ -684,7 +684,7 @@ void ServersPage::runningStateChanged(bool running) updateState(); } -void ServersPage::currentChanged(const QModelIndex ¤t, const QModelIndex &previous) +void ServersPage::currentChanged(const QModelIndex ¤t, [[maybe_unused]] const QModelIndex &previous) { int nextServer = -1; if (!current.isValid()) @@ -700,7 +700,7 @@ void ServersPage::currentChanged(const QModelIndex ¤t, 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) +void ServersPage::rowsRemoved([[maybe_unused]] const QModelIndex& parent, int first, int last) { if(currentServer < first) { diff --git a/launcher/ui/pages/instance/TexturePackPage.cpp b/launcher/ui/pages/instance/TexturePackPage.cpp index 427aba11..f7b3bc8d 100644 --- a/launcher/ui/pages/instance/TexturePackPage.cpp +++ b/launcher/ui/pages/instance/TexturePackPage.cpp @@ -57,7 +57,7 @@ TexturePackPage::TexturePackPage(MinecraftInstance* instance, std::shared_ptractionViewConfigs->setVisible(false); } -bool TexturePackPage::onSelectionChanged(const QModelIndex& current, const QModelIndex& previous) +bool TexturePackPage::onSelectionChanged(const QModelIndex& current, [[maybe_unused]] const QModelIndex& previous) { auto sourceCurrent = m_filterModel->mapToSource(current); int row = sourceCurrent.row(); diff --git a/launcher/ui/pages/instance/VersionPage.cpp b/launcher/ui/pages/instance/VersionPage.cpp index 59107c53..e3cef0d7 100644 --- a/launcher/ui/pages/instance/VersionPage.cpp +++ b/launcher/ui/pages/instance/VersionPage.cpp @@ -202,7 +202,7 @@ void VersionPage::showContextMenu(const QPoint& pos) delete menu; } -void VersionPage::packageCurrent(const QModelIndex ¤t, const QModelIndex &previous) +void VersionPage::packageCurrent(const QModelIndex ¤t, [[maybe_unused]] const QModelIndex &previous) { if (!current.isValid()) { @@ -647,7 +647,7 @@ void VersionPage::on_actionMinecraftFolder_triggered() DesktopServices::openDirectory(m_inst->gameRoot(), true); } -void VersionPage::versionCurrent(const QModelIndex ¤t, const QModelIndex &previous) +void VersionPage::versionCurrent(const QModelIndex ¤t, [[maybe_unused]] const QModelIndex &previous) { currentIdx = current.row(); updateButtons(currentIdx); diff --git a/launcher/ui/pages/instance/WorldListPage.cpp b/launcher/ui/pages/instance/WorldListPage.cpp index b6ad159e..d961a382 100644 --- a/launcher/ui/pages/instance/WorldListPage.cpp +++ b/launcher/ui/pages/instance/WorldListPage.cpp @@ -352,7 +352,7 @@ void WorldListPage::mceditState(LoggedProcess::State state) } } -void WorldListPage::worldChanged(const QModelIndex ¤t, const QModelIndex &previous) +void WorldListPage::worldChanged([[maybe_unused]] const QModelIndex ¤t, [[maybe_unused]] const QModelIndex &previous) { QModelIndex index = getSelectedWorld(); bool enable = index.isValid(); -- cgit From 64c591b234cec2519d8a04b32d4b6e85dcf204da Mon Sep 17 00:00:00 2001 From: TheKodeToad Date: Mon, 3 Jul 2023 20:48:37 +0100 Subject: Better parent version filtering; handle old fabric :P Signed-off-by: TheKodeToad --- launcher/ui/pages/instance/VersionPage.cpp | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) (limited to 'launcher/ui/pages/instance') diff --git a/launcher/ui/pages/instance/VersionPage.cpp b/launcher/ui/pages/instance/VersionPage.cpp index 31e0b9b3..a8e6e948 100644 --- a/launcher/ui/pages/instance/VersionPage.cpp +++ b/launcher/ui/pages/instance/VersionPage.cpp @@ -434,22 +434,14 @@ void VersionPage::on_actionChange_version_triggered() } auto uid = list->uid(); - // FIXME: this is still a horrible HACK. - if (uid == "net.minecraftforge" || uid == "com.mumfrey.liteloader" || uid == "net.fabricmc.fabric-loader" || - uid == "org.quiltmc.quilt-loader") { - InstallLoaderDialog dialog(m_inst->getPackProfile(), uid, this); - dialog.exec(); - m_container->refreshContainer(); - return; - } - VersionSelectDialog vselect(list.get(), tr("Change %1 version").arg(name), this); 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")); } + vselect.setExactIfPresentFilter(BaseVersionList::ParentVersionRole, m_profile->getComponentVersion("net.minecraft")); + auto currentVersion = patch->getVersion(); if(!currentVersion.isEmpty()) { -- cgit From f9578066d6b9d2813e05ad6501935304a787ce52 Mon Sep 17 00:00:00 2001 From: leo78913 Date: Wed, 28 Jun 2023 17:30:11 -0300 Subject: make "browse" buttons and java pages more consistent Signed-off-by: leo78913 --- launcher/ui/pages/instance/InstanceSettingsPage.ui | 62 ++++++++++++---------- 1 file changed, 33 insertions(+), 29 deletions(-) (limited to 'launcher/ui/pages/instance') diff --git a/launcher/ui/pages/instance/InstanceSettingsPage.ui b/launcher/ui/pages/instance/InstanceSettingsPage.ui index 8427965d..277deb2a 100644 --- a/launcher/ui/pages/instance/InstanceSettingsPage.ui +++ b/launcher/ui/pages/instance/InstanceSettingsPage.ui @@ -61,31 +61,7 @@ false - - - - - - - Auto-detect... - - - - - - - Browse... - - - - - - - Test - - - - + If enabled, the launcher will not check if an instance is compatible with the selected Java version. @@ -95,6 +71,38 @@ + + + + + + + + + Browse + + + + + + + + + + + Auto-detect... + + + + + + + Test + + + + + @@ -674,10 +682,6 @@ openGlobalJavaSettingsButton settingsTabs javaSettingsGroupBox - javaPathTextBox - javaDetectBtn - javaBrowseBtn - javaTestBtn memoryGroupBox minMemSpinBox maxMemSpinBox -- cgit From a3ffa6455021b69bd1940b65fefb3b6177c96730 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Sun, 16 Jul 2023 01:59:08 +0300 Subject: Upgraded pack changelog Signed-off-by: Trial97 --- launcher/ui/pages/instance/ManagedPackPage.cpp | 16 ++++++++++++++++ launcher/ui/pages/instance/ManagedPackPage.ui | 12 +++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) (limited to 'launcher/ui/pages/instance') diff --git a/launcher/ui/pages/instance/ManagedPackPage.cpp b/launcher/ui/pages/instance/ManagedPackPage.cpp index 0fc0c986..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 +#include +#include #include "ui_ManagedPackPage.h" #include @@ -103,6 +106,19 @@ ManagedPackPage::ManagedPackPage(BaseInstance* inst, InstanceWindow* instance_wi // 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() 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 @@ - + No changelog available for this version! + + false + @@ -188,6 +191,13 @@ + + + ProjectDescriptionPage + QTextBrowser +
ui/widgets/ProjectDescriptionPage.h
+
+
-- cgit From 91ba4cf75ee30c64779edb5b7644e5a830de5026 Mon Sep 17 00:00:00 2001 From: Sefa Eyeoglu Date: Mon, 14 Aug 2023 18:16:53 +0200 Subject: chore: reformat Signed-off-by: Sefa Eyeoglu --- launcher/ui/pages/instance/ExternalResourcesPage.h | 4 +- launcher/ui/pages/instance/GameOptionsPage.cpp | 11 +- launcher/ui/pages/instance/GameOptionsPage.h | 38 +- .../ui/pages/instance/InstanceSettingsPage.cpp | 127 ++----- launcher/ui/pages/instance/InstanceSettingsPage.h | 36 +- launcher/ui/pages/instance/LogPage.cpp | 146 +++----- launcher/ui/pages/instance/LogPage.h | 44 +-- launcher/ui/pages/instance/NotesPage.cpp | 5 +- launcher/ui/pages/instance/NotesPage.h | 35 +- launcher/ui/pages/instance/OtherLogsPage.cpp | 140 +++----- launcher/ui/pages/instance/OtherLogsPage.h | 42 +-- launcher/ui/pages/instance/ResourcePackPage.h | 11 +- launcher/ui/pages/instance/ScreenshotsPage.cpp | 244 ++++++------- launcher/ui/pages/instance/ScreenshotsPage.h | 58 +--- launcher/ui/pages/instance/ServersPage.cpp | 382 ++++++++------------- launcher/ui/pages/instance/ServersPage.h | 59 ++-- launcher/ui/pages/instance/ShaderPackPage.h | 7 +- launcher/ui/pages/instance/TexturePackPage.h | 12 +- launcher/ui/pages/instance/VersionPage.cpp | 1 - launcher/ui/pages/instance/WorldListPage.cpp | 177 ++++------ launcher/ui/pages/instance/WorldListPage.h | 64 ++-- 21 files changed, 598 insertions(+), 1045 deletions(-) (limited to 'launcher/ui/pages/instance') diff --git a/launcher/ui/pages/instance/ExternalResourcesPage.h b/launcher/ui/pages/instance/ExternalResourcesPage.h index 97d922d8..d29be0fc 100644 --- a/launcher/ui/pages/instance/ExternalResourcesPage.h +++ b/launcher/ui/pages/instance/ExternalResourcesPage.h @@ -4,8 +4,8 @@ #include #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(); diff --git a/launcher/ui/pages/instance/GameOptionsPage.cpp b/launcher/ui/pages/instance/GameOptionsPage.cpp index 63443166..e9004170 100644 --- a/launcher/ui/pages/instance/GameOptionsPage.cpp +++ b/launcher/ui/pages/instance/GameOptionsPage.cpp @@ -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..563bd10a 100644 --- a/launcher/ui/pages/instance/GameOptionsPage.h +++ b/launcher/ui/pages/instance/GameOptionsPage.h @@ -35,50 +35,36 @@ #pragma once -#include #include +#include -#include "ui/pages/BasePage.h" #include +#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 m_model; }; diff --git a/launcher/ui/pages/instance/InstanceSettingsPage.cpp b/launcher/ui/pages/instance/InstanceSettingsPage.cpp index 718c628c..8ea24b78 100644 --- a/launcher/ui/pages/instance/InstanceSettingsPage.cpp +++ b/launcher/ui/pages/instance/InstanceSettingsPage.cpp @@ -38,8 +38,8 @@ #include "InstanceSettingsPage.h" #include "ui_InstanceSettingsPage.h" -#include #include +#include #include #include @@ -47,15 +47,15 @@ #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" -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(); @@ -78,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; @@ -104,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"); } @@ -118,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"); @@ -134,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"); @@ -150,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"); @@ -176,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"); } @@ -190,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"); } @@ -205,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"); @@ -221,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"); } @@ -235,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"); @@ -251,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"); } @@ -265,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"); } @@ -316,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); } @@ -332,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; @@ -346,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()); @@ -408,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(vselect.selectedVersion()); ui->javaPathTextBox->setText(java->path); bool visible = java->id.requiresPermGen() && m_settings->get("OverrideMemory").toBool(); @@ -425,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); @@ -447,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(); } @@ -470,7 +420,6 @@ void InstanceSettingsPage::updateAccountsMenu() if (i == accountIndex) ui->instanceAccountSelector->setCurrentIndex(i); } - } QIcon InstanceSettingsPage::getFaceForAccount(MinecraftAccountPtr account) diff --git a/launcher/ui/pages/instance/InstanceSettingsPage.h b/launcher/ui/pages/instance/InstanceSettingsPage.h index 036b4181..9f135593 100644 --- a/launcher/ui/pages/instance/InstanceSettingsPage.h +++ b/launcher/ui/pages/instance/InstanceSettingsPage.h @@ -46,35 +46,21 @@ #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(); @@ -96,9 +82,9 @@ public: 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 checker; }; 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 -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 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 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)));