mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-06-02 00:33:16 +00:00
config: Add option to change DLC install path. (#1176)
This commit is contained in:
parent
0be0f18764
commit
7084fc4c41
8 changed files with 69 additions and 10 deletions
|
@ -18,6 +18,7 @@ GameInstallDialog::GameInstallDialog() : m_gamesDirectory(nullptr) {
|
|||
auto layout = new QVBoxLayout(this);
|
||||
|
||||
layout->addWidget(SetupGamesDirectory());
|
||||
layout->addWidget(SetupAddonsDirectory());
|
||||
layout->addStretch();
|
||||
layout->addWidget(SetupDialogActions());
|
||||
|
||||
|
@ -27,7 +28,7 @@ GameInstallDialog::GameInstallDialog() : m_gamesDirectory(nullptr) {
|
|||
|
||||
GameInstallDialog::~GameInstallDialog() {}
|
||||
|
||||
void GameInstallDialog::Browse() {
|
||||
void GameInstallDialog::BrowseGamesDirectory() {
|
||||
auto path = QFileDialog::getExistingDirectory(this, tr("Directory to install games"));
|
||||
|
||||
if (!path.isEmpty()) {
|
||||
|
@ -35,6 +36,14 @@ void GameInstallDialog::Browse() {
|
|||
}
|
||||
}
|
||||
|
||||
void GameInstallDialog::BrowseAddonsDirectory() {
|
||||
auto path = QFileDialog::getExistingDirectory(this, tr("Directory to install DLC"));
|
||||
|
||||
if (!path.isEmpty()) {
|
||||
m_addonsDirectory->setText(QDir::toNativeSeparators(path));
|
||||
}
|
||||
}
|
||||
|
||||
QWidget* GameInstallDialog::SetupGamesDirectory() {
|
||||
auto group = new QGroupBox(tr("Directory to install games"));
|
||||
auto layout = new QHBoxLayout(group);
|
||||
|
@ -51,7 +60,30 @@ QWidget* GameInstallDialog::SetupGamesDirectory() {
|
|||
// Browse button.
|
||||
auto browse = new QPushButton(tr("Browse"));
|
||||
|
||||
connect(browse, &QPushButton::clicked, this, &GameInstallDialog::Browse);
|
||||
connect(browse, &QPushButton::clicked, this, &GameInstallDialog::BrowseGamesDirectory);
|
||||
|
||||
layout->addWidget(browse);
|
||||
|
||||
return group;
|
||||
}
|
||||
|
||||
QWidget* GameInstallDialog::SetupAddonsDirectory() {
|
||||
auto group = new QGroupBox(tr("Directory to install DLC"));
|
||||
auto layout = new QHBoxLayout(group);
|
||||
|
||||
// Input.
|
||||
m_addonsDirectory = new QLineEdit();
|
||||
QString install_dir;
|
||||
Common::FS::PathToQString(install_dir, Config::getAddonInstallDir());
|
||||
m_addonsDirectory->setText(install_dir);
|
||||
m_addonsDirectory->setMinimumWidth(400);
|
||||
|
||||
layout->addWidget(m_addonsDirectory);
|
||||
|
||||
// Browse button.
|
||||
auto browse = new QPushButton(tr("Browse"));
|
||||
|
||||
connect(browse, &QPushButton::clicked, this, &GameInstallDialog::BrowseAddonsDirectory);
|
||||
|
||||
layout->addWidget(browse);
|
||||
|
||||
|
@ -70,6 +102,7 @@ QWidget* GameInstallDialog::SetupDialogActions() {
|
|||
void GameInstallDialog::Save() {
|
||||
// Check games directory.
|
||||
auto gamesDirectory = m_gamesDirectory->text();
|
||||
auto addonsDirectory = m_addonsDirectory->text();
|
||||
|
||||
if (gamesDirectory.isEmpty() || !QDir(gamesDirectory).exists() ||
|
||||
!QDir::isAbsolutePath(gamesDirectory)) {
|
||||
|
@ -78,7 +111,15 @@ void GameInstallDialog::Save() {
|
|||
return;
|
||||
}
|
||||
|
||||
if (addonsDirectory.isEmpty() || !QDir(addonsDirectory).exists() ||
|
||||
!QDir::isAbsolutePath(addonsDirectory)) {
|
||||
QMessageBox::critical(this, tr("Error"),
|
||||
"The value for location to install DLC is not valid.");
|
||||
return;
|
||||
}
|
||||
|
||||
Config::setGameInstallDir(Common::FS::PathFromQString(gamesDirectory));
|
||||
Config::setAddonInstallDir(Common::FS::PathFromQString(addonsDirectory));
|
||||
const auto config_dir = Common::FS::GetUserPath(Common::FS::PathType::UserDir);
|
||||
Config::save(config_dir / "config.toml");
|
||||
accept();
|
||||
|
|
|
@ -16,13 +16,16 @@ public:
|
|||
~GameInstallDialog();
|
||||
|
||||
private slots:
|
||||
void Browse();
|
||||
void BrowseGamesDirectory();
|
||||
void BrowseAddonsDirectory();
|
||||
|
||||
private:
|
||||
QWidget* SetupGamesDirectory();
|
||||
QWidget* SetupAddonsDirectory();
|
||||
QWidget* SetupDialogActions();
|
||||
void Save();
|
||||
|
||||
private:
|
||||
QLineEdit* m_gamesDirectory;
|
||||
QLineEdit* m_addonsDirectory;
|
||||
};
|
|
@ -687,8 +687,8 @@ void MainWindow::InstallDragDropPkg(std::filesystem::path file, int pkgNum, int
|
|||
}
|
||||
std::string entitlement_label = Common::SplitString(content_id, '-')[2];
|
||||
|
||||
auto addon_extract_path = Common::FS::GetUserPath(Common::FS::PathType::AddonsDir) /
|
||||
pkg.GetTitleID() / entitlement_label;
|
||||
auto addon_extract_path =
|
||||
Config::getAddonInstallDir() / pkg.GetTitleID() / entitlement_label;
|
||||
QString addonDirPath;
|
||||
Common::FS::PathToQString(addonDirPath, addon_extract_path);
|
||||
QDir addon_dir(addonDirPath);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue