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