2022-07-17 00:14:54 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <QDialog>
|
2022-10-25 09:19:19 +01:00
|
|
|
#include <QString>
|
|
|
|
#include <QList>
|
2022-07-17 00:14:54 +01:00
|
|
|
|
2022-10-25 09:19:19 +01:00
|
|
|
#include <QFileSystemWatcher>
|
|
|
|
|
|
|
|
#include "modplatform/helpers/HashUtils.h"
|
|
|
|
|
|
|
|
#include "tasks/ConcurrentTask.h"
|
2022-07-17 00:14:54 +01:00
|
|
|
|
2022-10-24 12:08:38 +01:00
|
|
|
struct BlockedMod {
|
|
|
|
QString name;
|
|
|
|
QString websiteUrl;
|
|
|
|
QString hash;
|
|
|
|
bool matched;
|
|
|
|
QString localPath;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2022-07-17 00:14:54 +01:00
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
namespace Ui { class BlockedModsDialog; }
|
|
|
|
QT_END_NAMESPACE
|
|
|
|
|
|
|
|
class BlockedModsDialog : public QDialog {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2022-10-25 09:19:19 +01:00
|
|
|
BlockedModsDialog(QWidget *parent, const QString &title, const QString &text, QList<BlockedMod> &mods);
|
2022-07-17 00:14:54 +01:00
|
|
|
|
|
|
|
~BlockedModsDialog() override;
|
|
|
|
|
2022-11-11 21:10:45 +00:00
|
|
|
protected:
|
|
|
|
void dragEnterEvent(QDragEnterEvent *event) override;
|
|
|
|
void dropEvent(QDropEvent *event) override;
|
2022-10-24 12:08:38 +01:00
|
|
|
|
2022-07-17 00:14:54 +01:00
|
|
|
private:
|
|
|
|
Ui::BlockedModsDialog *ui;
|
2022-11-11 22:45:40 +00:00
|
|
|
QList<BlockedMod> &m_mods;
|
|
|
|
QFileSystemWatcher m_watcher;
|
|
|
|
shared_qobject_ptr<ConcurrentTask> m_hashing_task;
|
|
|
|
QSet<QString> m_pending_hash_paths;
|
|
|
|
bool m_rehash_pending;
|
2022-10-25 09:19:19 +01:00
|
|
|
|
2022-07-17 00:14:54 +01:00
|
|
|
void openAll();
|
2022-11-11 21:10:45 +00:00
|
|
|
void addDownloadFolder();
|
2022-10-24 12:08:38 +01:00
|
|
|
void update();
|
2022-10-25 09:19:19 +01:00
|
|
|
void directoryChanged(QString path);
|
|
|
|
void setupWatch();
|
2022-10-26 04:18:14 +01:00
|
|
|
void scanPaths();
|
2022-11-11 22:45:40 +00:00
|
|
|
void scanPath(QString path, bool start_task);
|
2022-11-11 21:10:45 +00:00
|
|
|
void addHashTask(QString path);
|
2022-11-11 22:45:40 +00:00
|
|
|
void buildHashTask(QString path);
|
2022-10-25 09:19:19 +01:00
|
|
|
void checkMatchHash(QString hash, QString path);
|
2022-11-11 21:10:45 +00:00
|
|
|
void validateMatchedMods();
|
2022-11-11 22:45:40 +00:00
|
|
|
void runHashTask();
|
|
|
|
void hashTaskFinished();
|
2022-10-25 09:19:19 +01:00
|
|
|
|
|
|
|
bool checkValidPath(QString path);
|
|
|
|
bool allModsMatched();
|
2022-07-17 00:14:54 +01:00
|
|
|
};
|
2022-10-24 12:08:38 +01:00
|
|
|
|
2022-10-31 05:39:12 +00:00
|
|
|
QDebug operator<<(QDebug debug, const BlockedMod &m);
|