diff --git a/launcher/ui/dialogs/ModDownloadDialog.cpp b/launcher/ui/dialogs/ModDownloadDialog.cpp
index 305e85c0..436f51f9 100644
--- a/launcher/ui/dialogs/ModDownloadDialog.cpp
+++ b/launcher/ui/dialogs/ModDownloadDialog.cpp
@@ -77,18 +77,20 @@ void ModDownloadDialog::confirm()
auto keys = modTask.keys();
keys.sort(Qt::CaseInsensitive);
- auto confirm_dialog = ReviewMessageBox::create(
- this,
- tr("Confirm mods to download")
- );
+ auto confirm_dialog = ReviewMessageBox::create(this, tr("Confirm mods to download"));
- for(auto& task : keys){
- confirm_dialog->appendMod(task, modTask.find(task).value()->getFilename());
+ for (auto& task : keys) {
+ confirm_dialog->appendMod({ task, modTask.find(task).value()->getFilename() });
}
- connect(confirm_dialog, &QDialog::accepted, this, &ModDownloadDialog::accept);
+ if (confirm_dialog->exec()) {
+ auto deselected = confirm_dialog->deselectedMods();
+ for (auto name : deselected) {
+ modTask.remove(name);
+ }
- confirm_dialog->open();
+ this->accept();
+ }
}
void ModDownloadDialog::accept()
diff --git a/launcher/ui/dialogs/ReviewMessageBox.cpp b/launcher/ui/dialogs/ReviewMessageBox.cpp
index 2bfd02e0..c92234a4 100644
--- a/launcher/ui/dialogs/ReviewMessageBox.cpp
+++ b/launcher/ui/dialogs/ReviewMessageBox.cpp
@@ -5,6 +5,9 @@ ReviewMessageBox::ReviewMessageBox(QWidget* parent, QString const& title, QStrin
: QDialog(parent), ui(new Ui::ReviewMessageBox)
{
ui->setupUi(this);
+
+ connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &ReviewMessageBox::accept);
+ connect(ui->buttonBox, &QDialogButtonBox::rejected, this, &ReviewMessageBox::reject);
}
ReviewMessageBox::~ReviewMessageBox()
@@ -17,15 +20,33 @@ auto ReviewMessageBox::create(QWidget* parent, QString&& title, QString&& icon)
return new ReviewMessageBox(parent, title, icon);
}
-void ReviewMessageBox::appendMod(const QString& name, const QString& filename)
+void ReviewMessageBox::appendMod(ModInformation&& info)
{
auto itemTop = new QTreeWidgetItem(ui->modTreeWidget);
- itemTop->setText(0, name);
+ itemTop->setCheckState(0, Qt::CheckState::Checked);
+ itemTop->setText(0, info.name);
auto filenameItem = new QTreeWidgetItem(itemTop);
- filenameItem->setText(0, tr("Filename: %1").arg(filename));
+ filenameItem->setText(0, tr("Filename: %1").arg(info.filename));
itemTop->insertChildren(0, { filenameItem });
ui->modTreeWidget->addTopLevelItem(itemTop);
}
+
+auto ReviewMessageBox::deselectedMods() -> QStringList
+{
+ QStringList list;
+
+ auto* item = ui->modTreeWidget->topLevelItem(0);
+
+ for (int i = 0; item != nullptr; ++i) {
+ if (item->checkState(0) == Qt::CheckState::Unchecked) {
+ list.append(item->text(0));
+ }
+
+ item = ui->modTreeWidget->topLevelItem(i);
+ }
+
+ return list;
+}
diff --git a/launcher/ui/dialogs/ReviewMessageBox.h b/launcher/ui/dialogs/ReviewMessageBox.h
index 48742cd9..9cfa679a 100644
--- a/launcher/ui/dialogs/ReviewMessageBox.h
+++ b/launcher/ui/dialogs/ReviewMessageBox.h
@@ -6,17 +6,23 @@ namespace Ui {
class ReviewMessageBox;
}
-class ReviewMessageBox final : public QDialog {
+class ReviewMessageBox : public QDialog {
Q_OBJECT
public:
static auto create(QWidget* parent, QString&& title, QString&& icon = "") -> ReviewMessageBox*;
- void appendMod(const QString& name, const QString& filename);
+ using ModInformation = struct {
+ QString name;
+ QString filename;
+ };
+
+ void appendMod(ModInformation&& info);
+ auto deselectedMods() -> QStringList;
~ReviewMessageBox();
- private:
+ protected:
ReviewMessageBox(QWidget* parent, const QString& title, const QString& icon);
Ui::ReviewMessageBox* ui;
diff --git a/launcher/ui/dialogs/ReviewMessageBox.ui b/launcher/ui/dialogs/ReviewMessageBox.ui
index d04f3b3f..ab3bcc2f 100644
--- a/launcher/ui/dialogs/ReviewMessageBox.ui
+++ b/launcher/ui/dialogs/ReviewMessageBox.ui
@@ -6,8 +6,8 @@
0
0
- 400
- 300
+ 500
+ 350
@@ -20,24 +20,7 @@
true
- -
-
-
- You're about to download the following mods:
-
-
-
-
-
-
- Qt::Horizontal
-
-
- QDialogButtonBox::Cancel|QDialogButtonBox::Ok
-
-
-
- -
true
@@ -58,41 +41,33 @@
+ -
+
+
+ You're about to download the following mods:
+
+
+
+ -
+
+
-
+
+
+ Only mods with a check will be downloaded!
+
+
+
+ -
+
+
+ QDialogButtonBox::Cancel|QDialogButtonBox::Ok
+
+
+
+
+
-
-
- buttonBox
- accepted()
- ReviewMessageBox
- accept()
-
-
- 200
- 265
-
-
- 199
- 149
-
-
-
-
- buttonBox
- rejected()
- ReviewMessageBox
- reject()
-
-
- 200
- 265
-
-
- 199
- 149
-
-
-
-
+