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/dialogs/InstallLoaderDialog.cpp | 121 +++++++++++++++++++++++++ launcher/ui/dialogs/InstallLoaderDialog.h | 42 +++++++++ launcher/ui/dialogs/ResourceDownloadDialog.cpp | 26 ++---- launcher/ui/dialogs/ResourceDownloadDialog.h | 3 +- 4 files changed, 170 insertions(+), 22 deletions(-) create mode 100644 launcher/ui/dialogs/InstallLoaderDialog.cpp create mode 100644 launcher/ui/dialogs/InstallLoaderDialog.h (limited to 'launcher/ui/dialogs') diff --git a/launcher/ui/dialogs/InstallLoaderDialog.cpp b/launcher/ui/dialogs/InstallLoaderDialog.cpp new file mode 100644 index 00000000..34c91c68 --- /dev/null +++ b/launcher/ui/dialogs/InstallLoaderDialog.cpp @@ -0,0 +1,121 @@ +#include "InstallLoaderDialog.h" + +#include +#include +#include +#include "Application.h" +#include "BuildConfig.h" +#include "DesktopServices.h" +#include "meta/Index.h" +#include "minecraft/MinecraftInstance.h" +#include "minecraft/PackProfile.h" +#include "ui/widgets/PageContainer.h" +#include "ui/widgets/VersionSelectWidget.h" + +class LoaderPage : public VersionSelectWidget, public BasePage { + public: + LoaderPage(const QString&& id, + const QString&& icon, + const QString&& name, + // "lightweight" loaders are independent to any game version + const bool lightweight, + const std::shared_ptr profile, + QWidget* parent = nullptr) + : VersionSelectWidget(parent), m_id(std::move(id)), m_icon(std::move(icon)), m_name(std::move(name)) + { + const QString minecraftVersion = profile->getComponentVersion("net.minecraft"); + setEmptyErrorString(tr("No versions are currently available for Minecraft %1").arg(minecraftVersion)); + if (!lightweight) + setExactFilter(BaseVersionList::ParentVersionRole, minecraftVersion); + + if (const QString currentVersion = profile->getComponentVersion(id); !currentVersion.isNull()) + setCurrentVersion(currentVersion); + } + + QString id() const override { return m_id; } + QString displayName() const override { return m_name; } + QIcon icon() const override { return APPLICATION->getThemedIcon(m_icon); } + + void openedImpl() override + { + if (m_loaded) + return; + + const auto versions = APPLICATION->metadataIndex()->get(m_id); + if (!versions) + return; + + initialize(versions.get()); + m_loaded = true; + } + + private: + const QString m_id; + const QString m_icon; + const QString m_name; + bool m_loaded = false; +}; + +InstallLoaderDialog::InstallLoaderDialog(std::shared_ptr profile, QWidget* parent) + : QDialog(parent), m_profile(profile), m_container(new PageContainer(this)) +{ + auto layout = new QVBoxLayout(this); + + m_container->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); + layout->addWidget(m_container); + + auto buttonLayout = new QHBoxLayout(this); + + auto refreshButton = new QPushButton(tr("&Refresh"), this); + connect(refreshButton, &QPushButton::pressed, this, [this] { + LoaderPage* page = dynamic_cast(m_container->selectedPage()); + Q_ASSERT(page != nullptr); + page->loadList(); + }); + buttonLayout->addWidget(refreshButton); + + auto buttons = new QDialogButtonBox(this); + buttons->setOrientation(Qt::Horizontal); + buttons->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::Ok); + connect(buttons, &QDialogButtonBox::accepted, this, &QDialog::accept); + connect(buttons, &QDialogButtonBox::rejected, this, &QDialog::reject); + buttonLayout->addWidget(buttons); + + layout->addLayout(buttonLayout); + + setWindowTitle(dialogTitle()); + resize(650, 400); +} + +QList InstallLoaderDialog::getPages() +{ + return { // Fabric + new LoaderPage("net.fabricmc.fabric-loader", "fabric-loader", tr("Fabric"), true, m_profile, this), + // Quilt + new LoaderPage("org.quiltmc.quilt-loader", "quilt-loader", tr("Quilt"), true, m_profile, this), + // Forge + new LoaderPage("net.minecraftforge", "forge-loader", tr("Forge"), false, m_profile, this), + // LiteLoader + new LoaderPage("com.mumfrey.liteloader", "liteloader", tr("LiteLoader"), false, m_profile, this) + }; +} + +QString InstallLoaderDialog::dialogTitle() +{ + return tr("Install Loader"); +} + +void InstallLoaderDialog::done(int result) +{ + if (result == Accepted) { + LoaderPage* page = dynamic_cast(m_container->selectedPage()); + Q_ASSERT(page != nullptr); + + if (page->selectedVersion()) { + m_profile->setComponentVersion(page->id(), page->selectedVersion()->descriptor()); + m_profile->resolve(Net::Mode::Online); + } + } + + QDialog::done(result); +} diff --git a/launcher/ui/dialogs/InstallLoaderDialog.h b/launcher/ui/dialogs/InstallLoaderDialog.h new file mode 100644 index 00000000..26b39e4a --- /dev/null +++ b/launcher/ui/dialogs/InstallLoaderDialog.h @@ -0,0 +1,42 @@ +// SPDX-License-Identifier: GPL-3.0-only +/* + * Prism Launcher - Minecraft Launcher + * Copyright (C) 2022 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 + * 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 . + */ + +#pragma once + +#include +#include "ui/pages/BasePageProvider.h" + +class MinecraftInstance; +class PageContainer; +class PackProfile; + +class InstallLoaderDialog : public QDialog, public BasePageProvider { + Q_OBJECT + + public: + explicit InstallLoaderDialog(std::shared_ptr instance, QWidget* parent = nullptr); + + QList getPages() override; + QString dialogTitle() override; + + void done(int result) override; + + private: + std::shared_ptr m_profile; + PageContainer* m_container; +}; diff --git a/launcher/ui/dialogs/ResourceDownloadDialog.cpp b/launcher/ui/dialogs/ResourceDownloadDialog.cpp index 6d90480f..784662a0 100644 --- a/launcher/ui/dialogs/ResourceDownloadDialog.cpp +++ b/launcher/ui/dialogs/ResourceDownloadDialog.cpp @@ -148,15 +148,17 @@ bool ResourceDownloadDialog::selectPage(QString pageId) return m_container->selectPage(pageId); } -ResourcePage* ResourceDownloadDialog::getSelectedPage() +ResourcePage* ResourceDownloadDialog::selectedPage() { - return m_selectedPage; + ResourcePage* result = dynamic_cast(m_container->selectedPage()); + Q_ASSERT(result != nullptr); + return result; } void ResourceDownloadDialog::addResource(ModPlatform::IndexedPack::Ptr pack, ModPlatform::IndexedVersion& ver) { removeResource(pack->name); - m_selectedPage->addResourceToPage(pack, ver, getBaseModel()); + selectedPage()->addResourceToPage(pack, ver, getBaseModel()); setButtonStatus(); } @@ -196,14 +198,8 @@ void ResourceDownloadDialog::selectedPageChanged(BasePage* previous, BasePage* s return; } - m_selectedPage = dynamic_cast(selected); - if (!m_selectedPage) { - qCritical() << "Page '" << selected->displayName() << "' in ResourceDownloadDialog is not a ResourcePage!"; - return; - } - // Same effect as having a global search bar - m_selectedPage->setSearchTerm(prev_page->getSearchTerm()); + selectedPage()->setSearchTerm(prev_page->getSearchTerm()); } ModDownloadDialog::ModDownloadDialog(QWidget* parent, const std::shared_ptr& mods, BaseInstance* instance) @@ -226,8 +222,6 @@ QList ModDownloadDialog::getPages() if (APPLICATION->capabilities() & Application::SupportsFlame) pages.append(FlameModPage::create(this, *m_instance)); - m_selectedPage = dynamic_cast(pages[0]); - return pages; } @@ -253,8 +247,6 @@ QList ResourcePackDownloadDialog::getPages() if (APPLICATION->capabilities() & Application::SupportsFlame) pages.append(FlameResourcePackPage::create(this, *m_instance)); - m_selectedPage = dynamic_cast(pages[0]); - return pages; } @@ -280,8 +272,6 @@ QList TexturePackDownloadDialog::getPages() if (APPLICATION->capabilities() & Application::SupportsFlame) pages.append(FlameTexturePackPage::create(this, *m_instance)); - m_selectedPage = dynamic_cast(pages[0]); - return pages; } @@ -302,11 +292,7 @@ ShaderPackDownloadDialog::ShaderPackDownloadDialog(QWidget* parent, QList ShaderPackDownloadDialog::getPages() { QList pages; - pages.append(ModrinthShaderPackPage::create(this, *m_instance)); - - m_selectedPage = dynamic_cast(pages[0]); - return pages; } diff --git a/launcher/ui/dialogs/ResourceDownloadDialog.h b/launcher/ui/dialogs/ResourceDownloadDialog.h index 5b5b48c6..5077b2ca 100644 --- a/launcher/ui/dialogs/ResourceDownloadDialog.h +++ b/launcher/ui/dialogs/ResourceDownloadDialog.h @@ -60,7 +60,7 @@ class ResourceDownloadDialog : public QDialog, public BasePageProvider { QString dialogTitle() override { return tr("Download %1").arg(resourcesString()); }; bool selectPage(QString pageId); - ResourcePage* getSelectedPage(); + ResourcePage* selectedPage(); void addResource(ModPlatform::IndexedPack::Ptr, ModPlatform::IndexedVersion&); void removeResource(const QString&); @@ -85,7 +85,6 @@ class ResourceDownloadDialog : public QDialog, public BasePageProvider { const std::shared_ptr m_base_model; PageContainer* m_container = nullptr; - ResourcePage* m_selectedPage = nullptr; QDialogButtonBox m_buttons; QVBoxLayout m_vertical_layout; -- 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/dialogs/InstallLoaderDialog.cpp | 18 ++++++++++++++++++ launcher/ui/dialogs/InstallLoaderDialog.h | 2 +- launcher/ui/dialogs/ResourceDownloadDialog.cpp | 2 +- launcher/ui/dialogs/ResourceDownloadDialog.h | 2 +- 4 files changed, 21 insertions(+), 3 deletions(-) (limited to 'launcher/ui/dialogs') diff --git a/launcher/ui/dialogs/InstallLoaderDialog.cpp b/launcher/ui/dialogs/InstallLoaderDialog.cpp index 34c91c68..1b003e52 100644 --- a/launcher/ui/dialogs/InstallLoaderDialog.cpp +++ b/launcher/ui/dialogs/InstallLoaderDialog.cpp @@ -1,3 +1,21 @@ +// SPDX-License-Identifier: GPL-3.0-only +/* + * Prism Launcher - Minecraft Launcher + * 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 + * 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 . + */ + #include "InstallLoaderDialog.h" #include diff --git a/launcher/ui/dialogs/InstallLoaderDialog.h b/launcher/ui/dialogs/InstallLoaderDialog.h index 26b39e4a..7a32e427 100644 --- a/launcher/ui/dialogs/InstallLoaderDialog.h +++ b/launcher/ui/dialogs/InstallLoaderDialog.h @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-3.0-only /* * Prism Launcher - Minecraft Launcher - * 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 diff --git a/launcher/ui/dialogs/ResourceDownloadDialog.cpp b/launcher/ui/dialogs/ResourceDownloadDialog.cpp index 784662a0..8d4e51b2 100644 --- a/launcher/ui/dialogs/ResourceDownloadDialog.cpp +++ b/launcher/ui/dialogs/ResourceDownloadDialog.cpp @@ -2,7 +2,7 @@ /* * Prism Launcher - Minecraft Launcher * Copyright (C) 2022 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 diff --git a/launcher/ui/dialogs/ResourceDownloadDialog.h b/launcher/ui/dialogs/ResourceDownloadDialog.h index 5077b2ca..b56a9adc 100644 --- a/launcher/ui/dialogs/ResourceDownloadDialog.h +++ b/launcher/ui/dialogs/ResourceDownloadDialog.h @@ -2,7 +2,7 @@ /* * Prism Launcher - Minecraft Launcher * Copyright (C) 2022 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 a389983d7dfb78a2bf6c1b85e5837dcdac789070 Mon Sep 17 00:00:00 2001 From: TheKodeToad Date: Tue, 20 Jun 2023 00:28:42 +0100 Subject: Just use the old ordering Signed-off-by: TheKodeToad --- launcher/ui/dialogs/InstallLoaderDialog.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'launcher/ui/dialogs') diff --git a/launcher/ui/dialogs/InstallLoaderDialog.cpp b/launcher/ui/dialogs/InstallLoaderDialog.cpp index 1b003e52..5df27dba 100644 --- a/launcher/ui/dialogs/InstallLoaderDialog.cpp +++ b/launcher/ui/dialogs/InstallLoaderDialog.cpp @@ -107,12 +107,12 @@ InstallLoaderDialog::InstallLoaderDialog(std::shared_ptr profile, Q QList InstallLoaderDialog::getPages() { - return { // Fabric + return { // Forge + new LoaderPage("net.minecraftforge", "forge-loader", tr("Forge"), false, m_profile, this), + // Fabric new LoaderPage("net.fabricmc.fabric-loader", "fabric-loader", tr("Fabric"), true, m_profile, this), // Quilt new LoaderPage("org.quiltmc.quilt-loader", "quilt-loader", tr("Quilt"), true, m_profile, this), - // Forge - new LoaderPage("net.minecraftforge", "forge-loader", tr("Forge"), false, m_profile, this), // LiteLoader new LoaderPage("com.mumfrey.liteloader", "liteloader", tr("LiteLoader"), false, m_profile, this) }; -- cgit From 94510edd722b72e375011c6d4a6629c478728c72 Mon Sep 17 00:00:00 2001 From: TheKodeToad Date: Tue, 20 Jun 2023 19:57:15 +0100 Subject: Rework icons (Fabric is blurry now but looks better) Signed-off-by: TheKodeToad --- launcher/ui/dialogs/InstallLoaderDialog.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'launcher/ui/dialogs') diff --git a/launcher/ui/dialogs/InstallLoaderDialog.cpp b/launcher/ui/dialogs/InstallLoaderDialog.cpp index 5df27dba..a9d08fc5 100644 --- a/launcher/ui/dialogs/InstallLoaderDialog.cpp +++ b/launcher/ui/dialogs/InstallLoaderDialog.cpp @@ -42,7 +42,7 @@ class LoaderPage : public VersionSelectWidget, public BasePage { : VersionSelectWidget(parent), m_id(std::move(id)), m_icon(std::move(icon)), m_name(std::move(name)) { const QString minecraftVersion = profile->getComponentVersion("net.minecraft"); - setEmptyErrorString(tr("No versions are currently available for Minecraft %1").arg(minecraftVersion)); + setEmptyString(tr("No versions are currently available for Minecraft %1").arg(minecraftVersion)); if (!lightweight) setExactFilter(BaseVersionList::ParentVersionRole, minecraftVersion); @@ -108,11 +108,11 @@ InstallLoaderDialog::InstallLoaderDialog(std::shared_ptr profile, Q QList InstallLoaderDialog::getPages() { return { // Forge - new LoaderPage("net.minecraftforge", "forge-loader", tr("Forge"), false, m_profile, this), + new LoaderPage("net.minecraftforge", "forge", tr("Forge"), false, m_profile, this), // Fabric - new LoaderPage("net.fabricmc.fabric-loader", "fabric-loader", tr("Fabric"), true, m_profile, this), + new LoaderPage("net.fabricmc.fabric-loader", "fabricmc-small", tr("Fabric"), true, m_profile, this), // Quilt - new LoaderPage("org.quiltmc.quilt-loader", "quilt-loader", tr("Quilt"), true, m_profile, this), + new LoaderPage("org.quiltmc.quilt-loader", "quiltmc", tr("Quilt"), true, m_profile, this), // LiteLoader new LoaderPage("com.mumfrey.liteloader", "liteloader", tr("LiteLoader"), false, m_profile, this) }; -- cgit From 1f16380efce61fa028d6c25308c8cac7925da72a Mon Sep 17 00:00:00 2001 From: TheKodeToad Date: Thu, 22 Jun 2023 12:56:47 +0100 Subject: Fix I could use rvalue references and fix my brain fart, but i think regular references are more readable and safer here. Signed-off-by: TheKodeToad --- launcher/ui/dialogs/InstallLoaderDialog.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'launcher/ui/dialogs') diff --git a/launcher/ui/dialogs/InstallLoaderDialog.cpp b/launcher/ui/dialogs/InstallLoaderDialog.cpp index a9d08fc5..cc8d7e54 100644 --- a/launcher/ui/dialogs/InstallLoaderDialog.cpp +++ b/launcher/ui/dialogs/InstallLoaderDialog.cpp @@ -32,14 +32,14 @@ class LoaderPage : public VersionSelectWidget, public BasePage { public: - LoaderPage(const QString&& id, - const QString&& icon, - const QString&& name, + LoaderPage(const QString& id, + const QString& icon, + const QString& name, // "lightweight" loaders are independent to any game version const bool lightweight, const std::shared_ptr profile, QWidget* parent = nullptr) - : VersionSelectWidget(parent), m_id(std::move(id)), m_icon(std::move(icon)), m_name(std::move(name)) + : VersionSelectWidget(parent), m_id(id), m_icon(icon), m_name(name) { const QString minecraftVersion = profile->getComponentVersion("net.minecraft"); setEmptyString(tr("No versions are currently available for Minecraft %1").arg(minecraftVersion)); -- cgit From 05d2c1f0b06519eba9cc5ad22848106b49f9bd15 Mon Sep 17 00:00:00 2001 From: TheKodeToad Date: Thu, 22 Jun 2023 18:18:33 +0100 Subject: Dynamic button text Signed-off-by: TheKodeToad --- launcher/ui/dialogs/InstallLoaderDialog.cpp | 23 ++++++++++++++++------- launcher/ui/dialogs/InstallLoaderDialog.h | 3 +++ 2 files changed, 19 insertions(+), 7 deletions(-) (limited to 'launcher/ui/dialogs') diff --git a/launcher/ui/dialogs/InstallLoaderDialog.cpp b/launcher/ui/dialogs/InstallLoaderDialog.cpp index cc8d7e54..6e1ad1c0 100644 --- a/launcher/ui/dialogs/InstallLoaderDialog.cpp +++ b/launcher/ui/dialogs/InstallLoaderDialog.cpp @@ -75,7 +75,7 @@ class LoaderPage : public VersionSelectWidget, public BasePage { }; InstallLoaderDialog::InstallLoaderDialog(std::shared_ptr profile, QWidget* parent) - : QDialog(parent), m_profile(profile), m_container(new PageContainer(this)) + : QDialog(parent), m_profile(profile), m_container(new PageContainer(this)), m_buttons(new QDialogButtonBox(this)) { auto layout = new QVBoxLayout(this); @@ -92,17 +92,20 @@ InstallLoaderDialog::InstallLoaderDialog(std::shared_ptr profile, Q }); buttonLayout->addWidget(refreshButton); - auto buttons = new QDialogButtonBox(this); - buttons->setOrientation(Qt::Horizontal); - buttons->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::Ok); - connect(buttons, &QDialogButtonBox::accepted, this, &QDialog::accept); - connect(buttons, &QDialogButtonBox::rejected, this, &QDialog::reject); - buttonLayout->addWidget(buttons); + m_buttons->setOrientation(Qt::Horizontal); + m_buttons->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::Ok); + connect(m_buttons, &QDialogButtonBox::accepted, this, &QDialog::accept); + connect(m_buttons, &QDialogButtonBox::rejected, this, &QDialog::reject); + buttonLayout->addWidget(m_buttons); layout->addLayout(buttonLayout); setWindowTitle(dialogTitle()); resize(650, 400); + + connect(m_container, &PageContainer::selectedPageChanged, this, + [this](BasePage* previous, BasePage* selected) { updateAcceptButton(selected); }); + updateAcceptButton(m_container->selectedPage()); } QList InstallLoaderDialog::getPages() @@ -123,6 +126,12 @@ QString InstallLoaderDialog::dialogTitle() return tr("Install Loader"); } +void InstallLoaderDialog::updateAcceptButton(const BasePage* page) +{ + auto installed = !m_profile->getComponentVersion(page->id()).isNull(); + m_buttons->button(QDialogButtonBox::Ok)->setText(installed ? tr("&Update") : tr("&Install")); +} + void InstallLoaderDialog::done(int result) { if (result == Accepted) { diff --git a/launcher/ui/dialogs/InstallLoaderDialog.h b/launcher/ui/dialogs/InstallLoaderDialog.h index 7a32e427..6c8762dc 100644 --- a/launcher/ui/dialogs/InstallLoaderDialog.h +++ b/launcher/ui/dialogs/InstallLoaderDialog.h @@ -24,6 +24,7 @@ class MinecraftInstance; class PageContainer; class PackProfile; +class QDialogButtonBox; class InstallLoaderDialog : public QDialog, public BasePageProvider { Q_OBJECT @@ -34,9 +35,11 @@ class InstallLoaderDialog : public QDialog, public BasePageProvider { QList getPages() override; QString dialogTitle() override; + void updateAcceptButton(const BasePage* page); void done(int result) override; private: std::shared_ptr m_profile; PageContainer* m_container; + QDialogButtonBox* m_buttons; }; -- cgit From 4332b62a6268e3093c957dfcbd652c5275228546 Mon Sep 17 00:00:00 2001 From: TheKodeToad Date: Sat, 1 Jul 2023 16:39:21 +0100 Subject: Fix search focusing Signed-off-by: TheKodeToad --- launcher/ui/dialogs/InstallLoaderDialog.cpp | 22 ++++++++++------------ launcher/ui/dialogs/VersionSelectDialog.cpp | 3 ++- 2 files changed, 12 insertions(+), 13 deletions(-) (limited to 'launcher/ui/dialogs') diff --git a/launcher/ui/dialogs/InstallLoaderDialog.cpp b/launcher/ui/dialogs/InstallLoaderDialog.cpp index 6e1ad1c0..f62fb8c4 100644 --- a/launcher/ui/dialogs/InstallLoaderDialog.cpp +++ b/launcher/ui/dialogs/InstallLoaderDialog.cpp @@ -30,9 +30,9 @@ #include "ui/widgets/PageContainer.h" #include "ui/widgets/VersionSelectWidget.h" -class LoaderPage : public VersionSelectWidget, public BasePage { +class InstallLoaderPage : public VersionSelectWidget, public BasePage { public: - LoaderPage(const QString& id, + InstallLoaderPage(const QString& id, const QString& icon, const QString& name, // "lightweight" loaders are independent to any game version @@ -86,9 +86,7 @@ InstallLoaderDialog::InstallLoaderDialog(std::shared_ptr profile, Q auto refreshButton = new QPushButton(tr("&Refresh"), this); connect(refreshButton, &QPushButton::pressed, this, [this] { - LoaderPage* page = dynamic_cast(m_container->selectedPage()); - Q_ASSERT(page != nullptr); - page->loadList(); + dynamic_cast(m_container->selectedPage())->loadList(); }); buttonLayout->addWidget(refreshButton); @@ -106,18 +104,20 @@ InstallLoaderDialog::InstallLoaderDialog(std::shared_ptr profile, Q connect(m_container, &PageContainer::selectedPageChanged, this, [this](BasePage* previous, BasePage* selected) { updateAcceptButton(selected); }); updateAcceptButton(m_container->selectedPage()); + + dynamic_cast(m_container->selectedPage())->selectSearch(); } QList InstallLoaderDialog::getPages() { return { // Forge - new LoaderPage("net.minecraftforge", "forge", tr("Forge"), false, m_profile, this), + new InstallLoaderPage("net.minecraftforge", "forge", tr("Forge"), false, m_profile, this), // Fabric - new LoaderPage("net.fabricmc.fabric-loader", "fabricmc-small", tr("Fabric"), true, m_profile, this), + new InstallLoaderPage("net.fabricmc.fabric-loader", "fabricmc-small", tr("Fabric"), true, m_profile, this), // Quilt - new LoaderPage("org.quiltmc.quilt-loader", "quiltmc", tr("Quilt"), true, m_profile, this), + new InstallLoaderPage("org.quiltmc.quilt-loader", "quiltmc", tr("Quilt"), true, m_profile, this), // LiteLoader - new LoaderPage("com.mumfrey.liteloader", "liteloader", tr("LiteLoader"), false, m_profile, this) + new InstallLoaderPage("com.mumfrey.liteloader", "liteloader", tr("LiteLoader"), false, m_profile, this) }; } @@ -135,9 +135,7 @@ void InstallLoaderDialog::updateAcceptButton(const BasePage* page) void InstallLoaderDialog::done(int result) { if (result == Accepted) { - LoaderPage* page = dynamic_cast(m_container->selectedPage()); - Q_ASSERT(page != nullptr); - + auto* page = dynamic_cast(m_container->selectedPage()); if (page->selectedVersion()) { m_profile->setComponentVersion(page->id(), page->selectedVersion()->descriptor()); m_profile->resolve(Net::Mode::Online); diff --git a/launcher/ui/dialogs/VersionSelectDialog.cpp b/launcher/ui/dialogs/VersionSelectDialog.cpp index 5feb70d2..dec85550 100644 --- a/launcher/ui/dialogs/VersionSelectDialog.cpp +++ b/launcher/ui/dialogs/VersionSelectDialog.cpp @@ -55,7 +55,7 @@ VersionSelectDialog::VersionSelectDialog(BaseVersionList *vlist, QString title, m_verticalLayout = new QVBoxLayout(this); m_verticalLayout->setObjectName(QStringLiteral("verticalLayout")); - m_versionWidget = new VersionSelectWidget(true, parent); + m_versionWidget = new VersionSelectWidget(parent); m_verticalLayout->addWidget(m_versionWidget); m_horizontalLayout = new QHBoxLayout(); @@ -123,6 +123,7 @@ int VersionSelectDialog::exec() { QDialog::open(); m_versionWidget->initialize(m_vlist); + m_versionWidget->selectSearch(); if(resizeOnColumn != -1) { m_versionWidget->setResizeOn(resizeOnColumn); -- 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/dialogs/InstallLoaderDialog.cpp | 18 ++++++++++++++---- launcher/ui/dialogs/InstallLoaderDialog.h | 4 ++-- 2 files changed, 16 insertions(+), 6 deletions(-) (limited to 'launcher/ui/dialogs') diff --git a/launcher/ui/dialogs/InstallLoaderDialog.cpp b/launcher/ui/dialogs/InstallLoaderDialog.cpp index f62fb8c4..74b3ea92 100644 --- a/launcher/ui/dialogs/InstallLoaderDialog.cpp +++ b/launcher/ui/dialogs/InstallLoaderDialog.cpp @@ -74,7 +74,14 @@ class InstallLoaderPage : public VersionSelectWidget, public BasePage { bool m_loaded = false; }; -InstallLoaderDialog::InstallLoaderDialog(std::shared_ptr profile, QWidget* parent) +InstallLoaderPage* pageCast(BasePage* page) +{ + auto result = dynamic_cast(page); + Q_ASSERT(result != nullptr); + return result; +} + +InstallLoaderDialog::InstallLoaderDialog(std::shared_ptr profile, const QString& uid, QWidget* parent) : QDialog(parent), m_profile(profile), m_container(new PageContainer(this)), m_buttons(new QDialogButtonBox(this)) { auto layout = new QVBoxLayout(this); @@ -86,7 +93,7 @@ InstallLoaderDialog::InstallLoaderDialog(std::shared_ptr profile, Q auto refreshButton = new QPushButton(tr("&Refresh"), this); connect(refreshButton, &QPushButton::pressed, this, [this] { - dynamic_cast(m_container->selectedPage())->loadList(); + pageCast(m_container->selectedPage())->loadList(); }); buttonLayout->addWidget(refreshButton); @@ -105,7 +112,10 @@ InstallLoaderDialog::InstallLoaderDialog(std::shared_ptr profile, Q [this](BasePage* previous, BasePage* selected) { updateAcceptButton(selected); }); updateAcceptButton(m_container->selectedPage()); - dynamic_cast(m_container->selectedPage())->selectSearch(); + pageCast(m_container->selectedPage())->selectSearch(); + for (BasePage* page : m_container->getPages()) + if (page->id() == uid) + m_container->selectPage(page->id()); } QList InstallLoaderDialog::getPages() @@ -135,7 +145,7 @@ void InstallLoaderDialog::updateAcceptButton(const BasePage* page) void InstallLoaderDialog::done(int result) { if (result == Accepted) { - auto* page = dynamic_cast(m_container->selectedPage()); + auto* page = pageCast(m_container->selectedPage()); if (page->selectedVersion()) { m_profile->setComponentVersion(page->id(), page->selectedVersion()->descriptor()); m_profile->resolve(Net::Mode::Online); diff --git a/launcher/ui/dialogs/InstallLoaderDialog.h b/launcher/ui/dialogs/InstallLoaderDialog.h index 6c8762dc..24064eaa 100644 --- a/launcher/ui/dialogs/InstallLoaderDialog.h +++ b/launcher/ui/dialogs/InstallLoaderDialog.h @@ -26,11 +26,11 @@ class PageContainer; class PackProfile; class QDialogButtonBox; -class InstallLoaderDialog : public QDialog, public BasePageProvider { +class InstallLoaderDialog final : public QDialog, public BasePageProvider { Q_OBJECT public: - explicit InstallLoaderDialog(std::shared_ptr instance, QWidget* parent = nullptr); + explicit InstallLoaderDialog(std::shared_ptr instance, const QString& uid = QString(), QWidget* parent = nullptr); QList getPages() override; QString dialogTitle() override; -- cgit From 284e374ae858d6784b6df48c83534dc6dc973747 Mon Sep 17 00:00:00 2001 From: TheKodeToad Date: Sat, 1 Jul 2023 17:20:43 +0100 Subject: Nop Signed-off-by: TheKodeToad --- launcher/ui/dialogs/InstallLoaderDialog.cpp | 10 ---------- launcher/ui/dialogs/InstallLoaderDialog.h | 1 - 2 files changed, 11 deletions(-) (limited to 'launcher/ui/dialogs') diff --git a/launcher/ui/dialogs/InstallLoaderDialog.cpp b/launcher/ui/dialogs/InstallLoaderDialog.cpp index 74b3ea92..31307ee1 100644 --- a/launcher/ui/dialogs/InstallLoaderDialog.cpp +++ b/launcher/ui/dialogs/InstallLoaderDialog.cpp @@ -108,10 +108,6 @@ InstallLoaderDialog::InstallLoaderDialog(std::shared_ptr profile, c setWindowTitle(dialogTitle()); resize(650, 400); - connect(m_container, &PageContainer::selectedPageChanged, this, - [this](BasePage* previous, BasePage* selected) { updateAcceptButton(selected); }); - updateAcceptButton(m_container->selectedPage()); - pageCast(m_container->selectedPage())->selectSearch(); for (BasePage* page : m_container->getPages()) if (page->id() == uid) @@ -136,12 +132,6 @@ QString InstallLoaderDialog::dialogTitle() return tr("Install Loader"); } -void InstallLoaderDialog::updateAcceptButton(const BasePage* page) -{ - auto installed = !m_profile->getComponentVersion(page->id()).isNull(); - m_buttons->button(QDialogButtonBox::Ok)->setText(installed ? tr("&Update") : tr("&Install")); -} - void InstallLoaderDialog::done(int result) { if (result == Accepted) { diff --git a/launcher/ui/dialogs/InstallLoaderDialog.h b/launcher/ui/dialogs/InstallLoaderDialog.h index 24064eaa..09d84777 100644 --- a/launcher/ui/dialogs/InstallLoaderDialog.h +++ b/launcher/ui/dialogs/InstallLoaderDialog.h @@ -35,7 +35,6 @@ class InstallLoaderDialog final : public QDialog, public BasePageProvider { QList getPages() override; QString dialogTitle() override; - void updateAcceptButton(const BasePage* page); void done(int result) override; private: -- cgit From 9f9b5254a239d6359d199c33fa5d966e1f4d6e63 Mon Sep 17 00:00:00 2001 From: TheKodeToad Date: Sat, 1 Jul 2023 19:32:04 +0100 Subject: Double-click to install/change version Signed-off-by: TheKodeToad --- launcher/ui/dialogs/InstallLoaderDialog.cpp | 33 ++++++++++++++++------------- launcher/ui/dialogs/VersionSelectDialog.cpp | 5 +++-- 2 files changed, 21 insertions(+), 17 deletions(-) (limited to 'launcher/ui/dialogs') diff --git a/launcher/ui/dialogs/InstallLoaderDialog.cpp b/launcher/ui/dialogs/InstallLoaderDialog.cpp index 31307ee1..acef60c6 100644 --- a/launcher/ui/dialogs/InstallLoaderDialog.cpp +++ b/launcher/ui/dialogs/InstallLoaderDialog.cpp @@ -33,13 +33,12 @@ class InstallLoaderPage : public VersionSelectWidget, public BasePage { public: InstallLoaderPage(const QString& id, - const QString& icon, - const QString& name, - // "lightweight" loaders are independent to any game version - const bool lightweight, - const std::shared_ptr profile, - QWidget* parent = nullptr) - : VersionSelectWidget(parent), m_id(id), m_icon(icon), m_name(name) + const QString& icon, + const QString& name, + // "lightweight" loaders are independent to any game version + const bool lightweight, + const std::shared_ptr profile) + : VersionSelectWidget(nullptr), m_id(id), m_icon(icon), m_name(name) { const QString minecraftVersion = profile->getComponentVersion("net.minecraft"); setEmptyString(tr("No versions are currently available for Minecraft %1").arg(minecraftVersion)); @@ -67,6 +66,12 @@ class InstallLoaderPage : public VersionSelectWidget, public BasePage { m_loaded = true; } + void setParentContainer(BasePageContainer* container) override + { + auto dialog = dynamic_cast(dynamic_cast(container)->parent()); + connect(view(), &QAbstractItemView::doubleClicked, dialog, &QDialog::accept); + } + private: const QString m_id; const QString m_icon; @@ -82,7 +87,7 @@ InstallLoaderPage* pageCast(BasePage* page) } InstallLoaderDialog::InstallLoaderDialog(std::shared_ptr profile, const QString& uid, QWidget* parent) - : QDialog(parent), m_profile(profile), m_container(new PageContainer(this)), m_buttons(new QDialogButtonBox(this)) + : QDialog(parent), m_profile(profile), m_container(new PageContainer(this, QString(), this)), m_buttons(new QDialogButtonBox(this)) { auto layout = new QVBoxLayout(this); @@ -92,9 +97,7 @@ InstallLoaderDialog::InstallLoaderDialog(std::shared_ptr profile, c auto buttonLayout = new QHBoxLayout(this); auto refreshButton = new QPushButton(tr("&Refresh"), this); - connect(refreshButton, &QPushButton::pressed, this, [this] { - pageCast(m_container->selectedPage())->loadList(); - }); + connect(refreshButton, &QPushButton::pressed, this, [this] { pageCast(m_container->selectedPage())->loadList(); }); buttonLayout->addWidget(refreshButton); m_buttons->setOrientation(Qt::Horizontal); @@ -117,13 +120,13 @@ InstallLoaderDialog::InstallLoaderDialog(std::shared_ptr profile, c QList InstallLoaderDialog::getPages() { return { // Forge - new InstallLoaderPage("net.minecraftforge", "forge", tr("Forge"), false, m_profile, this), + new InstallLoaderPage("net.minecraftforge", "forge", tr("Forge"), false, m_profile), // Fabric - new InstallLoaderPage("net.fabricmc.fabric-loader", "fabricmc-small", tr("Fabric"), true, m_profile, this), + new InstallLoaderPage("net.fabricmc.fabric-loader", "fabricmc-small", tr("Fabric"), true, m_profile), // Quilt - new InstallLoaderPage("org.quiltmc.quilt-loader", "quiltmc", tr("Quilt"), true, m_profile, this), + new InstallLoaderPage("org.quiltmc.quilt-loader", "quiltmc", tr("Quilt"), true, m_profile), // LiteLoader - new InstallLoaderPage("com.mumfrey.liteloader", "liteloader", tr("LiteLoader"), false, m_profile, this) + new InstallLoaderPage("com.mumfrey.liteloader", "liteloader", tr("LiteLoader"), false, m_profile) }; } diff --git a/launcher/ui/dialogs/VersionSelectDialog.cpp b/launcher/ui/dialogs/VersionSelectDialog.cpp index dec85550..e45787e4 100644 --- a/launcher/ui/dialogs/VersionSelectDialog.cpp +++ b/launcher/ui/dialogs/VersionSelectDialog.cpp @@ -75,8 +75,9 @@ VersionSelectDialog::VersionSelectDialog(BaseVersionList *vlist, QString title, retranslate(); - QObject::connect(m_buttonBox, SIGNAL(accepted()), this, SLOT(accept())); - QObject::connect(m_buttonBox, SIGNAL(rejected()), this, SLOT(reject())); + connect(m_buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); + connect(m_versionWidget->view(), &QAbstractItemView::doubleClicked, this, &QDialog::accept); + connect(m_buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); QMetaObject::connectSlotsByName(this); setWindowModality(Qt::WindowModal); -- 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> --- launcher/ui/dialogs/CopyInstanceDialog.cpp | 2 +- launcher/ui/dialogs/ExportInstanceDialog.cpp | 8 ++++---- launcher/ui/dialogs/NewInstanceDialog.cpp | 2 +- launcher/ui/dialogs/ProfileSetupDialog.cpp | 16 ++++++++-------- launcher/ui/dialogs/ProgressDialog.cpp | 20 ++++++++++---------- launcher/ui/dialogs/ProgressDialog.h | 2 +- launcher/ui/dialogs/ResourceDownloadDialog.cpp | 2 +- launcher/ui/dialogs/ReviewMessageBox.cpp | 2 +- launcher/ui/dialogs/SkinUploadDialog.cpp | 6 +++--- 9 files changed, 30 insertions(+), 30 deletions(-) (limited to 'launcher/ui/dialogs') diff --git a/launcher/ui/dialogs/CopyInstanceDialog.cpp b/launcher/ui/dialogs/CopyInstanceDialog.cpp index d75bb5fe..ffa1e31b 100644 --- a/launcher/ui/dialogs/CopyInstanceDialog.cpp +++ b/launcher/ui/dialogs/CopyInstanceDialog.cpp @@ -220,7 +220,7 @@ void CopyInstanceDialog::on_iconButton_clicked() } } -void CopyInstanceDialog::on_instNameTextBox_textChanged(const QString& arg1) +void CopyInstanceDialog::on_instNameTextBox_textChanged([[maybe_unused]] const QString& arg1) { updateDialogState(); } diff --git a/launcher/ui/dialogs/ExportInstanceDialog.cpp b/launcher/ui/dialogs/ExportInstanceDialog.cpp index cc41c394..5223391e 100644 --- a/launcher/ui/dialogs/ExportInstanceDialog.cpp +++ b/launcher/ui/dialogs/ExportInstanceDialog.cpp @@ -203,8 +203,8 @@ void ExportInstanceDialog::loadPackIgnore() { return; } - auto data = ignoreFile.readAll(); - auto string = QString::fromUtf8(data); + auto ignoreData = ignoreFile.readAll(); + auto string = QString::fromUtf8(ignoreData); #if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) proxyModel->setBlockedPaths(string.split('\n', Qt::SkipEmptyParts)); #else @@ -214,11 +214,11 @@ void ExportInstanceDialog::loadPackIgnore() void ExportInstanceDialog::savePackIgnore() { - auto data = proxyModel->blockedPaths().toStringList().join('\n').toUtf8(); + auto ignoreData = proxyModel->blockedPaths().toStringList().join('\n').toUtf8(); auto filename = ignoreFileName(); try { - FS::write(filename, data); + FS::write(filename, ignoreData); } catch (const Exception &e) { diff --git a/launcher/ui/dialogs/NewInstanceDialog.cpp b/launcher/ui/dialogs/NewInstanceDialog.cpp index 7b9bb944..95ded16e 100644 --- a/launcher/ui/dialogs/NewInstanceDialog.cpp +++ b/launcher/ui/dialogs/NewInstanceDialog.cpp @@ -296,7 +296,7 @@ void NewInstanceDialog::on_iconButton_clicked() } } -void NewInstanceDialog::on_instNameTextBox_textChanged(const QString &arg1) +void NewInstanceDialog::on_instNameTextBox_textChanged([[maybe_unused]] const QString &arg1) { updateDialogState(); } diff --git a/launcher/ui/dialogs/ProfileSetupDialog.cpp b/launcher/ui/dialogs/ProfileSetupDialog.cpp index 64c0b924..758f7f23 100644 --- a/launcher/ui/dialogs/ProfileSetupDialog.cpp +++ b/launcher/ui/dialogs/ProfileSetupDialog.cpp @@ -167,14 +167,14 @@ void ProfileSetupDialog::checkName(const QString &name) { void ProfileSetupDialog::checkFinished( QNetworkReply::NetworkError error, - QByteArray data, - QList headers + QByteArray profileData, + [[maybe_unused]] QList headers ) { auto requestor = qobject_cast(QObject::sender()); requestor->deleteLater(); if(error == QNetworkReply::NoError) { - auto doc = QJsonDocument::fromJson(data); + auto doc = QJsonDocument::fromJson(profileData); auto root = doc.object(); auto statusValue = root.value("status").toString("INVALID"); if(statusValue == "AVAILABLE") { @@ -210,11 +210,11 @@ void ProfileSetupDialog::setupProfile(const QString &profileName) { request.setRawHeader("Authorization", QString("Bearer %1").arg(token).toUtf8()); QString payloadTemplate("{\"profileName\":\"%1\"}"); - auto data = payloadTemplate.arg(profileName).toUtf8(); + auto profileData = payloadTemplate.arg(profileName).toUtf8(); AuthRequest *requestor = new AuthRequest(this); connect(requestor, &AuthRequest::finished, this, &ProfileSetupDialog::setupProfileFinished); - requestor->post(request, data); + requestor->post(request, profileData); isWorking = true; auto button = ui->buttonBox->button(QDialogButtonBox::Cancel); @@ -251,8 +251,8 @@ struct MojangError{ void ProfileSetupDialog::setupProfileFinished( QNetworkReply::NetworkError error, - QByteArray data, - QList headers + QByteArray errorData, + [[maybe_unused]] QList headers ) { auto requestor = qobject_cast(QObject::sender()); requestor->deleteLater(); @@ -266,7 +266,7 @@ void ProfileSetupDialog::setupProfileFinished( accept(); } else { - auto parsedError = MojangError::fromJSON(data); + auto parsedError = MojangError::fromJSON(errorData); ui->errorLabel->setVisible(true); ui->errorLabel->setText(tr("The server returned the following error:") + "\n\n" + parsedError.errorMessage); qDebug() << parsedError.rawError; diff --git a/launcher/ui/dialogs/ProgressDialog.cpp b/launcher/ui/dialogs/ProgressDialog.cpp index 246a0fd4..24f445e6 100644 --- a/launcher/ui/dialogs/ProgressDialog.cpp +++ b/launcher/ui/dialogs/ProgressDialog.cpp @@ -85,7 +85,7 @@ void ProgressDialog::on_skipButton_clicked(bool checked) { Q_UNUSED(checked); if (ui->skipButton->isEnabled()) // prevent other triggers from aborting - task->abort(); + m_task->abort(); } ProgressDialog::~ProgressDialog() @@ -116,7 +116,7 @@ void ProgressDialog::updateSize() int ProgressDialog::execWithTask(Task* task) { - this->task = task; + this->m_task = task; if (!task) { qDebug() << "Programmer error: Progress dialog created with null task."; @@ -168,8 +168,8 @@ int ProgressDialog::execWithTask(std::unique_ptr& task) bool ProgressDialog::handleImmediateResult(QDialog::DialogCode& result) { - if (task->isFinished()) { - if (task->wasSuccessful()) { + if (m_task->isFinished()) { + if (m_task->wasSuccessful()) { result = QDialog::Accepted; } else { result = QDialog::Rejected; @@ -181,12 +181,12 @@ bool ProgressDialog::handleImmediateResult(QDialog::DialogCode& result) Task* ProgressDialog::getTask() { - return task; + return m_task; } void ProgressDialog::onTaskStarted() {} -void ProgressDialog::onTaskFailed(QString failure) +void ProgressDialog::onTaskFailed([[maybe_unused]] QString failure) { reject(); hide(); @@ -198,10 +198,10 @@ void ProgressDialog::onTaskSucceeded() hide(); } -void ProgressDialog::changeStatus(const QString& status) +void ProgressDialog::changeStatus([[maybe_unused]] const QString& status) { - ui->globalStatusLabel->setText(task->getStatus()); - ui->globalStatusDetailsLabel->setText(task->getDetails()); + ui->globalStatusLabel->setText(m_task->getStatus()); + ui->globalStatusDetailsLabel->setText(m_task->getDetails()); updateSize(); } @@ -269,7 +269,7 @@ void ProgressDialog::keyPressEvent(QKeyEvent* e) void ProgressDialog::closeEvent(QCloseEvent* e) { - if (task && task->isRunning()) { + if (m_task && m_task->isRunning()) { e->ignore(); } else { QDialog::closeEvent(e); diff --git a/launcher/ui/dialogs/ProgressDialog.h b/launcher/ui/dialogs/ProgressDialog.h index fc9a0fbc..ee55ceca 100644 --- a/launcher/ui/dialogs/ProgressDialog.h +++ b/launcher/ui/dialogs/ProgressDialog.h @@ -98,7 +98,7 @@ private: private: Ui::ProgressDialog *ui; - Task *task; + Task *m_task; bool m_is_multi_step = false; QHash taskProgress; diff --git a/launcher/ui/dialogs/ResourceDownloadDialog.cpp b/launcher/ui/dialogs/ResourceDownloadDialog.cpp index 4f59f560..cebc9e9e 100644 --- a/launcher/ui/dialogs/ResourceDownloadDialog.cpp +++ b/launcher/ui/dialogs/ResourceDownloadDialog.cpp @@ -301,7 +301,7 @@ GetModDependenciesTask::Ptr ModDownloadDialog::getModDependenciesTask() return makeShared(this, m_instance, model, selectedVers); } return nullptr; -}; +} ResourcePackDownloadDialog::ResourcePackDownloadDialog(QWidget* parent, const std::shared_ptr& resource_packs, diff --git a/launcher/ui/dialogs/ReviewMessageBox.cpp b/launcher/ui/dialogs/ReviewMessageBox.cpp index 7b33765f..78c2542f 100644 --- a/launcher/ui/dialogs/ReviewMessageBox.cpp +++ b/launcher/ui/dialogs/ReviewMessageBox.cpp @@ -5,7 +5,7 @@ #include -ReviewMessageBox::ReviewMessageBox(QWidget* parent, QString const& title, QString const& icon) +ReviewMessageBox::ReviewMessageBox(QWidget* parent, [[maybe_unused]] QString const& title, [[maybe_unused]] QString const& icon) : QDialog(parent), ui(new Ui::ReviewMessageBox) { ui->setupUi(this); diff --git a/launcher/ui/dialogs/SkinUploadDialog.cpp b/launcher/ui/dialogs/SkinUploadDialog.cpp index 8180ac1f..1ff15c87 100644 --- a/launcher/ui/dialogs/SkinUploadDialog.cpp +++ b/launcher/ui/dialogs/SkinUploadDialog.cpp @@ -155,15 +155,15 @@ SkinUploadDialog::SkinUploadDialog(MinecraftAccountPtr acct, QWidget *parent) ui->setupUi(this); // FIXME: add a model for this, download/refresh the capes on demand - auto &data = *acct->accountData(); + auto &accountData = *acct->accountData(); int index = 0; ui->capeCombo->addItem(tr("No Cape"), QVariant()); - auto currentCape = data.minecraftProfile.currentCape; + auto currentCape = accountData.minecraftProfile.currentCape; if(currentCape.isEmpty()) { ui->capeCombo->setCurrentIndex(index); } - for(auto & cape: data.minecraftProfile.capes) { + for(auto & cape: accountData.minecraftProfile.capes) { index++; if(cape.data.size()) { QPixmap capeImage; -- cgit From 0e5c37768084cf0772ca2598b4554bf262cb581b Mon Sep 17 00:00:00 2001 From: TheKodeToad Date: Mon, 3 Jul 2023 17:32:59 +0100 Subject: Various tweaks Signed-off-by: TheKodeToad --- launcher/ui/dialogs/InstallLoaderDialog.cpp | 78 +++++++++++++++++------------ launcher/ui/dialogs/InstallLoaderDialog.h | 7 +-- 2 files changed, 50 insertions(+), 35 deletions(-) (limited to 'launcher/ui/dialogs') diff --git a/launcher/ui/dialogs/InstallLoaderDialog.cpp b/launcher/ui/dialogs/InstallLoaderDialog.cpp index acef60c6..31d6f9ab 100644 --- a/launcher/ui/dialogs/InstallLoaderDialog.cpp +++ b/launcher/ui/dialogs/InstallLoaderDialog.cpp @@ -38,7 +38,7 @@ class InstallLoaderPage : public VersionSelectWidget, public BasePage { // "lightweight" loaders are independent to any game version const bool lightweight, const std::shared_ptr profile) - : VersionSelectWidget(nullptr), m_id(id), m_icon(icon), m_name(name) + : VersionSelectWidget(nullptr), uid(id), iconName(icon), name(name) { const QString minecraftVersion = profile->getComponentVersion("net.minecraft"); setEmptyString(tr("No versions are currently available for Minecraft %1").arg(minecraftVersion)); @@ -49,21 +49,21 @@ class InstallLoaderPage : public VersionSelectWidget, public BasePage { setCurrentVersion(currentVersion); } - QString id() const override { return m_id; } - QString displayName() const override { return m_name; } - QIcon icon() const override { return APPLICATION->getThemedIcon(m_icon); } + QString id() const override { return uid; } + QString displayName() const override { return name; } + QIcon icon() const override { return APPLICATION->getThemedIcon(iconName); } void openedImpl() override { - if (m_loaded) + if (loaded) return; - const auto versions = APPLICATION->metadataIndex()->get(m_id); + const auto versions = APPLICATION->metadataIndex()->get(uid); if (!versions) return; initialize(versions.get()); - m_loaded = true; + loaded = true; } void setParentContainer(BasePageContainer* container) override @@ -73,13 +73,13 @@ class InstallLoaderPage : public VersionSelectWidget, public BasePage { } private: - const QString m_id; - const QString m_icon; - const QString m_name; - bool m_loaded = false; + const QString uid; + const QString iconName; + const QString name; + bool loaded = false; }; -InstallLoaderPage* pageCast(BasePage* page) +static InstallLoaderPage* pageCast(BasePage* page) { auto result = dynamic_cast(page); Q_ASSERT(result != nullptr); @@ -87,46 +87,55 @@ InstallLoaderPage* pageCast(BasePage* page) } InstallLoaderDialog::InstallLoaderDialog(std::shared_ptr profile, const QString& uid, QWidget* parent) - : QDialog(parent), m_profile(profile), m_container(new PageContainer(this, QString(), this)), m_buttons(new QDialogButtonBox(this)) + : QDialog(parent), profile(std::move(profile)), container(new PageContainer(this, QString(), this)), buttons(new QDialogButtonBox(this)) { auto layout = new QVBoxLayout(this); - m_container->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); - layout->addWidget(m_container); + container->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); + layout->addWidget(container); auto buttonLayout = new QHBoxLayout(this); auto refreshButton = new QPushButton(tr("&Refresh"), this); - connect(refreshButton, &QPushButton::pressed, this, [this] { pageCast(m_container->selectedPage())->loadList(); }); + connect(refreshButton, &QPushButton::pressed, this, [this] { pageCast(container->selectedPage())->loadList(); }); buttonLayout->addWidget(refreshButton); - m_buttons->setOrientation(Qt::Horizontal); - m_buttons->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::Ok); - connect(m_buttons, &QDialogButtonBox::accepted, this, &QDialog::accept); - connect(m_buttons, &QDialogButtonBox::rejected, this, &QDialog::reject); - buttonLayout->addWidget(m_buttons); + buttons->setOrientation(Qt::Horizontal); + buttons->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::Ok); + connect(buttons, &QDialogButtonBox::accepted, this, &QDialog::accept); + connect(buttons, &QDialogButtonBox::rejected, this, &QDialog::reject); + buttonLayout->addWidget(buttons); layout->addLayout(buttonLayout); setWindowTitle(dialogTitle()); - resize(650, 400); + setWindowModality(Qt::WindowModal); + resize(520, 347); - pageCast(m_container->selectedPage())->selectSearch(); - for (BasePage* page : m_container->getPages()) + for (BasePage* page : container->getPages()) { if (page->id() == uid) - m_container->selectPage(page->id()); + container->selectPage(page->id()); + + connect(pageCast(page), &VersionSelectWidget::selectedVersionChanged, this, [this, page] { + if (page->id() == container->selectedPage()->id()) + validate(container->selectedPage()); + }); + } + connect(container, &PageContainer::selectedPageChanged, this, [this](BasePage* previous, BasePage* current) { validate(current); }); + pageCast(container->selectedPage())->selectSearch(); + validate(container->selectedPage()); } QList InstallLoaderDialog::getPages() { return { // Forge - new InstallLoaderPage("net.minecraftforge", "forge", tr("Forge"), false, m_profile), + new InstallLoaderPage("net.minecraftforge", "forge", tr("Forge"), false, profile), // Fabric - new InstallLoaderPage("net.fabricmc.fabric-loader", "fabricmc-small", tr("Fabric"), true, m_profile), + new InstallLoaderPage("net.fabricmc.fabric-loader", "fabricmc-small", tr("Fabric"), true, profile), // Quilt - new InstallLoaderPage("org.quiltmc.quilt-loader", "quiltmc", tr("Quilt"), true, m_profile), + new InstallLoaderPage("org.quiltmc.quilt-loader", "quiltmc", tr("Quilt"), true, profile), // LiteLoader - new InstallLoaderPage("com.mumfrey.liteloader", "liteloader", tr("LiteLoader"), false, m_profile) + new InstallLoaderPage("com.mumfrey.liteloader", "liteloader", tr("LiteLoader"), false, profile) }; } @@ -135,13 +144,18 @@ QString InstallLoaderDialog::dialogTitle() return tr("Install Loader"); } +void InstallLoaderDialog::validate(BasePage* page) +{ + buttons->button(QDialogButtonBox::Ok)->setEnabled(pageCast(page)->selectedVersion() != nullptr); +} + void InstallLoaderDialog::done(int result) { if (result == Accepted) { - auto* page = pageCast(m_container->selectedPage()); + auto* page = pageCast(container->selectedPage()); if (page->selectedVersion()) { - m_profile->setComponentVersion(page->id(), page->selectedVersion()->descriptor()); - m_profile->resolve(Net::Mode::Online); + profile->setComponentVersion(page->id(), page->selectedVersion()->descriptor()); + profile->resolve(Net::Mode::Online); } } diff --git a/launcher/ui/dialogs/InstallLoaderDialog.h b/launcher/ui/dialogs/InstallLoaderDialog.h index 09d84777..cdcba2b9 100644 --- a/launcher/ui/dialogs/InstallLoaderDialog.h +++ b/launcher/ui/dialogs/InstallLoaderDialog.h @@ -35,10 +35,11 @@ class InstallLoaderDialog final : public QDialog, public BasePageProvider { QList getPages() override; QString dialogTitle() override; + void validate(BasePage* page); void done(int result) override; private: - std::shared_ptr m_profile; - PageContainer* m_container; - QDialogButtonBox* m_buttons; + std::shared_ptr profile; + PageContainer* container; + QDialogButtonBox* buttons; }; -- 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/dialogs/InstallLoaderDialog.cpp | 17 +++++++++-------- launcher/ui/dialogs/VersionSelectDialog.cpp | 4 ++++ launcher/ui/dialogs/VersionSelectDialog.h | 1 + 3 files changed, 14 insertions(+), 8 deletions(-) (limited to 'launcher/ui/dialogs') diff --git a/launcher/ui/dialogs/InstallLoaderDialog.cpp b/launcher/ui/dialogs/InstallLoaderDialog.cpp index 31d6f9ab..bab5b835 100644 --- a/launcher/ui/dialogs/InstallLoaderDialog.cpp +++ b/launcher/ui/dialogs/InstallLoaderDialog.cpp @@ -35,15 +35,16 @@ class InstallLoaderPage : public VersionSelectWidget, public BasePage { InstallLoaderPage(const QString& id, const QString& icon, const QString& name, - // "lightweight" loaders are independent to any game version - const bool lightweight, + const Version& oldestVersion, const std::shared_ptr profile) : VersionSelectWidget(nullptr), uid(id), iconName(icon), name(name) { const QString minecraftVersion = profile->getComponentVersion("net.minecraft"); setEmptyString(tr("No versions are currently available for Minecraft %1").arg(minecraftVersion)); - if (!lightweight) - setExactFilter(BaseVersionList::ParentVersionRole, minecraftVersion); + setExactIfPresentFilter(BaseVersionList::ParentVersionRole, minecraftVersion); + + if (oldestVersion != Version() && Version(minecraftVersion) < oldestVersion) + setExactFilter(BaseVersionList::ParentVersionRole, "AAA"); if (const QString currentVersion = profile->getComponentVersion(id); !currentVersion.isNull()) setCurrentVersion(currentVersion); @@ -129,13 +130,13 @@ InstallLoaderDialog::InstallLoaderDialog(std::shared_ptr profile, c QList InstallLoaderDialog::getPages() { return { // Forge - new InstallLoaderPage("net.minecraftforge", "forge", tr("Forge"), false, profile), + new InstallLoaderPage("net.minecraftforge", "forge", tr("Forge"), {}, profile), // Fabric - new InstallLoaderPage("net.fabricmc.fabric-loader", "fabricmc-small", tr("Fabric"), true, profile), + new InstallLoaderPage("net.fabricmc.fabric-loader", "fabricmc-small", tr("Fabric"), Version("1.14"), profile), // Quilt - new InstallLoaderPage("org.quiltmc.quilt-loader", "quiltmc", tr("Quilt"), true, profile), + new InstallLoaderPage("org.quiltmc.quilt-loader", "quiltmc", tr("Quilt"), Version("1.14"), profile), // LiteLoader - new InstallLoaderPage("com.mumfrey.liteloader", "liteloader", tr("LiteLoader"), false, profile) + new InstallLoaderPage("com.mumfrey.liteloader", "liteloader", tr("LiteLoader"), {}, profile) }; } diff --git a/launcher/ui/dialogs/VersionSelectDialog.cpp b/launcher/ui/dialogs/VersionSelectDialog.cpp index e45787e4..9fa3c90f 100644 --- a/launcher/ui/dialogs/VersionSelectDialog.cpp +++ b/launcher/ui/dialogs/VersionSelectDialog.cpp @@ -152,6 +152,10 @@ void VersionSelectDialog::setExactFilter(BaseVersionList::ModelRoles role, QStri m_versionWidget->setExactFilter(role, filter); } +void VersionSelectDialog::setExactIfPresentFilter(BaseVersionList::ModelRoles role, QString filter) { + m_versionWidget->setExactIfPresentFilter(role, filter); +} + void VersionSelectDialog::setFuzzyFilter(BaseVersionList::ModelRoles role, QString filter) { m_versionWidget->setFuzzyFilter(role, filter); diff --git a/launcher/ui/dialogs/VersionSelectDialog.h b/launcher/ui/dialogs/VersionSelectDialog.h index 18a50cdb..c20a9ed5 100644 --- a/launcher/ui/dialogs/VersionSelectDialog.h +++ b/launcher/ui/dialogs/VersionSelectDialog.h @@ -49,6 +49,7 @@ public: void setCurrentVersion(const QString & version); void setFuzzyFilter(BaseVersionList::ModelRoles role, QString filter); void setExactFilter(BaseVersionList::ModelRoles role, QString filter); + void setExactIfPresentFilter(BaseVersionList::ModelRoles role, QString filter); void setEmptyString(QString emptyString); void setEmptyErrorString(QString emptyErrorString); void setResizeOn(int column); -- cgit From 1208300ddfc03b409dca7a3b1b0bf5ab8715ba1a Mon Sep 17 00:00:00 2001 From: leo78913 Date: Wed, 12 Jul 2023 10:57:30 -0300 Subject: i forgor to change skin upload browse button Signed-off-by: leo78913 --- launcher/ui/dialogs/SkinUploadDialog.ui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'launcher/ui/dialogs') diff --git a/launcher/ui/dialogs/SkinUploadDialog.ui b/launcher/ui/dialogs/SkinUploadDialog.ui index c7b16645..2c81a7fe 100644 --- a/launcher/ui/dialogs/SkinUploadDialog.ui +++ b/launcher/ui/dialogs/SkinUploadDialog.ui @@ -42,7 +42,7 @@ - ... + Browse -- cgit From 97ff7afbe749358728bf4843f1022f2994902ef7 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Fri, 28 Jul 2023 01:16:00 +0300 Subject: keep the icon suffix Signed-off-by: Trial97 --- launcher/ui/dialogs/NewInstanceDialog.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'launcher/ui/dialogs') diff --git a/launcher/ui/dialogs/NewInstanceDialog.cpp b/launcher/ui/dialogs/NewInstanceDialog.cpp index 7b9bb944..fb91b8ae 100644 --- a/launcher/ui/dialogs/NewInstanceDialog.cpp +++ b/launcher/ui/dialogs/NewInstanceDialog.cpp @@ -284,28 +284,27 @@ QString NewInstanceDialog::iconKey() const void NewInstanceDialog::on_iconButton_clicked() { - importIconNow(); //so the user can switch back + importIconNow(); // so the user can switch back IconPickerDialog dlg(this); dlg.execWithSelection(InstIconKey); - if (dlg.result() == QDialog::Accepted) - { + if (dlg.result() == QDialog::Accepted) { InstIconKey = dlg.selectedIconKey; ui->iconButton