aboutsummaryrefslogtreecommitdiff
path: root/launcher/ui/dialogs/BlockedModsDialog.cpp
diff options
context:
space:
mode:
authorAlexandru Ionut Tripon <alexandru.tripon97@gmail.com>2023-04-14 23:03:42 +0300
committerTrial97 <alexandru.tripon97@gmail.com>2023-04-21 18:42:05 +0300
commitf231a33f6eabdc64c6af3a752db826cb6446614b (patch)
treee7ce02aece0bd9ae565959520a80991eb7385e19 /launcher/ui/dialogs/BlockedModsDialog.cpp
parent4fe497cd682258ca80501be2ad616de7a40043d9 (diff)
parent1b053032506afc3b7ad9734aea461dc39101ba64 (diff)
downloadPrismLauncher-f231a33f6eabdc64c6af3a752db826cb6446614b.tar.gz
PrismLauncher-f231a33f6eabdc64c6af3a752db826cb6446614b.tar.bz2
PrismLauncher-f231a33f6eabdc64c6af3a752db826cb6446614b.zip
Merge branch 'PrismLauncher:develop' into develop
Diffstat (limited to 'launcher/ui/dialogs/BlockedModsDialog.cpp')
-rw-r--r--launcher/ui/dialogs/BlockedModsDialog.cpp37
1 files changed, 29 insertions, 8 deletions
diff --git a/launcher/ui/dialogs/BlockedModsDialog.cpp b/launcher/ui/dialogs/BlockedModsDialog.cpp
index ff885f10..ba453df6 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,30 @@ 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);
+ const bool downloadsFolderWatchRecursive = APPLICATION->settings()->get("DownloadsDirWatchRecursive").toBool();
+ watchPath(downloadsFolder, downloadsFolderWatchRecursive);
+ watchPath(modsFolder, true);
+}
+
+void BlockedModsDialog::watchPath(QString path, bool watch_recursive)
+{
+ auto to_watch = QFileInfo(path);
+ auto to_watch_path = to_watch.canonicalFilePath();
+ if (m_watcher.directories().contains(to_watch_path))
+ return; // don't watch the same path twice (no loops!)
+
+ qDebug() << "[Blocked Mods Dialog] Adding Watch Path:" << path;
+ m_watcher.addPath(to_watch_path);
+
+ if (!to_watch.isDir() || !watch_recursive)
+ return;
+
+
+ QDirIterator it(to_watch_path, QDir::Filter::Dirs | QDir::Filter::NoDotAndDotDot, QDirIterator::NoIteratorFlags);
+ while (it.hasNext()) {
+ QString watch_dir = QDir(it.next()).canonicalPath(); // resolve symlinks and relative paths
+ watchPath(watch_dir, watch_recursive);
+ }
}
/// @brief scan all watched folder
@@ -221,7 +242,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 +349,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()) {