mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2025-09-08 11:31:32 -04:00
Clang-format
Signed-off-by: Naomi <103967@gmail.com>
This commit is contained in:
parent
db4e7d8820
commit
a478fa60d3
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -48,10 +48,10 @@
|
||||
#include <QKeyEvent>
|
||||
#include <QMenu>
|
||||
#include <QMessageBox>
|
||||
#include <QPushButton>
|
||||
#include <QSortFilterProxyModel>
|
||||
#include <QTreeView>
|
||||
#include <Qt>
|
||||
#include <QPushButton>
|
||||
|
||||
#include "FileSystem.h"
|
||||
#include "tools/MCEditTool.h"
|
||||
|
@ -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());
|
||||
|
Loading…
x
Reference in New Issue
Block a user