2022-07-17 04:44:54 +05:30
|
|
|
#include "BlockedModsDialog.h"
|
|
|
|
#include "ui_BlockedModsDialog.h"
|
2022-07-18 23:33:06 +05:30
|
|
|
#include <QPushButton>
|
2022-07-17 04:44:54 +05:30
|
|
|
#include <QDialogButtonBox>
|
|
|
|
#include <QDesktopServices>
|
|
|
|
|
2022-10-24 16:38:38 +05:30
|
|
|
#include <QDebug>
|
2022-07-17 04:44:54 +05:30
|
|
|
|
2022-10-24 16:38:38 +05:30
|
|
|
|
|
|
|
BlockedModsDialog::BlockedModsDialog(QWidget *parent, const QString &title, const QString &text, const QList<BlockedMod> &mods) :
|
|
|
|
QDialog(parent), ui(new Ui::BlockedModsDialog), mods(mods) {
|
2022-07-17 04:44:54 +05:30
|
|
|
ui->setupUi(this);
|
|
|
|
|
|
|
|
auto openAllButton = ui->buttonBox->addButton(tr("Open All"), QDialogButtonBox::ActionRole);
|
|
|
|
connect(openAllButton, &QPushButton::clicked, this, &BlockedModsDialog::openAll);
|
|
|
|
|
2022-10-24 16:38:38 +05:30
|
|
|
qDebug() << "Mods List: " << mods;
|
|
|
|
|
2022-07-17 04:44:54 +05:30
|
|
|
this->setWindowTitle(title);
|
|
|
|
ui->label->setText(text);
|
|
|
|
ui->textBrowser->setText(body);
|
2022-10-24 16:38:38 +05:30
|
|
|
update();
|
2022-07-17 04:44:54 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
BlockedModsDialog::~BlockedModsDialog() {
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
|
|
|
void BlockedModsDialog::openAll() {
|
2022-10-24 16:38:38 +05:30
|
|
|
for(auto &mod : mods) {
|
|
|
|
QDesktopServices::openUrl(mod.websiteUrl);
|
2022-07-17 04:44:54 +05:30
|
|
|
}
|
|
|
|
}
|
2022-10-24 16:38:38 +05:30
|
|
|
|
|
|
|
void BlockedModsDialog::update() {
|
|
|
|
QString text;
|
|
|
|
QString span;
|
|
|
|
|
|
|
|
for (auto &mod : mods) {
|
|
|
|
if (mod.matched) {
|
|
|
|
// ✔ -> html for HEAVY CHECK MARK : ✔
|
|
|
|
span = QString("<span style=\"color:green\"> ✔ Found at %1 </span>").arg(mod.localPath);
|
|
|
|
} else {
|
|
|
|
// ✘ -> html for HEAVY BALLOT X : ✘
|
|
|
|
span = QString("<span style=\"color:red\"> ✘ Not Found </span>");
|
|
|
|
}
|
|
|
|
text += QString("%1: <a href='%2'>%2</a> <p>Hash: %3 %4</p> <br/>").arg(mod.name, mod.websiteUrl, mod.hash, span);
|
|
|
|
}
|
|
|
|
|
|
|
|
ui->textBrowser->setText(text);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QDebug operator<<(QDebug debug, const BlockedMod &m) {
|
|
|
|
QDebugStateSaver saver(debug);
|
|
|
|
|
|
|
|
debug.nospace() << "{ name: " << m.name << ", websiteUrl: " << m.websiteUrl
|
|
|
|
<< ", hash: " << m.hash << ", matched: " << m.matched
|
|
|
|
<< ", localPath: " << m.localPath <<"}";
|
|
|
|
|
|
|
|
return debug;
|
|
|
|
}
|