refactor: replace Open All with Open Missing

Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>
This commit is contained in:
Sefa Eyeoglu 2022-11-23 14:29:23 +01:00
parent e08d97825d
commit c06abd9b6b
No known key found for this signature in database
GPG Key ID: C10411294912A422
2 changed files with 18 additions and 11 deletions

View File

@ -1,14 +1,16 @@
#include "BlockedModsDialog.h"
#include <QDesktopServices>
#include <QDialogButtonBox>
#include <QPushButton>
#include "Application.h"
#include "ui_BlockedModsDialog.h"
#include "Application.h"
#include "modplatform/helpers/HashUtils.h"
#include <QDebug>
#include <QDesktopServices>
#include <QDialogButtonBox>
#include <QDragEnterEvent>
#include <QFileDialog>
#include <QFileInfo>
#include <QPushButton>
#include <QStandardPaths>
BlockedModsDialog::BlockedModsDialog(QWidget* parent, const QString& title, const QString& text, QList<BlockedMod>& mods)
@ -19,8 +21,8 @@ BlockedModsDialog::BlockedModsDialog(QWidget* parent, const QString& title, cons
ui->setupUi(this);
auto openAllButton = ui->buttonBox->addButton(tr("Open All"), QDialogButtonBox::ActionRole);
connect(openAllButton, &QPushButton::clicked, this, &BlockedModsDialog::openAll);
m_openMissingButton = ui->buttonBox->addButton(tr("Open Missing"), QDialogButtonBox::ActionRole);
connect(m_openMissingButton, &QPushButton::clicked, this, [this]() { openAll(true); });
auto downloadFolderButton = ui->buttonBox->addButton(tr("Add Download Folder"), QDialogButtonBox::ActionRole);
connect(downloadFolderButton, &QPushButton::clicked, this, &BlockedModsDialog::addDownloadFolder);
@ -78,12 +80,14 @@ void BlockedModsDialog::done(int r)
disconnect(&m_watcher, &QFileSystemWatcher::directoryChanged, this, &BlockedModsDialog::directoryChanged);
}
void BlockedModsDialog::openAll()
void BlockedModsDialog::openAll(bool missingOnly)
{
for (auto& mod : m_mods) {
if (!missingOnly || !mod.matched) {
QDesktopServices::openUrl(mod.websiteUrl);
}
}
}
void BlockedModsDialog::addDownloadFolder()
{
@ -124,8 +128,10 @@ void BlockedModsDialog::update()
if (allModsMatched()) {
ui->labelModsFound->setText("<span style=\"color:green\">✔</span>" + tr("All mods found"));
m_openMissingButton->setDisabled(true);
} else {
ui->labelModsFound->setText(tr("Please download the missing mods."));
m_openMissingButton->setDisabled(false);
}
}

View File

@ -6,10 +6,10 @@
#include <QFileSystemWatcher>
#include "modplatform/helpers/HashUtils.h"
#include "tasks/ConcurrentTask.h"
class QPushButton;
struct BlockedMod {
QString name;
QString websiteUrl;
@ -46,8 +46,9 @@ class BlockedModsDialog : public QDialog {
shared_qobject_ptr<ConcurrentTask> m_hashing_task;
QSet<QString> m_pending_hash_paths;
bool m_rehash_pending;
QPushButton *m_openMissingButton;
void openAll();
void openAll(bool missingOnly);
void addDownloadFolder();
void update();
void directoryChanged(QString path);