mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-05-24 12:25:00 +00:00
Add global/common user folder for Windows (#2589)
* Add global windows user folder * Add button for creating portable folder * Add notice about restarting after creating the portable folder --------- Co-authored-by: rainmakerv2 <30595646+jpau02@users.noreply.github.com>
This commit is contained in:
parent
c2adaf41c0
commit
a4b35f275c
3 changed files with 92 additions and 17 deletions
|
@ -17,6 +17,8 @@
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
// This is the maximum number of UTF-16 code units permissible in Windows file paths
|
// This is the maximum number of UTF-16 code units permissible in Windows file paths
|
||||||
#define MAX_PATH 260
|
#define MAX_PATH 260
|
||||||
|
#include <Shlobj.h>
|
||||||
|
#include <windows.h>
|
||||||
#else
|
#else
|
||||||
// This is the maximum number of UTF-8 code units permissible in all other OSes' file paths
|
// This is the maximum number of UTF-8 code units permissible in all other OSes' file paths
|
||||||
#define MAX_PATH 1024
|
#define MAX_PATH 1024
|
||||||
|
@ -106,6 +108,10 @@ static auto UserPaths = [] {
|
||||||
} else {
|
} else {
|
||||||
user_dir = std::filesystem::path(getenv("HOME")) / ".local" / "share" / "shadPS4";
|
user_dir = std::filesystem::path(getenv("HOME")) / ".local" / "share" / "shadPS4";
|
||||||
}
|
}
|
||||||
|
#elif _WIN32
|
||||||
|
TCHAR appdata[MAX_PATH] = {0};
|
||||||
|
SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, 0, appdata);
|
||||||
|
user_dir = std::filesystem::path(appdata) / "shadPS4";
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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. Restart the app after creating the portable user folder to begin using it.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save Data
|
// Save Data
|
||||||
|
|
|
@ -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>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue