diff options
author | TheKodeToad <TheKodeToad@proton.me> | 2023-07-01 19:32:04 +0100 |
---|---|---|
committer | TheKodeToad <TheKodeToad@proton.me> | 2023-07-01 19:39:04 +0100 |
commit | 9f9b5254a239d6359d199c33fa5d966e1f4d6e63 (patch) | |
tree | bd0ebeb0fc010e1c734ef8e014bd23c9f44a57c2 /launcher | |
parent | 284e374ae858d6784b6df48c83534dc6dc973747 (diff) | |
download | PrismLauncher-9f9b5254a239d6359d199c33fa5d966e1f4d6e63.tar.gz PrismLauncher-9f9b5254a239d6359d199c33fa5d966e1f4d6e63.tar.bz2 PrismLauncher-9f9b5254a239d6359d199c33fa5d966e1f4d6e63.zip |
Double-click to install/change version
Signed-off-by: TheKodeToad <TheKodeToad@proton.me>
Diffstat (limited to 'launcher')
-rw-r--r-- | launcher/ui/dialogs/InstallLoaderDialog.cpp | 33 | ||||
-rw-r--r-- | launcher/ui/dialogs/VersionSelectDialog.cpp | 5 | ||||
-rw-r--r-- | launcher/ui/widgets/VersionSelectWidget.cpp | 5 | ||||
-rw-r--r-- | launcher/ui/widgets/VersionSelectWidget.h | 1 |
4 files changed, 27 insertions, 17 deletions
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<PackProfile> 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<PackProfile> 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<QDialog*>(dynamic_cast<PageContainer*>(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<PackProfile> 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<PackProfile> 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<PackProfile> profile, c QList<BasePage*> 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); diff --git a/launcher/ui/widgets/VersionSelectWidget.cpp b/launcher/ui/widgets/VersionSelectWidget.cpp index efc9c412..f20dad71 100644 --- a/launcher/ui/widgets/VersionSelectWidget.cpp +++ b/launcher/ui/widgets/VersionSelectWidget.cpp @@ -210,6 +210,11 @@ void VersionSelectWidget::selectSearch() search->setFocus(); } +VersionListView* VersionSelectWidget::view() +{ + return listView; +} + void VersionSelectWidget::selectRecommended() { auto idx = m_proxyModel->getRecommended(); diff --git a/launcher/ui/widgets/VersionSelectWidget.h b/launcher/ui/widgets/VersionSelectWidget.h index a1b60d35..624d9a23 100644 --- a/launcher/ui/widgets/VersionSelectWidget.h +++ b/launcher/ui/widgets/VersionSelectWidget.h @@ -65,6 +65,7 @@ public: void selectRecommended(); void selectCurrent(); void selectSearch(); + VersionListView* view(); void setCurrentVersion(const QString & version); void setFuzzyFilter(BaseVersionList::ModelRoles role, QString filter); |