Add button for creating portable folder

This commit is contained in:
rainmakerv2 2025-03-04 16:51:00 +08:00
parent 15304ef913
commit b5a45c2acf
2 changed files with 86 additions and 17 deletions

View File

@ -5,6 +5,7 @@
#include <QDirIterator> #include <QDirIterator>
#include <QFileDialog> #include <QFileDialog>
#include <QHoverEvent> #include <QHoverEvent>
#include <QMessageBox>
#include <fmt/format.h> #include <fmt/format.h>
#include "common/config.h" #include "common/config.h"
@ -234,6 +235,21 @@ SettingsDialog::SettingsDialog(std::span<const QString> physical_devices,
Common::FS::GetUserPath(Common::FS::PathType::CustomTrophy)); Common::FS::GetUserPath(Common::FS::PathType::CustomTrophy));
QDesktopServices::openUrl(QUrl::fromLocalFile(userPath)); 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 // Input TAB
@ -344,6 +360,7 @@ SettingsDialog::SettingsDialog(std::span<const QString> physical_devices,
ui->saveDataGroupBox->installEventFilter(this); ui->saveDataGroupBox->installEventFilter(this);
ui->currentSaveDataPath->installEventFilter(this); ui->currentSaveDataPath->installEventFilter(this);
ui->browseButton->installEventFilter(this); ui->browseButton->installEventFilter(this);
ui->PortableUserFolderGroupBox->installEventFilter(this);
// Debug // Debug
ui->debugDump->installEventFilter(this); ui->debugDump->installEventFilter(this);
@ -650,6 +667,8 @@ void SettingsDialog::updateNoteTextEdit(const QString& elementName) {
text = tr("Add:\\nAdd a folder to the list."); text = tr("Add:\\nAdd a folder to the list.");
} else if (elementName == "removeFolderButton") { } else if (elementName == "removeFolderButton") {
text = tr("Remove:\\nRemove a folder from the list."); 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 // Save Data

View File

@ -31,7 +31,7 @@
<string>Settings</string> <string>Settings</string>
</property> </property>
<property name="windowIcon"> <property name="windowIcon">
<iconset> <iconset resource="../shadps4.qrc">
<normaloff>:/images/shadps4.ico</normaloff>:/images/shadps4.ico</iconset> <normaloff>:/images/shadps4.ico</normaloff>:/images/shadps4.ico</iconset>
</property> </property>
<property name="sizeGripEnabled"> <property name="sizeGripEnabled">
@ -59,7 +59,7 @@
</size> </size>
</property> </property>
<property name="currentIndex"> <property name="currentIndex">
<number>0</number> <number>5</number>
</property> </property>
<widget class="QScrollArea" name="generalTab"> <widget class="QScrollArea" name="generalTab">
<property name="widgetResizable"> <property name="widgetResizable">
@ -74,7 +74,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>946</width> <width>946</width>
<height>545</height> <height>536</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="generalTabVLayout" stretch="0"> <layout class="QVBoxLayout" name="generalTabVLayout" stretch="0">
@ -130,9 +130,6 @@
<property name="bottomMargin"> <property name="bottomMargin">
<number>9</number> <number>9</number>
</property> </property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignTop</set>
</property>
<item> <item>
<layout class="QVBoxLayout" name="emulatorverticalLayout"> <layout class="QVBoxLayout" name="emulatorverticalLayout">
<property name="spacing"> <property name="spacing">
@ -455,7 +452,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>946</width> <width>946</width>
<height>545</height> <height>536</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="guiTabVLayout" stretch="0"> <layout class="QVBoxLayout" name="guiTabVLayout" stretch="0">
@ -904,7 +901,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>946</width> <width>946</width>
<height>545</height> <height>536</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="graphicsTabVLayout" stretch="0,0"> <layout class="QVBoxLayout" name="graphicsTabVLayout" stretch="0,0">
@ -1199,7 +1196,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>946</width> <width>946</width>
<height>545</height> <height>536</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="userTabVLayout" stretch="0,0,1"> <layout class="QVBoxLayout" name="userTabVLayout" stretch="0,0,1">
@ -1335,8 +1332,7 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QDoubleSpinBox" name="popUpDurationSpinBox"> <widget class="QDoubleSpinBox" name="popUpDurationSpinBox"/>
</widget>
</item> </item>
<item> <item>
<spacer name="horizontalSpacer_4"> <spacer name="horizontalSpacer_4">
@ -1442,7 +1438,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>946</width> <width>946</width>
<height>545</height> <height>536</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="inputTabVLayout" stretch="0,0"> <layout class="QVBoxLayout" name="inputTabVLayout" stretch="0,0">
@ -1726,7 +1722,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>946</width> <width>946</width>
<height>545</height> <height>536</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="pathsTabLayout"> <layout class="QVBoxLayout" name="pathsTabLayout">
@ -1800,6 +1796,58 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item>
<widget class="QGroupBox" name="PortableUserFolderGroupBox">
<property name="title">
<string>Portable User Folder</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_9">
<item>
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="PortableUserButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Create Portable User Folder from Common User Folder</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</widget> </widget>
@ -1816,7 +1864,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>946</width> <width>946</width>
<height>545</height> <height>536</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="debugTabVLayout" stretch="0,0"> <layout class="QVBoxLayout" name="debugTabVLayout" stretch="0,0">
@ -2068,6 +2116,8 @@
</item> </item>
</layout> </layout>
</widget> </widget>
<resources/> <resources>
<include location="../shadps4.qrc"/>
</resources>
<connections/> <connections/>
</ui> </ui>