diff --git a/launcher/FileSystem.cpp b/launcher/FileSystem.cpp index 48654a7c4..ff543b3a8 100644 --- a/launcher/FileSystem.cpp +++ b/launcher/FileSystem.cpp @@ -680,11 +680,11 @@ bool interactiveMove(const QString& source, const QString& destination, bool rec { const QFileInfo sourceInfo(source); - // Make sure the source exists. + // Make sure the source exists. if (!sourceInfo.exists()) return false; - // Recursive doesn't make sense if the source isn't a directory. + // Recursive doesn't make sense if the source isn't a directory. if (recursive && sourceInfo.isDir()) { QDirIterator sourceIt(source, QDir::Filter::Files | QDir::Filter::Dirs | QDir::Filter::Hidden | QDir::Filter::NoDotAndDotDot); @@ -700,7 +700,7 @@ bool interactiveMove(const QString& source, const QString& destination, bool rec FileConflictDialog dialog(source, destination, true, parent); FileConflictDialog::Result result = dialog.execWithResult(); - switch(result) { + switch (result) { case FileConflictDialog::Cancel: return false; case FileConflictDialog::ChooseDestination: @@ -1751,10 +1751,15 @@ QString getSymLinkTarget(const QString& path) return QFileInfo(path).symLinkTarget(); } -bool tryCreateSymlink(const QString& source, const QString& destination, const QString& symlinkName /* = "symbolic link" */) { +bool tryCreateSymlink(const QString& source, const QString& destination, const QString& symlinkName /* = "symbolic link" */) +{ // Make sure that symbolic links are supported. if (!FS::canLink(source, destination)) { - CustomMessageBox::selectable(nullptr, QObject::tr("Failed"), QObject::tr("Failed to create %1.\nSymbolic links are not supported on the filesystem").arg(symlinkName), QMessageBox::Warning, QMessageBox::Ok)->exec(); + CustomMessageBox::selectable( + nullptr, QObject::tr("Failed"), + QObject::tr("Failed to create %1.\nSymbolic links are not supported on the filesystem").arg(symlinkName), QMessageBox::Warning, + QMessageBox::Ok) + ->exec(); return false; } @@ -1770,7 +1775,11 @@ bool tryCreateSymlink(const QString& source, const QString& destination, const Q } else if (QFileInfo::exists(destination)) { if (!FS::checkFolderPathEmpty(destination)) { if (!interactiveMove(destination, source, true)) { - CustomMessageBox::selectable(nullptr, QObject::tr("Failed"), QObject::tr("Failed to create %1.\nEnsure that \"%2\" is empty.").arg(symlinkName).arg(destination), QMessageBox::Warning, QMessageBox::Ok)->exec(); + CustomMessageBox::selectable( + nullptr, QObject::tr("Failed"), + QObject::tr("Failed to create %1.\nEnsure that \"%2\" is empty.").arg(symlinkName).arg(destination), + QMessageBox::Warning, QMessageBox::Ok) + ->exec(); return false; } } @@ -1780,7 +1789,10 @@ bool tryCreateSymlink(const QString& source, const QString& destination, const Q // Make sure the source folder exists if (!FS::ensureFolderPathExists(source)) { - CustomMessageBox::selectable(nullptr, QObject::tr("Failed"), QObject::tr("Failed to create %1.\nEnsure that \"%2\" exists.").arg(symlinkName).arg(source), QMessageBox::Warning, QMessageBox::Ok)->exec(); + CustomMessageBox::selectable(nullptr, QObject::tr("Failed"), + QObject::tr("Failed to create %1.\nEnsure that \"%2\" exists.").arg(symlinkName).arg(source), + QMessageBox::Warning, QMessageBox::Ok) + ->exec(); return false; } @@ -1788,11 +1800,13 @@ bool tryCreateSymlink(const QString& source, const QString& destination, const Q folderLink.linkRecursively(false); if (!folderLink()) { - CustomMessageBox::selectable(nullptr, QObject::tr("Failed"), QObject::tr("Failed to create %1. Error %2: %3") - .arg(symlinkName) - .arg(folderLink.getOSError().value()) - .arg(folderLink.getOSError().message().c_str()), - QMessageBox::Warning, QMessageBox::Ok)->exec(); + CustomMessageBox::selectable(nullptr, QObject::tr("Failed"), + QObject::tr("Failed to create %1. Error %2: %3") + .arg(symlinkName) + .arg(folderLink.getOSError().value()) + .arg(folderLink.getOSError().message().c_str()), + QMessageBox::Warning, QMessageBox::Ok) + ->exec(); } return true; diff --git a/launcher/minecraft/MinecraftInstance.cpp b/launcher/minecraft/MinecraftInstance.cpp index 14860d778..6c9d80d30 100644 --- a/launcher/minecraft/MinecraftInstance.cpp +++ b/launcher/minecraft/MinecraftInstance.cpp @@ -1331,15 +1331,13 @@ bool MinecraftInstance::updateSharedDirectories() bool success = true; for (const auto& [useSetting, source, destination] : sharedDirectories) { // Create symlink if useSetting is true, remove symlink if false. - if (m_settings->get(useSetting).toBool()) - { + if (m_settings->get(useSetting).toBool()) { // Try to create symlink, set setting to false if failed. - if(!FS::tryCreateSymlink(source, destination, tr("shared folder"))) { + if (!FS::tryCreateSymlink(source, destination, tr("shared folder"))) { m_settings->set(useSetting, false); success = false; } - } - else { + } else { // Safety check if (FS::isSymLink(destination)) { success = FS::deletePath(destination) && success; diff --git a/launcher/ui/pages/instance/WorldListPage.cpp b/launcher/ui/pages/instance/WorldListPage.cpp index 52911bd57..247269703 100644 --- a/launcher/ui/pages/instance/WorldListPage.cpp +++ b/launcher/ui/pages/instance/WorldListPage.cpp @@ -48,10 +48,10 @@ #include #include #include +#include #include #include #include -#include #include "FileSystem.h" #include "tools/MCEditTool.h" diff --git a/launcher/ui/widgets/MinecraftSettingsWidget.cpp b/launcher/ui/widgets/MinecraftSettingsWidget.cpp index 89ce06413..285d5fae3 100644 --- a/launcher/ui/widgets/MinecraftSettingsWidget.cpp +++ b/launcher/ui/widgets/MinecraftSettingsWidget.cpp @@ -284,7 +284,8 @@ void MinecraftSettingsWidget::loadSettings() m_ui->liteLoader->blockSignals(false); // Shared folders - m_ui->sharedScreenshotsFolder->initialize(settings->get("UseSharedScreenshotsFolder").toBool(), settings->get("SharedScreenshotsPath").toString()); + m_ui->sharedScreenshotsFolder->initialize(settings->get("UseSharedScreenshotsFolder").toBool(), + settings->get("SharedScreenshotsPath").toString()); m_ui->sharedSavesFolder->initialize(settings->get("UseSharedSavesFolder").toBool(), settings->get("SharedSavesPath").toString()); m_ui->sharedResourcePacksFolder->initialize(settings->get("UseSharedResourcePacksFolder").toBool(), settings->get("SharedResourcePacksPath").toString());