aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRachel Powers <508861+Ryex@users.noreply.github.com>2022-10-25 20:18:14 -0700
committerRachel Powers <508861+Ryex@users.noreply.github.com>2022-11-01 04:24:11 -0700
commite9d4793b1e98944dad910b3952c117bb2d3369de (patch)
tree220af12faafe97d903d5c2298befee2aee91f050
parent13c7efa0584caf34950a6e6efa4b8e3bee16d764 (diff)
downloadPrismLauncher-e9d4793b1e98944dad910b3952c117bb2d3369de.tar.gz
PrismLauncher-e9d4793b1e98944dad910b3952c117bb2d3369de.tar.bz2
PrismLauncher-e9d4793b1e98944dad910b3952c117bb2d3369de.zip
minor clean up and add some docs
Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
-rw-r--r--launcher/FileSystem.cpp7
-rw-r--r--launcher/FileSystem.h1
-rw-r--r--launcher/modplatform/flame/FlameInstanceCreationTask.cpp2
-rw-r--r--launcher/modplatform/modpacksch/FTBPackInstallTask.cpp4
-rw-r--r--launcher/ui/dialogs/BlockedModsDialog.cpp42
-rw-r--r--launcher/ui/dialogs/BlockedModsDialog.h5
6 files changed, 38 insertions, 23 deletions
diff --git a/launcher/FileSystem.cpp b/launcher/FileSystem.cpp
index 4285fa87..8fe441b3 100644
--- a/launcher/FileSystem.cpp
+++ b/launcher/FileSystem.cpp
@@ -163,6 +163,10 @@ bool ensureFolderPathExists(QString foldernamepath)
return success;
}
+/// @brief Copy file at src to dest, ensures the full filepath exsists
+/// @param src srouce file path
+/// @param dst destination file path
+/// @return boolean: was there an error during the filecopy?
bool copyFile(QString &src, QString &dst) {
using copy_opts = fs::copy_options;
@@ -185,6 +189,9 @@ bool copyFile(QString &src, QString &dst) {
}
+/// @brief Copies a directory and it's contents from src to dest
+/// @param offset subdirectory form src to copy to dest
+/// @return if there was an error during the filecopy
bool copy::operator()(const QString& offset)
{
using copy_opts = fs::copy_options;
diff --git a/launcher/FileSystem.h b/launcher/FileSystem.h
index 68f6bc4c..ab006d48 100644
--- a/launcher/FileSystem.h
+++ b/launcher/FileSystem.h
@@ -77,6 +77,7 @@ bool ensureFolderPathExists(QString filenamepath);
bool copyFile(QString &src, QString &dst);
+/// @brief Copies a directory and it's contents from src to dest
class copy {
public:
copy(const QString& src, const QString& dst)
diff --git a/launcher/modplatform/flame/FlameInstanceCreationTask.cpp b/launcher/modplatform/flame/FlameInstanceCreationTask.cpp
index fbc4ecf3..edacb819 100644
--- a/launcher/modplatform/flame/FlameInstanceCreationTask.cpp
+++ b/launcher/modplatform/flame/FlameInstanceCreationTask.cpp
@@ -411,6 +411,8 @@ void FlameCreationTask::idResolverSucceeded(QEventLoop& loop)
}
}
+/// @brief copy the matched blocked mods to the instance staging area
+/// @param blocked_mods list of the blocked mods and their matched paths
void FlameCreationTask::copyBlockedMods(QList<BlockedMod> blocked_mods) {
setStatus(tr("Copying Blocked Mods..."));
diff --git a/launcher/modplatform/modpacksch/FTBPackInstallTask.cpp b/launcher/modplatform/modpacksch/FTBPackInstallTask.cpp
index f6bf2488..49fbafd6 100644
--- a/launcher/modplatform/modpacksch/FTBPackInstallTask.cpp
+++ b/launcher/modplatform/modpacksch/FTBPackInstallTask.cpp
@@ -189,9 +189,6 @@ void PackInstallTask::onResolveModsSucceeded()
// First check for blocked mods
if (!results_file.resolved || results_file.url.isEmpty()) {
- // QString type(local_file.type);
-
- // type[0] = type[0].toUpper();
BlockedMod blocked_mod;
blocked_mod.name = local_file.name;
@@ -355,6 +352,7 @@ void PackInstallTask::onModDownloadFailed(QString reason)
emitFailed(reason);
}
+/// @brief copy the matched blocked mods to the instance staging area
void PackInstallTask::copyBlockedMods() {
setStatus(tr("Copying Blocked Mods..."));
diff --git a/launcher/ui/dialogs/BlockedModsDialog.cpp b/launcher/ui/dialogs/BlockedModsDialog.cpp
index 542d0681..f5bc7f73 100644
--- a/launcher/ui/dialogs/BlockedModsDialog.cpp
+++ b/launcher/ui/dialogs/BlockedModsDialog.cpp
@@ -1,5 +1,3 @@
-#include <qfileinfo.h>
-#include <qnamespace.h>
#include "Application.h"
#include "BlockedModsDialog.h"
#include "ui_BlockedModsDialog.h"
@@ -27,7 +25,7 @@ BlockedModsDialog::BlockedModsDialog(QWidget *parent, const QString &title, cons
qDebug() << "Mods List: " << mods;
setupWatch();
- scanPaths(true);
+ scanPaths();
this->setWindowTitle(title);
ui->label->setText(text);
@@ -45,6 +43,7 @@ void BlockedModsDialog::openAll() {
}
}
+/// @brief update UI with current status of the blocked mod detection
void BlockedModsDialog::update() {
QString text;
QString span;
@@ -69,12 +68,15 @@ void BlockedModsDialog::update() {
}
}
+/// @brief Signal fired when a watched direcotry has changed
+/// @param path the path to the changed directory
void BlockedModsDialog::directoryChanged(QString path) {
qDebug() << "Directory changed: " << path;
- scanPath(path, false);
+ scanPath(path);
}
+/// @brief add the user downloads folder and the global mods folder to the filesystem watcher
void BlockedModsDialog::setupWatch() {
const QString downloadsFolder = QStandardPaths::writableLocation(QStandardPaths::DownloadLocation);
const QString modsFolder = APPLICATION->settings()->get("CentralModsDir").toString();
@@ -82,23 +84,24 @@ void BlockedModsDialog::setupWatch() {
watcher.addPath(modsFolder);
}
-void BlockedModsDialog::scanPaths(bool init) {
+
+/// @brief scan all watched folder
+void BlockedModsDialog::scanPaths() {
for (auto &dir : watcher.directories()) {
- scanPath(dir, init);
+ scanPath(dir);
}
}
-void BlockedModsDialog::scanPath(QString path, bool init) {
+/// @brief Scan the directory at path, skip paths that do not contain a file name
+/// of a blocked mod we are looking for
+/// @param path the directory to scan
+void BlockedModsDialog::scanPath(QString path) {
QDir scan_dir(path);
QDirIterator scan_it(path, QDir::Filter::Files | QDir::Filter::Hidden, QDirIterator::NoIteratorFlags);
while (scan_it.hasNext()) {
QString file = scan_it.next();
- if (checked_paths.contains(file)){
- continue;
- }
-
if (!checkValidPath(file)) {
continue;
}
@@ -113,10 +116,6 @@ void BlockedModsDialog::scanPath(QString path, bool init) {
connect(hash_task.get(), &Task::failed, [this, hash_task, file] {
qDebug() << "Failed to hash path: " << file;
});
-
- if (init) {
- checked_paths.insert(file);
- }
hashing_task->addTask(hash_task);
}
@@ -125,6 +124,10 @@ void BlockedModsDialog::scanPath(QString path, bool init) {
}
+/// @brief check if the conputed hash for the provided path matches a blocked
+/// mod we are looking for
+/// @param hash the computed hash for the provided path
+/// @param path the path to the local file being compared
void BlockedModsDialog::checkMatchHash(QString hash, QString path) {
bool match = false;
@@ -150,6 +153,9 @@ void BlockedModsDialog::checkMatchHash(QString hash, QString path) {
}
}
+/// @brief Check if the name of the file at path matches the naem of a blocked mod we are searching for
+/// @param path the path to check
+/// @return boolean: did the path match the name of a blocked mod?
bool BlockedModsDialog::checkValidPath(QString path) {
QFileInfo file = QFileInfo(path);
@@ -165,6 +171,8 @@ bool BlockedModsDialog::checkValidPath(QString path) {
return false;
}
+/// @brief have we found all the mods we're lookign for?
+/// @return boolean
bool BlockedModsDialog::allModsMatched() {
for (auto &mod : mods) {
if (!mod.matched)
@@ -173,7 +181,7 @@ bool BlockedModsDialog::allModsMatched() {
return true;
}
-
+/// qDebug print support for the BlockedMod struct
QDebug operator<<(QDebug debug, const BlockedMod &m) {
QDebugStateSaver saver(debug);
@@ -182,4 +190,4 @@ QDebug operator<<(QDebug debug, const BlockedMod &m) {
<< ", localPath: " << m.localPath <<"}";
return debug;
-} \ No newline at end of file
+}
diff --git a/launcher/ui/dialogs/BlockedModsDialog.h b/launcher/ui/dialogs/BlockedModsDialog.h
index 93b9f46a..cf1d3b3d 100644
--- a/launcher/ui/dialogs/BlockedModsDialog.h
+++ b/launcher/ui/dialogs/BlockedModsDialog.h
@@ -37,14 +37,13 @@ private:
QList<BlockedMod> &mods;
QFileSystemWatcher watcher;
shared_qobject_ptr<ConcurrentTask> hashing_task;
- QSet<QString> checked_paths;
void openAll();
void update();
void directoryChanged(QString path);
void setupWatch();
- void scanPaths(bool init);
- void scanPath(QString path, bool init);
+ void scanPaths();
+ void scanPath(QString path);
void checkMatchHash(QString hash, QString path);
bool checkValidPath(QString path);