aboutsummaryrefslogtreecommitdiff
path: root/launcher/ui/dialogs/BlockedModsDialog.h
blob: 0a5c90db02c7b7a0ebeb7080f69208a780e152ab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#pragma once

#include <QDialog>
#include <QString>
#include <QList>

#include <QFileSystemWatcher>

#include "modplatform/helpers/HashUtils.h"

#include "tasks/ConcurrentTask.h"

struct BlockedMod {
    QString name;
    QString websiteUrl;
    QString hash;
    bool matched;
    QString localPath;

};

QT_BEGIN_NAMESPACE
namespace Ui { class BlockedModsDialog; }
QT_END_NAMESPACE

class BlockedModsDialog : public QDialog {
Q_OBJECT

public:
    BlockedModsDialog(QWidget *parent, const QString &title, const QString &text, QList<BlockedMod> &mods);

    ~BlockedModsDialog() override;


private:
    Ui::BlockedModsDialog *ui;
    QList<BlockedMod> &mods;
    QFileSystemWatcher watcher;
    shared_qobject_ptr<ConcurrentTask> hashing_task;

    void openAll();
    void update();
    void directoryChanged(QString path);
    void setupWatch();
    void scanPaths();
    void scanPath(QString path);
    void checkMatchHash(QString hash, QString path);

    bool checkValidPath(QString path);
    bool allModsMatched();
};

QDebug operator<<(QDebug debug, const BlockedMod &m);