aboutsummaryrefslogtreecommitdiff
path: root/launcher/ui/dialogs/ModDownloadDialog.cpp
diff options
context:
space:
mode:
authorflow <flowlnlnln@gmail.com>2022-07-15 09:34:11 -0300
committerflow <flowlnlnln@gmail.com>2022-08-01 07:33:29 -0300
commita8bcd85c93ad1e5af277652862f773413c255c47 (patch)
tree89fc4c891ac637a54265f7ba1d37cc5a48a7cad3 /launcher/ui/dialogs/ModDownloadDialog.cpp
parent127b558f9573daece14fe7140bc2242010fbaa9e (diff)
downloadPrismLauncher-a8bcd85c93ad1e5af277652862f773413c255c47.tar.gz
PrismLauncher-a8bcd85c93ad1e5af277652862f773413c255c47.tar.bz2
PrismLauncher-a8bcd85c93ad1e5af277652862f773413c255c47.zip
feat+refactor: add shortcuts to mod downloader and clean up
Signed-off-by: flow <flowlnlnln@gmail.com>
Diffstat (limited to 'launcher/ui/dialogs/ModDownloadDialog.cpp')
-rw-r--r--launcher/ui/dialogs/ModDownloadDialog.cpp46
1 files changed, 21 insertions, 25 deletions
diff --git a/launcher/ui/dialogs/ModDownloadDialog.cpp b/launcher/ui/dialogs/ModDownloadDialog.cpp
index 60c19856..31253bc2 100644
--- a/launcher/ui/dialogs/ModDownloadDialog.cpp
+++ b/launcher/ui/dialogs/ModDownloadDialog.cpp
@@ -19,36 +19,33 @@
#include "ModDownloadDialog.h"
#include <BaseVersion.h>
-#include <icons/IconList.h>
#include <InstanceList.h>
+#include <icons/IconList.h>
#include "Application.h"
-#include "ProgressDialog.h"
#include "ReviewMessageBox.h"
+#include <QDialogButtonBox>
#include <QLayout>
#include <QPushButton>
#include <QValidator>
-#include <QDialogButtonBox>
-#include "ui/widgets/PageContainer.h"
-#include "ui/pages/modplatform/modrinth/ModrinthModPage.h"
#include "ModDownloadTask.h"
+#include "ui/pages/modplatform/flame/FlameModPage.h"
+#include "ui/pages/modplatform/modrinth/ModrinthModPage.h"
+#include "ui/widgets/PageContainer.h"
-
-ModDownloadDialog::ModDownloadDialog(const std::shared_ptr<ModFolderModel> &mods, QWidget *parent,
- BaseInstance *instance)
- : QDialog(parent), mods(mods), m_instance(instance)
+ModDownloadDialog::ModDownloadDialog(const std::shared_ptr<ModFolderModel>& mods, QWidget* parent, BaseInstance* instance)
+ : QDialog(parent), mods(mods), m_verticalLayout(new QVBoxLayout(this)), m_instance(instance)
{
setObjectName(QStringLiteral("ModDownloadDialog"));
-
- resize(std::max(0.5*parent->width(), 400.0), std::max(0.75*parent->height(), 400.0));
-
- m_verticalLayout = new QVBoxLayout(this);
m_verticalLayout->setObjectName(QStringLiteral("verticalLayout"));
+ resize(std::max(0.5 * parent->width(), 400.0), std::max(0.75 * parent->height(), 400.0));
+
setWindowIcon(APPLICATION->getThemedIcon("new"));
- // NOTE: m_buttons must be initialized before PageContainer, because it indirectly accesses m_buttons through setSuggestedPack! Do not move this below.
+ // NOTE: m_buttons must be initialized before PageContainer, because it indirectly accesses m_buttons through setSuggestedPack! Do not
+ // move this below.
m_buttons = new QDialogButtonBox(QDialogButtonBox::Help | QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
m_container = new PageContainer(this);
@@ -65,6 +62,8 @@ ModDownloadDialog::ModDownloadDialog(const std::shared_ptr<ModFolderModel> &mods
OkButton->setDefault(true);
OkButton->setAutoDefault(true);
OkButton->setText(tr("Review and confirm"));
+ OkButton->setShortcut(tr("Ctrl+Return"));
+ OkButton->setToolTip(tr("Opens a new popup to review your selected mods and confirm your selection. Shortcut: Ctrl+Return"));
connect(OkButton, &QPushButton::clicked, this, &ModDownloadDialog::confirm);
auto CancelButton = m_buttons->button(QDialogButtonBox::Cancel);
@@ -118,9 +117,9 @@ void ModDownloadDialog::accept()
QDialog::accept();
}
-QList<BasePage *> ModDownloadDialog::getPages()
+QList<BasePage*> ModDownloadDialog::getPages()
{
- QList<BasePage *> pages;
+ QList<BasePage*> pages;
pages.append(new ModrinthModPage(this, m_instance));
if (APPLICATION->currentCapabilities() & Application::SupportsFlame)
@@ -129,7 +128,7 @@ QList<BasePage *> ModDownloadDialog::getPages()
return pages;
}
-void ModDownloadDialog::addSelectedMod(const QString& name, ModDownloadTask* task)
+void ModDownloadDialog::addSelectedMod(QString name, ModDownloadTask* task)
{
removeSelectedMod(name);
modTask.insert(name, task);
@@ -137,16 +136,16 @@ void ModDownloadDialog::addSelectedMod(const QString& name, ModDownloadTask* tas
m_buttons->button(QDialogButtonBox::Ok)->setEnabled(!modTask.isEmpty());
}
-void ModDownloadDialog::removeSelectedMod(const QString &name)
+void ModDownloadDialog::removeSelectedMod(QString name)
{
- if(modTask.contains(name))
+ if (modTask.contains(name))
delete modTask.find(name).value();
modTask.remove(name);
m_buttons->button(QDialogButtonBox::Ok)->setEnabled(!modTask.isEmpty());
}
-bool ModDownloadDialog::isModSelected(const QString &name, const QString& filename) const
+bool ModDownloadDialog::isModSelected(QString name, QString filename) const
{
// FIXME: Is there a way to check for versions without checking the filename
// as a heuristic, other than adding such info to ModDownloadTask itself?
@@ -154,16 +153,13 @@ bool ModDownloadDialog::isModSelected(const QString &name, const QString& filena
return iter != modTask.end() && (iter.value()->getFilename() == filename);
}
-bool ModDownloadDialog::isModSelected(const QString &name) const
+bool ModDownloadDialog::isModSelected(QString name) const
{
auto iter = modTask.find(name);
return iter != modTask.end();
}
-ModDownloadDialog::~ModDownloadDialog()
+const QList<ModDownloadTask*> ModDownloadDialog::getTasks()
{
-}
-
-const QList<ModDownloadTask*> ModDownloadDialog::getTasks() {
return modTask.values();
}