2022-11-23 19:24:04 +05:30
|
|
|
// SPDX-FileCopyrightText: 2022 Sefa Eyeoglu <contact@scrumplex.net>
|
|
|
|
// SPDX-FileCopyrightText: 2022 Rachel Powers <508861+Ryex@users.noreply.github.com>
|
|
|
|
// SPDX-FileCopyrightText: 2022 kumquat-ir <66188216+kumquat-ir@users.noreply.github.com>
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Prism Launcher - Minecraft Launcher
|
|
|
|
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
|
|
|
|
* Copyright (C) 2022 Rachel Powers <508861+Ryex@users.noreply.github.com>
|
|
|
|
* Copyright (C) 2022 kumquat-ir <66188216+kumquat-ir@users.noreply.github.com>
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, version 3.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2022-07-17 04:44:54 +05:30
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <QDialog>
|
2022-10-25 13:49:19 +05:30
|
|
|
#include <QList>
|
2022-12-06 17:46:27 +05:30
|
|
|
#include <QString>
|
2022-07-17 04:44:54 +05:30
|
|
|
|
2022-10-25 13:49:19 +05:30
|
|
|
#include <QFileSystemWatcher>
|
|
|
|
|
|
|
|
#include "tasks/ConcurrentTask.h"
|
2022-07-17 04:44:54 +05:30
|
|
|
|
2022-11-23 18:59:23 +05:30
|
|
|
class QPushButton;
|
|
|
|
|
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
|
2022-12-06 17:46:27 +05:30
|
|
|
namespace Ui {
|
|
|
|
class BlockedModsDialog;
|
|
|
|
}
|
2022-07-17 04:44:54 +05:30
|
|
|
QT_END_NAMESPACE
|
|
|
|
|
|
|
|
class BlockedModsDialog : public QDialog {
|
2022-12-06 17:46:27 +05:30
|
|
|
Q_OBJECT
|
2022-07-17 04:44:54 +05:30
|
|
|
|
2022-12-06 17:46:27 +05:30
|
|
|
public:
|
|
|
|
BlockedModsDialog(QWidget* parent, const QString& title, const QString& text, QList<BlockedMod>& mods);
|
2022-07-17 04:44:54 +05:30
|
|
|
|
|
|
|
~BlockedModsDialog() override;
|
|
|
|
|
2022-12-06 17:46:27 +05:30
|
|
|
protected:
|
|
|
|
void dragEnterEvent(QDragEnterEvent* event) override;
|
|
|
|
void dropEvent(QDropEvent* event) override;
|
2022-10-24 16:38:38 +05:30
|
|
|
|
2022-12-06 17:46:27 +05:30
|
|
|
protected slots:
|
2022-12-06 01:57:23 +05:30
|
|
|
void done(int r) override;
|
|
|
|
|
2022-12-06 17:46:27 +05:30
|
|
|
private:
|
|
|
|
Ui::BlockedModsDialog* ui;
|
|
|
|
QList<BlockedMod>& m_mods;
|
2022-11-12 04:15:40 +05:30
|
|
|
QFileSystemWatcher m_watcher;
|
|
|
|
shared_qobject_ptr<ConcurrentTask> m_hashing_task;
|
|
|
|
QSet<QString> m_pending_hash_paths;
|
|
|
|
bool m_rehash_pending;
|
2022-11-23 19:25:43 +05:30
|
|
|
QPushButton* m_openMissingButton;
|
2022-10-25 13:49:19 +05:30
|
|
|
|
2022-11-23 18:59:23 +05:30
|
|
|
void openAll(bool missingOnly);
|
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-12-06 17:46:27 +05:30
|
|
|
QDebug operator<<(QDebug debug, const BlockedMod& m);
|