From b5a45c2acff7797a85f43b1abfeaa171912e84af Mon Sep 17 00:00:00 2001 From: rainmakerv2 <30595646+jpau02@users.noreply.github.com> Date: Tue, 4 Mar 2025 16:51:00 +0800 Subject: [PATCH] Add button for creating portable folder --- src/qt_gui/settings_dialog.cpp | 19 ++++++++ src/qt_gui/settings_dialog.ui | 84 +++++++++++++++++++++++++++------- 2 files changed, 86 insertions(+), 17 deletions(-) diff --git a/src/qt_gui/settings_dialog.cpp b/src/qt_gui/settings_dialog.cpp index 8bd72a237..eed148933 100644 --- a/src/qt_gui/settings_dialog.cpp +++ b/src/qt_gui/settings_dialog.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include "common/config.h" @@ -234,6 +235,21 @@ SettingsDialog::SettingsDialog(std::span physical_devices, Common::FS::GetUserPath(Common::FS::PathType::CustomTrophy)); QDesktopServices::openUrl(QUrl::fromLocalFile(userPath)); }); + + connect(ui->PortableUserButton, &QPushButton::clicked, this, []() { + QString userDir; + Common::FS::PathToQString(userDir, std::filesystem::current_path() / "user"); + if (std::filesystem::exists(std::filesystem::current_path() / "user")) { + QMessageBox::information(NULL, "Cannot create portable user folder", + userDir + " already exists"); + } else { + std::filesystem::copy(Common::FS::GetUserPath(Common::FS::PathType::UserDir), + std::filesystem::current_path() / "user", + std::filesystem::copy_options::recursive); + QMessageBox::information(NULL, "Portable user folder created", + userDir + " successfully created"); + } + }); } // Input TAB @@ -344,6 +360,7 @@ SettingsDialog::SettingsDialog(std::span physical_devices, ui->saveDataGroupBox->installEventFilter(this); ui->currentSaveDataPath->installEventFilter(this); ui->browseButton->installEventFilter(this); + ui->PortableUserFolderGroupBox->installEventFilter(this); // Debug ui->debugDump->installEventFilter(this); @@ -650,6 +667,8 @@ void SettingsDialog::updateNoteTextEdit(const QString& elementName) { text = tr("Add:\\nAdd a folder to the list."); } else if (elementName == "removeFolderButton") { text = tr("Remove:\\nRemove a folder from the list."); + } else if (elementName == "PortableUserFolderGroupBox") { + text = tr("Portable user folder:\\nStores shadPS4 settings and data that will be applied only to the shadPS4 build located in the current folder"); } // Save Data diff --git a/src/qt_gui/settings_dialog.ui b/src/qt_gui/settings_dialog.ui index 7db0afa59..5600a0db7 100644 --- a/src/qt_gui/settings_dialog.ui +++ b/src/qt_gui/settings_dialog.ui @@ -31,7 +31,7 @@ Settings - + :/images/shadps4.ico:/images/shadps4.ico @@ -59,7 +59,7 @@ - 0 + 5 @@ -74,7 +74,7 @@ 0 0 946 - 545 + 536 @@ -130,9 +130,6 @@ 9 - - Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignTop - @@ -455,7 +452,7 @@ 0 0 946 - 545 + 536 @@ -904,7 +901,7 @@ 0 0 946 - 545 + 536 @@ -1199,7 +1196,7 @@ 0 0 946 - 545 + 536 @@ -1306,14 +1303,14 @@ Top - + Bottom - + @@ -1335,8 +1332,7 @@ - - + @@ -1442,7 +1438,7 @@ 0 0 946 - 545 + 536 @@ -1726,7 +1722,7 @@ 0 0 946 - 545 + 536 @@ -1800,6 +1796,58 @@ + + + + Portable User Folder + + + + + + + + Qt::Orientation::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + Create Portable User Folder from Common User Folder + + + + + + + Qt::Orientation::Horizontal + + + + 40 + 20 + + + + + + + + + @@ -1816,7 +1864,7 @@ 0 0 946 - 545 + 536 @@ -2068,6 +2116,8 @@ - + + +