mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-07-22 18:15:14 +00:00
removing "Install" from game directory code
This commit is contained in:
parent
7f727340aa
commit
fa2c82e9a3
@ -1048,8 +1048,8 @@ set(QT_GUI src/qt_gui/about_dialog.cpp
|
|||||||
src/qt_gui/game_list_frame.h
|
src/qt_gui/game_list_frame.h
|
||||||
src/qt_gui/game_grid_frame.cpp
|
src/qt_gui/game_grid_frame.cpp
|
||||||
src/qt_gui/game_grid_frame.h
|
src/qt_gui/game_grid_frame.h
|
||||||
src/qt_gui/game_install_dialog.cpp
|
src/qt_gui/game_directory_dialog.cpp
|
||||||
src/qt_gui/game_install_dialog.h
|
src/qt_gui/game_directory_dialog.h
|
||||||
src/qt_gui/trophy_viewer.cpp
|
src/qt_gui/trophy_viewer.cpp
|
||||||
src/qt_gui/trophy_viewer.h
|
src/qt_gui/trophy_viewer.h
|
||||||
src/qt_gui/elf_viewer.cpp
|
src/qt_gui/elf_viewer.cpp
|
||||||
|
125
src/qt_gui/game_directory_dialog.cpp
Normal file
125
src/qt_gui/game_directory_dialog.cpp
Normal file
@ -0,0 +1,125 @@
|
|||||||
|
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
#include <QDialogButtonBox>
|
||||||
|
#include <QDir>
|
||||||
|
#include <QFileDialog>
|
||||||
|
#include <QGroupBox>
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QLineEdit>
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include <QPushButton>
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
|
#include "game_install_dialog.h"
|
||||||
|
|
||||||
|
GameInstallDialog::GameInstallDialog() : m_gamesDirectory(nullptr) {
|
||||||
|
auto layout = new QVBoxLayout(this);
|
||||||
|
|
||||||
|
layout->addWidget(SetupGamesDirectory());
|
||||||
|
layout->addWidget(SetupAddonsDirectory());
|
||||||
|
layout->addStretch();
|
||||||
|
layout->addWidget(SetupDialogActions());
|
||||||
|
|
||||||
|
setWindowTitle(tr("shadPS4 - Choose directory"));
|
||||||
|
setWindowIcon(QIcon(":images/shadps4.ico"));
|
||||||
|
}
|
||||||
|
|
||||||
|
GameInstallDialog::~GameInstallDialog() {}
|
||||||
|
|
||||||
|
void GameInstallDialog::BrowseGamesDirectory() {
|
||||||
|
auto path = QFileDialog::getExistingDirectory(this, tr("Games Directory"));
|
||||||
|
|
||||||
|
if (!path.isEmpty()) {
|
||||||
|
m_gamesDirectory->setText(QDir::toNativeSeparators(path));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void GameInstallDialog::BrowseAddonsDirectory() {
|
||||||
|
auto path = QFileDialog::getExistingDirectory(this, tr("DLC Directory"));
|
||||||
|
|
||||||
|
if (!path.isEmpty()) {
|
||||||
|
m_addonsDirectory->setText(QDir::toNativeSeparators(path));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QWidget* GameInstallDialog::SetupGamesDirectory() {
|
||||||
|
auto group = new QGroupBox(tr("Games Directory"));
|
||||||
|
auto layout = new QHBoxLayout(group);
|
||||||
|
|
||||||
|
layout->addWidget(m_gamesDirectory);
|
||||||
|
|
||||||
|
// Browse button.
|
||||||
|
auto browse = new QPushButton(tr("Browse"));
|
||||||
|
|
||||||
|
connect(browse, &QPushButton::clicked, this, &GameInstallDialog::BrowseGamesDirectory);
|
||||||
|
|
||||||
|
layout->addWidget(browse);
|
||||||
|
|
||||||
|
return group;
|
||||||
|
}
|
||||||
|
|
||||||
|
QWidget* GameInstallDialog::SetupAddonsDirectory() {
|
||||||
|
auto group = new QGroupBox(tr("DLC Directory"));
|
||||||
|
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);
|
||||||
|
|
||||||
|
return group;
|
||||||
|
}
|
||||||
|
|
||||||
|
QWidget* GameInstallDialog::SetupDialogActions() {
|
||||||
|
auto actions = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||||
|
|
||||||
|
connect(actions, &QDialogButtonBox::accepted, this, &GameInstallDialog::Save);
|
||||||
|
connect(actions, &QDialogButtonBox::rejected, this, &GameInstallDialog::reject);
|
||||||
|
|
||||||
|
return actions;
|
||||||
|
}
|
||||||
|
|
||||||
|
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)) {
|
||||||
|
QMessageBox::critical(this, tr("Error"),
|
||||||
|
"The value for location for games is not valid.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (addonsDirectory.isEmpty() || !QDir::isAbsolutePath(addonsDirectory)) {
|
||||||
|
QMessageBox::critical(this, tr("Error"),
|
||||||
|
"The value for location for DLC is not valid.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
QDir addonsDir(addonsDirectory);
|
||||||
|
if (!addonsDir.exists()) {
|
||||||
|
if (!addonsDir.mkpath(".")) {
|
||||||
|
QMessageBox::critical(this, tr("Error"),
|
||||||
|
"The DLC location could not be created.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Config::addGameInstallDir(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();
|
||||||
|
}
|
32
src/qt_gui/game_directory_dialog.h
Normal file
32
src/qt_gui/game_directory_dialog.h
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QDialog>
|
||||||
|
|
||||||
|
#include "common/config.h"
|
||||||
|
#include "common/path_util.h"
|
||||||
|
|
||||||
|
class QLineEdit;
|
||||||
|
|
||||||
|
class GameInstallDialog final : public QDialog {
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
GameInstallDialog();
|
||||||
|
~GameInstallDialog();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void BrowseGamesDirectory();
|
||||||
|
void BrowseAddonsDirectory();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QWidget* SetupGamesDirectory();
|
||||||
|
QWidget* SetupAddonsDirectory();
|
||||||
|
QWidget* SetupDialogActions();
|
||||||
|
void Save();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QLineEdit* m_gamesDirectory;
|
||||||
|
QLineEdit* m_addonsDirectory;
|
||||||
|
};
|
@ -12,9 +12,9 @@
|
|||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
#include "game_install_dialog.h"
|
#include "game_directory_dialog.h"
|
||||||
|
|
||||||
GameInstallDialog::GameInstallDialog() : m_gamesDirectory(nullptr) {
|
GameInstallDialog::GameDirectoryDialog() : m_gamesDirectory(nullptr) {
|
||||||
auto layout = new QVBoxLayout(this);
|
auto layout = new QVBoxLayout(this);
|
||||||
|
|
||||||
layout->addWidget(SetupGamesDirectory());
|
layout->addWidget(SetupGamesDirectory());
|
||||||
@ -26,10 +26,10 @@ GameInstallDialog::GameInstallDialog() : m_gamesDirectory(nullptr) {
|
|||||||
setWindowIcon(QIcon(":images/shadps4.ico"));
|
setWindowIcon(QIcon(":images/shadps4.ico"));
|
||||||
}
|
}
|
||||||
|
|
||||||
GameInstallDialog::~GameInstallDialog() {}
|
GameInstallDialog::~GameDirectoryDialog() {}
|
||||||
|
|
||||||
void GameInstallDialog::BrowseGamesDirectory() {
|
void GameInstallDialog::BrowseGamesDirectory() {
|
||||||
auto path = QFileDialog::getExistingDirectory(this, tr("Directory to install games"));
|
auto path = QFileDialog::getExistingDirectory(this, tr("Games Directory"));
|
||||||
|
|
||||||
if (!path.isEmpty()) {
|
if (!path.isEmpty()) {
|
||||||
m_gamesDirectory->setText(QDir::toNativeSeparators(path));
|
m_gamesDirectory->setText(QDir::toNativeSeparators(path));
|
||||||
@ -37,7 +37,7 @@ void GameInstallDialog::BrowseGamesDirectory() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void GameInstallDialog::BrowseAddonsDirectory() {
|
void GameInstallDialog::BrowseAddonsDirectory() {
|
||||||
auto path = QFileDialog::getExistingDirectory(this, tr("Directory to install DLC"));
|
auto path = QFileDialog::getExistingDirectory(this, tr("DLC Directory"));
|
||||||
|
|
||||||
if (!path.isEmpty()) {
|
if (!path.isEmpty()) {
|
||||||
m_addonsDirectory->setText(QDir::toNativeSeparators(path));
|
m_addonsDirectory->setText(QDir::toNativeSeparators(path));
|
||||||
@ -45,18 +45,9 @@ void GameInstallDialog::BrowseAddonsDirectory() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
QWidget* GameInstallDialog::SetupGamesDirectory() {
|
QWidget* GameInstallDialog::SetupGamesDirectory() {
|
||||||
auto group = new QGroupBox(tr("Directory to install games"));
|
auto group = new QGroupBox(tr("Games Directory"));
|
||||||
auto layout = new QHBoxLayout(group);
|
auto layout = new QHBoxLayout(group);
|
||||||
|
|
||||||
// Input.
|
|
||||||
m_gamesDirectory = new QLineEdit();
|
|
||||||
QString install_dir;
|
|
||||||
std::filesystem::path install_path =
|
|
||||||
Config::getGameInstallDirs().empty() ? "" : Config::getGameInstallDirs().front();
|
|
||||||
Common::FS::PathToQString(install_dir, install_path);
|
|
||||||
m_gamesDirectory->setText(install_dir);
|
|
||||||
m_gamesDirectory->setMinimumWidth(400);
|
|
||||||
|
|
||||||
layout->addWidget(m_gamesDirectory);
|
layout->addWidget(m_gamesDirectory);
|
||||||
|
|
||||||
// Browse button.
|
// Browse button.
|
||||||
@ -70,7 +61,7 @@ QWidget* GameInstallDialog::SetupGamesDirectory() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
QWidget* GameInstallDialog::SetupAddonsDirectory() {
|
QWidget* GameInstallDialog::SetupAddonsDirectory() {
|
||||||
auto group = new QGroupBox(tr("Directory to install DLC"));
|
auto group = new QGroupBox(tr("DLC Directory"));
|
||||||
auto layout = new QHBoxLayout(group);
|
auto layout = new QHBoxLayout(group);
|
||||||
|
|
||||||
// Input.
|
// Input.
|
||||||
@ -109,20 +100,20 @@ void GameInstallDialog::Save() {
|
|||||||
if (gamesDirectory.isEmpty() || !QDir(gamesDirectory).exists() ||
|
if (gamesDirectory.isEmpty() || !QDir(gamesDirectory).exists() ||
|
||||||
!QDir::isAbsolutePath(gamesDirectory)) {
|
!QDir::isAbsolutePath(gamesDirectory)) {
|
||||||
QMessageBox::critical(this, tr("Error"),
|
QMessageBox::critical(this, tr("Error"),
|
||||||
"The value for location to install games is not valid.");
|
"The value for location for games is not valid.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (addonsDirectory.isEmpty() || !QDir::isAbsolutePath(addonsDirectory)) {
|
if (addonsDirectory.isEmpty() || !QDir::isAbsolutePath(addonsDirectory)) {
|
||||||
QMessageBox::critical(this, tr("Error"),
|
QMessageBox::critical(this, tr("Error"),
|
||||||
"The value for location to install DLC is not valid.");
|
"The value for location for DLC is not valid.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QDir addonsDir(addonsDirectory);
|
QDir addonsDir(addonsDirectory);
|
||||||
if (!addonsDir.exists()) {
|
if (!addonsDir.exists()) {
|
||||||
if (!addonsDir.mkpath(".")) {
|
if (!addonsDir.mkpath(".")) {
|
||||||
QMessageBox::critical(this, tr("Error"),
|
QMessageBox::critical(this, tr("Error"),
|
||||||
"The DLC install location could not be created.");
|
"The DLC location could not be created.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,8 +13,8 @@ class QLineEdit;
|
|||||||
class GameInstallDialog final : public QDialog {
|
class GameInstallDialog final : public QDialog {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
GameInstallDialog();
|
GameDirectoryDialog();
|
||||||
~GameInstallDialog();
|
~GameDirectoryDialog();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void BrowseGamesDirectory();
|
void BrowseGamesDirectory();
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
#include "common/memory_patcher.h"
|
#include "common/memory_patcher.h"
|
||||||
#include "core/file_sys/fs.h"
|
#include "core/file_sys/fs.h"
|
||||||
#include "emulator.h"
|
#include "emulator.h"
|
||||||
#include "game_install_dialog.h"
|
#include "game_directory_dialog.h"
|
||||||
#include "main_window.h"
|
#include "main_window.h"
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#include "common/scm_rev.h"
|
#include "common/scm_rev.h"
|
||||||
#include "common/string_util.h"
|
#include "common/string_util.h"
|
||||||
#include "control_settings.h"
|
#include "control_settings.h"
|
||||||
#include "game_install_dialog.h"
|
#include "game_directory_dialog.h"
|
||||||
#include "kbm_gui.h"
|
#include "kbm_gui.h"
|
||||||
#include "main_window.h"
|
#include "main_window.h"
|
||||||
#include "settings_dialog.h"
|
#include "settings_dialog.h"
|
||||||
|
Loading…
Reference in New Issue
Block a user