diff options
author | flow <thiagodonato300@gmail.com> | 2022-02-21 21:53:21 -0300 |
---|---|---|
committer | flow <thiagodonato300@gmail.com> | 2022-02-21 21:53:21 -0300 |
commit | f5cf4eb45f6610851367bdcab7b87766bed14288 (patch) | |
tree | 6406ddba47cc719a4e72a9a6e108b7bf1041d446 /launcher/ui/pages/modplatform/flame/FlameModPage.cpp | |
parent | 512395e3f1ada7e16fa547f7fbe050e20a6d3209 (diff) | |
download | PrismLauncher-f5cf4eb45f6610851367bdcab7b87766bed14288.tar.gz PrismLauncher-f5cf4eb45f6610851367bdcab7b87766bed14288.tar.bz2 PrismLauncher-f5cf4eb45f6610851367bdcab7b87766bed14288.zip |
feat(ui): allow downloading multiple mods from CurseForge at once
Diffstat (limited to 'launcher/ui/pages/modplatform/flame/FlameModPage.cpp')
-rw-r--r-- | launcher/ui/pages/modplatform/flame/FlameModPage.cpp | 51 |
1 files changed, 33 insertions, 18 deletions
diff --git a/launcher/ui/pages/modplatform/flame/FlameModPage.cpp b/launcher/ui/pages/modplatform/flame/FlameModPage.cpp index a816c681..728c3641 100644 --- a/launcher/ui/pages/modplatform/flame/FlameModPage.cpp +++ b/launcher/ui/pages/modplatform/flame/FlameModPage.cpp @@ -35,6 +35,7 @@ FlameModPage::FlameModPage(ModDownloadDialog *dialog, BaseInstance *instance) connect(ui->sortByBox, SIGNAL(currentIndexChanged(int)), this, SLOT(triggerSearch())); connect(ui->packView->selectionModel(), &QItemSelectionModel::currentChanged, this, &FlameModPage::onSelectionChanged); connect(ui->versionSelectionBox, &QComboBox::currentTextChanged, this, &FlameModPage::onVersionSelectionChanged); + connect(ui->modSelectionButton, &QPushButton::clicked, this, &FlameModPage::onModSelected); } FlameModPage::~FlameModPage() @@ -62,7 +63,7 @@ bool FlameModPage::shouldDisplay() const void FlameModPage::openedImpl() { - suggestCurrent(); + updateSelectionButton(); triggerSearch(); } @@ -77,10 +78,6 @@ void FlameModPage::onSelectionChanged(QModelIndex first, QModelIndex second) if(!first.isValid()) { - if(isOpened) - { - dialog->setSuggestedMod(); - } return; } @@ -112,6 +109,10 @@ void FlameModPage::onSelectionChanged(QModelIndex first, QModelIndex second) if (!current.versionsLoaded) { qDebug() << "Loading flame mod versions"; + + ui->modSelectionButton->setText(tr("Loading versions...")); + ui->modSelectionButton->setEnabled(false); + auto netJob = new NetJob(QString("Flame::ModVersions(%1)").arg(current.name), APPLICATION->network()); std::shared_ptr<QByteArray> response = std::make_shared<QByteArray>(); int addonId = current.addonId; @@ -151,7 +152,7 @@ void FlameModPage::onSelectionChanged(QModelIndex first, QModelIndex second) ui->versionSelectionBox->addItem(tr("No Valid Version found!"), QVariant(-1)); } - suggestCurrent(); + updateSelectionButton(); }); netJob->start(); } @@ -163,25 +164,26 @@ void FlameModPage::onSelectionChanged(QModelIndex first, QModelIndex second) if(ui->versionSelectionBox->count() == 0){ ui->versionSelectionBox->addItem(tr("No Valid Version found!"), QVariant(-1)); } - suggestCurrent(); + + updateSelectionButton(); } } -void FlameModPage::suggestCurrent() +void FlameModPage::updateSelectionButton() { - if(!isOpened) - { + if(!isOpened || selectedVersion < 0){ + ui->modSelectionButton->setEnabled(false); return; } - if (selectedVersion == -1) - { - dialog->setSuggestedMod(); - return; + ui->modSelectionButton->setEnabled(true); + auto& version = current.versions[selectedVersion]; + if(!dialog->isModSelected(current.name, version.fileName)){ + ui->modSelectionButton->setText(tr("Select mod for download")); + } + else{ + ui->modSelectionButton->setText(tr("Deselect mod for download")); } - - auto version = current.versions[selectedVersion]; - dialog->setSuggestedMod(current.name, new ModDownloadTask(version.downloadUrl, version.fileName , dialog->mods)); } void FlameModPage::onVersionSelectionChanged(QString data) @@ -192,5 +194,18 @@ void FlameModPage::onVersionSelectionChanged(QString data) return; } selectedVersion = ui->versionSelectionBox->currentData().toInt(); - suggestCurrent(); + updateSelectionButton(); +} + +void FlameModPage::onModSelected() +{ + auto& version = current.versions[selectedVersion]; + if (dialog->isModSelected(current.name, version.fileName)){ + dialog->removeSelectedMod(current.name); + } + else{ + dialog->addSelectedMod(current.name, new ModDownloadTask(version.downloadUrl, version.fileName , dialog->mods)); + } + + updateSelectionButton(); } |