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/ui/dialogs/InstallLoaderDialog.cpp | |
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/ui/dialogs/InstallLoaderDialog.cpp')
-rw-r--r-- | launcher/ui/dialogs/InstallLoaderDialog.cpp | 33 |
1 files changed, 18 insertions, 15 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) }; } |