diff options
author | Rachel Powers <508861+Ryex@users.noreply.github.com> | 2023-03-21 11:07:20 -0700 |
---|---|---|
committer | Rachel Powers <508861+Ryex@users.noreply.github.com> | 2023-03-21 11:07:20 -0700 |
commit | 02bf086c09a26fb7dfd9a95d2a6f81a7a7d4c161 (patch) | |
tree | f94ba2721e81bbe7d49961b17c2e0bb06aa85d3f /launcher/ui | |
parent | 6dcf34acdc8ec3dcbb094e4981ef136cd6a99913 (diff) | |
download | PrismLauncher-02bf086c09a26fb7dfd9a95d2a6f81a7a7d4c161.tar.gz PrismLauncher-02bf086c09a26fb7dfd9a95d2a6f81a7a7d4c161.tar.bz2 PrismLauncher-02bf086c09a26fb7dfd9a95d2a6f81a7a7d4c161.zip |
feat: watch sub directories for mods
Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
Diffstat (limited to 'launcher/ui')
-rw-r--r-- | launcher/ui/dialogs/BlockedModsDialog.cpp | 29 | ||||
-rw-r--r-- | launcher/ui/dialogs/BlockedModsDialog.h | 1 |
2 files changed, 22 insertions, 8 deletions
diff --git a/launcher/ui/dialogs/BlockedModsDialog.cpp b/launcher/ui/dialogs/BlockedModsDialog.cpp index ff885f10..05f50c06 100644 --- a/launcher/ui/dialogs/BlockedModsDialog.cpp +++ b/launcher/ui/dialogs/BlockedModsDialog.cpp @@ -39,7 +39,6 @@ #include <QFileInfo> #include <QMimeData> #include <QPushButton> -#include <QMimeData> #include <QStandardPaths> BlockedModsDialog::BlockedModsDialog(QWidget* parent, const QString& title, const QString& text, QList<BlockedMod>& mods) @@ -89,11 +88,11 @@ void BlockedModsDialog::dragEnterEvent(QDragEnterEvent* e) void BlockedModsDialog::dropEvent(QDropEvent* e) { for (QUrl& url : e->mimeData()->urls()) { - if (url.scheme().isEmpty()) { // ensure isLocalFile() works correctly + if (url.scheme().isEmpty()) { // ensure isLocalFile() works correctly url.setScheme("file"); } - if (!url.isLocalFile()) { // can't drop external files here. + if (!url.isLocalFile()) { // can't drop external files here. continue; } @@ -172,7 +171,7 @@ void BlockedModsDialog::update() } } -/// @brief Signal fired when a watched direcotry has changed +/// @brief Signal fired when a watched directory has changed /// @param path the path to the changed directory void BlockedModsDialog::directoryChanged(QString path) { @@ -186,8 +185,22 @@ void BlockedModsDialog::setupWatch() { const QString downloadsFolder = APPLICATION->settings()->get("DownloadsDir").toString(); const QString modsFolder = APPLICATION->settings()->get("CentralModsDir").toString(); - m_watcher.addPath(downloadsFolder); - m_watcher.addPath(modsFolder); + watchPath(downloadsFolder, true); + watchPath(modsFolder, true); +} + +void BlockedModsDialog::watchPath(QString path, bool watch_subdirectories) +{ + m_watcher.addPath(path); + + if (!watch_subdirectories) + return; + + QDirIterator it(path, QDirIterator::Subdirectories); + while (it.hasNext()) { + QString dir = it.next(); + watchPath(it.next(), watch_subdirectories); + } } /// @brief scan all watched folder @@ -221,7 +234,7 @@ void BlockedModsDialog::scanPath(QString path, bool start_task) } } -/// @brief add a hashing task for the file located at path, add the path to the pending set if the hasing task is already running +/// @brief add a hashing task for the file located at path, add the path to the pending set if the hashing task is already running /// @param path the path to the local file being hashed void BlockedModsDialog::addHashTask(QString path) { @@ -328,7 +341,7 @@ void BlockedModsDialog::validateMatchedMods() } } -/// @brief run hash task or mark a pending run if it is already runing +/// @brief run hash task or mark a pending run if it is already running void BlockedModsDialog::runHashTask() { if (!m_hashing_task->isRunning()) { diff --git a/launcher/ui/dialogs/BlockedModsDialog.h b/launcher/ui/dialogs/BlockedModsDialog.h index 014f488a..01077aa5 100644 --- a/launcher/ui/dialogs/BlockedModsDialog.h +++ b/launcher/ui/dialogs/BlockedModsDialog.h @@ -79,6 +79,7 @@ class BlockedModsDialog : public QDialog { void update(); void directoryChanged(QString path); void setupWatch(); + void watchPath(QString path, bool watch_subdirectories = false); void scanPaths(); void scanPath(QString path, bool start_task); void addHashTask(QString path); |