mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-05-14 08:12:16 +00:00
qt_gui: Some game install features and fixes (#2261)
* open update folder + delete save folder + bulk install checkbox * delete pkg on install checkbox + use game icon for finish window
This commit is contained in:
parent
0575853be1
commit
78a0a755c5
5 changed files with 101 additions and 10 deletions
|
@ -52,10 +52,12 @@ public:
|
||||||
// "Open Folder..." submenu
|
// "Open Folder..." submenu
|
||||||
QMenu* openFolderMenu = new QMenu(tr("Open Folder..."), widget);
|
QMenu* openFolderMenu = new QMenu(tr("Open Folder..."), widget);
|
||||||
QAction* openGameFolder = new QAction(tr("Open Game Folder"), widget);
|
QAction* openGameFolder = new QAction(tr("Open Game Folder"), widget);
|
||||||
|
QAction* openUpdateFolder = new QAction(tr("Open Update Folder"), widget);
|
||||||
QAction* openSaveDataFolder = new QAction(tr("Open Save Data Folder"), widget);
|
QAction* openSaveDataFolder = new QAction(tr("Open Save Data Folder"), widget);
|
||||||
QAction* openLogFolder = new QAction(tr("Open Log Folder"), widget);
|
QAction* openLogFolder = new QAction(tr("Open Log Folder"), widget);
|
||||||
|
|
||||||
openFolderMenu->addAction(openGameFolder);
|
openFolderMenu->addAction(openGameFolder);
|
||||||
|
openFolderMenu->addAction(openUpdateFolder);
|
||||||
openFolderMenu->addAction(openSaveDataFolder);
|
openFolderMenu->addAction(openSaveDataFolder);
|
||||||
openFolderMenu->addAction(openLogFolder);
|
openFolderMenu->addAction(openLogFolder);
|
||||||
|
|
||||||
|
@ -87,10 +89,12 @@ public:
|
||||||
QMenu* deleteMenu = new QMenu(tr("Delete..."), widget);
|
QMenu* deleteMenu = new QMenu(tr("Delete..."), widget);
|
||||||
QAction* deleteGame = new QAction(tr("Delete Game"), widget);
|
QAction* deleteGame = new QAction(tr("Delete Game"), widget);
|
||||||
QAction* deleteUpdate = new QAction(tr("Delete Update"), widget);
|
QAction* deleteUpdate = new QAction(tr("Delete Update"), widget);
|
||||||
|
QAction* deleteSaveData = new QAction(tr("Delete Save Data"), widget);
|
||||||
QAction* deleteDLC = new QAction(tr("Delete DLC"), widget);
|
QAction* deleteDLC = new QAction(tr("Delete DLC"), widget);
|
||||||
|
|
||||||
deleteMenu->addAction(deleteGame);
|
deleteMenu->addAction(deleteGame);
|
||||||
deleteMenu->addAction(deleteUpdate);
|
deleteMenu->addAction(deleteUpdate);
|
||||||
|
deleteMenu->addAction(deleteSaveData);
|
||||||
deleteMenu->addAction(deleteDLC);
|
deleteMenu->addAction(deleteDLC);
|
||||||
|
|
||||||
menu.addMenu(deleteMenu);
|
menu.addMenu(deleteMenu);
|
||||||
|
@ -122,6 +126,18 @@ public:
|
||||||
QDesktopServices::openUrl(QUrl::fromLocalFile(folderPath));
|
QDesktopServices::openUrl(QUrl::fromLocalFile(folderPath));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (selected == openUpdateFolder) {
|
||||||
|
QString open_update_path;
|
||||||
|
Common::FS::PathToQString(open_update_path, m_games[itemID].path);
|
||||||
|
open_update_path += "-UPDATE";
|
||||||
|
if (!std::filesystem::exists(Common::FS::PathFromQString(open_update_path))) {
|
||||||
|
QMessageBox::critical(nullptr, tr("Error"),
|
||||||
|
QString(tr("This game has no update folder to open!")));
|
||||||
|
} else {
|
||||||
|
QDesktopServices::openUrl(QUrl::fromLocalFile(open_update_path));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (selected == openSaveDataFolder) {
|
if (selected == openSaveDataFolder) {
|
||||||
QString userPath;
|
QString userPath;
|
||||||
Common::FS::PathToQString(userPath,
|
Common::FS::PathToQString(userPath,
|
||||||
|
@ -143,7 +159,7 @@ public:
|
||||||
PSF psf;
|
PSF psf;
|
||||||
std::filesystem::path game_folder_path = m_games[itemID].path;
|
std::filesystem::path game_folder_path = m_games[itemID].path;
|
||||||
std::filesystem::path game_update_path = game_folder_path;
|
std::filesystem::path game_update_path = game_folder_path;
|
||||||
game_update_path += "UPDATE";
|
game_update_path += "-UPDATE";
|
||||||
if (std::filesystem::exists(game_update_path)) {
|
if (std::filesystem::exists(game_update_path)) {
|
||||||
game_folder_path = game_update_path;
|
game_folder_path = game_update_path;
|
||||||
}
|
}
|
||||||
|
@ -238,6 +254,11 @@ public:
|
||||||
QString trophyPath, gameTrpPath;
|
QString trophyPath, gameTrpPath;
|
||||||
Common::FS::PathToQString(trophyPath, m_games[itemID].serial);
|
Common::FS::PathToQString(trophyPath, m_games[itemID].serial);
|
||||||
Common::FS::PathToQString(gameTrpPath, m_games[itemID].path);
|
Common::FS::PathToQString(gameTrpPath, m_games[itemID].path);
|
||||||
|
auto game_update_path = Common::FS::PathFromQString(gameTrpPath);
|
||||||
|
game_update_path += "-UPDATE";
|
||||||
|
if (std::filesystem::exists(game_update_path)) {
|
||||||
|
Common::FS::PathToQString(gameTrpPath, game_update_path);
|
||||||
|
}
|
||||||
TrophyViewer* trophyViewer = new TrophyViewer(trophyPath, gameTrpPath);
|
TrophyViewer* trophyViewer = new TrophyViewer(trophyPath, gameTrpPath);
|
||||||
trophyViewer->show();
|
trophyViewer->show();
|
||||||
connect(widget->parent(), &QWidget::destroyed, trophyViewer,
|
connect(widget->parent(), &QWidget::destroyed, trophyViewer,
|
||||||
|
@ -335,14 +356,18 @@ public:
|
||||||
clipboard->setText(combinedText);
|
clipboard->setText(combinedText);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (selected == deleteGame || selected == deleteUpdate || selected == deleteDLC) {
|
if (selected == deleteGame || selected == deleteUpdate || selected == deleteDLC ||
|
||||||
|
selected == deleteSaveData) {
|
||||||
bool error = false;
|
bool error = false;
|
||||||
QString folder_path, game_update_path, dlc_path;
|
QString folder_path, game_update_path, dlc_path, save_data_path;
|
||||||
Common::FS::PathToQString(folder_path, m_games[itemID].path);
|
Common::FS::PathToQString(folder_path, m_games[itemID].path);
|
||||||
game_update_path = folder_path + "-UPDATE";
|
game_update_path = folder_path + "-UPDATE";
|
||||||
Common::FS::PathToQString(
|
Common::FS::PathToQString(
|
||||||
dlc_path, Config::getAddonInstallDir() /
|
dlc_path, Config::getAddonInstallDir() /
|
||||||
Common::FS::PathFromQString(folder_path).parent_path().filename());
|
Common::FS::PathFromQString(folder_path).parent_path().filename());
|
||||||
|
Common::FS::PathToQString(save_data_path,
|
||||||
|
Common::FS::GetUserPath(Common::FS::PathType::UserDir) /
|
||||||
|
"savedata/1" / m_games[itemID].serial);
|
||||||
QString message_type = tr("Game");
|
QString message_type = tr("Game");
|
||||||
|
|
||||||
if (selected == deleteUpdate) {
|
if (selected == deleteUpdate) {
|
||||||
|
@ -363,6 +388,15 @@ public:
|
||||||
folder_path = dlc_path;
|
folder_path = dlc_path;
|
||||||
message_type = tr("DLC");
|
message_type = tr("DLC");
|
||||||
}
|
}
|
||||||
|
} else if (selected == deleteSaveData) {
|
||||||
|
if (!std::filesystem::exists(Common::FS::PathFromQString(save_data_path))) {
|
||||||
|
QMessageBox::critical(nullptr, tr("Error"),
|
||||||
|
QString(tr("This game has no save data to delete!")));
|
||||||
|
error = true;
|
||||||
|
} else {
|
||||||
|
folder_path = save_data_path;
|
||||||
|
message_type = tr("Save Data");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!error) {
|
if (!error) {
|
||||||
QString gameName = QString::fromStdString(m_games[itemID].name);
|
QString gameName = QString::fromStdString(m_games[itemID].name);
|
||||||
|
@ -374,7 +408,10 @@ public:
|
||||||
QMessageBox::Yes | QMessageBox::No);
|
QMessageBox::Yes | QMessageBox::No);
|
||||||
if (reply == QMessageBox::Yes) {
|
if (reply == QMessageBox::Yes) {
|
||||||
dir.removeRecursively();
|
dir.removeRecursively();
|
||||||
widget->removeRow(itemID);
|
if (selected == deleteGame) {
|
||||||
|
widget->removeRow(itemID);
|
||||||
|
m_games.removeAt(itemID);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
#include <QCheckBox>
|
||||||
#include <QDialogButtonBox>
|
#include <QDialogButtonBox>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
|
@ -15,10 +16,11 @@
|
||||||
#include "install_dir_select.h"
|
#include "install_dir_select.h"
|
||||||
|
|
||||||
InstallDirSelect::InstallDirSelect() : selected_dir() {
|
InstallDirSelect::InstallDirSelect() : selected_dir() {
|
||||||
selected_dir = Config::getGameInstallDirs().empty() ? "" : Config::getGameInstallDirs().front();
|
auto install_dirs = Config::getGameInstallDirs();
|
||||||
|
selected_dir = install_dirs.empty() ? "" : install_dirs.front();
|
||||||
|
|
||||||
if (!Config::getGameInstallDirs().empty() && Config::getGameInstallDirs().size() == 1) {
|
if (!install_dirs.empty() && install_dirs.size() == 1) {
|
||||||
reject();
|
accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto layout = new QVBoxLayout(this);
|
auto layout = new QVBoxLayout(this);
|
||||||
|
@ -53,6 +55,14 @@ QWidget* InstallDirSelect::SetupInstallDirList() {
|
||||||
|
|
||||||
vlayout->addWidget(m_path_list);
|
vlayout->addWidget(m_path_list);
|
||||||
|
|
||||||
|
auto checkbox = new QCheckBox(tr("Install All Queued to Selected Folder"));
|
||||||
|
connect(checkbox, &QCheckBox::toggled, this, &InstallDirSelect::setUseForAllQueued);
|
||||||
|
vlayout->addWidget(checkbox);
|
||||||
|
|
||||||
|
auto checkbox2 = new QCheckBox(tr("Delete PKG File on Install"));
|
||||||
|
connect(checkbox2, &QCheckBox::toggled, this, &InstallDirSelect::setDeleteFileOnInstall);
|
||||||
|
vlayout->addWidget(checkbox2);
|
||||||
|
|
||||||
group->setLayout(vlayout);
|
group->setLayout(vlayout);
|
||||||
return group;
|
return group;
|
||||||
}
|
}
|
||||||
|
@ -66,6 +76,14 @@ void InstallDirSelect::setSelectedDirectory(QListWidgetItem* item) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InstallDirSelect::setUseForAllQueued(bool enabled) {
|
||||||
|
use_for_all_queued = enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
void InstallDirSelect::setDeleteFileOnInstall(bool enabled) {
|
||||||
|
delete_file_on_install = enabled;
|
||||||
|
}
|
||||||
|
|
||||||
QWidget* InstallDirSelect::SetupDialogActions() {
|
QWidget* InstallDirSelect::SetupDialogActions() {
|
||||||
auto actions = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
auto actions = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||||
|
|
||||||
|
|
|
@ -22,9 +22,21 @@ public:
|
||||||
return selected_dir;
|
return selected_dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool useForAllQueued() {
|
||||||
|
return use_for_all_queued;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool deleteFileOnInstall() {
|
||||||
|
return delete_file_on_install;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QWidget* SetupInstallDirList();
|
QWidget* SetupInstallDirList();
|
||||||
QWidget* SetupDialogActions();
|
QWidget* SetupDialogActions();
|
||||||
void setSelectedDirectory(QListWidgetItem* item);
|
void setSelectedDirectory(QListWidgetItem* item);
|
||||||
|
void setDeleteFileOnInstall(bool enabled);
|
||||||
|
void setUseForAllQueued(bool enabled);
|
||||||
std::filesystem::path selected_dir;
|
std::filesystem::path selected_dir;
|
||||||
|
bool delete_file_on_install = false;
|
||||||
|
bool use_for_all_queued = false;
|
||||||
};
|
};
|
||||||
|
|
|
@ -725,9 +725,20 @@ void MainWindow::InstallDragDropPkg(std::filesystem::path file, int pkgNum, int
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto category = psf.GetString("CATEGORY");
|
auto category = psf.GetString("CATEGORY");
|
||||||
InstallDirSelect ids;
|
|
||||||
ids.exec();
|
if (!use_for_all_queued || pkgNum == 1) {
|
||||||
auto game_install_dir = ids.getSelectedDirectory();
|
InstallDirSelect ids;
|
||||||
|
const auto selected = ids.exec();
|
||||||
|
if (selected == QDialog::Rejected) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
last_install_dir = ids.getSelectedDirectory();
|
||||||
|
delete_file_on_install = ids.deleteFileOnInstall();
|
||||||
|
use_for_all_queued = ids.useForAllQueued();
|
||||||
|
}
|
||||||
|
std::filesystem::path game_install_dir = last_install_dir;
|
||||||
|
|
||||||
auto game_folder_path = game_install_dir / pkg.GetTitleID();
|
auto game_folder_path = game_install_dir / pkg.GetTitleID();
|
||||||
QString pkgType = QString::fromStdString(pkg.GetPkgFlags());
|
QString pkgType = QString::fromStdString(pkg.GetPkgFlags());
|
||||||
bool use_game_update = pkgType.contains("PATCH") && Config::getSeparateUpdateEnabled();
|
bool use_game_update = pkgType.contains("PATCH") && Config::getSeparateUpdateEnabled();
|
||||||
|
@ -879,8 +890,14 @@ void MainWindow::InstallDragDropPkg(std::filesystem::path file, int pkgNum, int
|
||||||
if (pkgNum == nPkg) {
|
if (pkgNum == nPkg) {
|
||||||
QString path;
|
QString path;
|
||||||
Common::FS::PathToQString(path, game_install_dir);
|
Common::FS::PathToQString(path, game_install_dir);
|
||||||
|
QIcon windowIcon(
|
||||||
|
Common::FS::PathToUTF8String(game_folder_path / "sce_sys/icon0.png")
|
||||||
|
.c_str());
|
||||||
QMessageBox extractMsgBox(this);
|
QMessageBox extractMsgBox(this);
|
||||||
extractMsgBox.setWindowTitle(tr("Extraction Finished"));
|
extractMsgBox.setWindowTitle(tr("Extraction Finished"));
|
||||||
|
if (!windowIcon.isNull()) {
|
||||||
|
extractMsgBox.setWindowIcon(windowIcon);
|
||||||
|
}
|
||||||
extractMsgBox.setText(
|
extractMsgBox.setText(
|
||||||
QString(tr("Game successfully installed at %1")).arg(path));
|
QString(tr("Game successfully installed at %1")).arg(path));
|
||||||
extractMsgBox.addButton(QMessageBox::Ok);
|
extractMsgBox.addButton(QMessageBox::Ok);
|
||||||
|
@ -894,6 +911,9 @@ void MainWindow::InstallDragDropPkg(std::filesystem::path file, int pkgNum, int
|
||||||
});
|
});
|
||||||
extractMsgBox.exec();
|
extractMsgBox.exec();
|
||||||
}
|
}
|
||||||
|
if (delete_file_on_install) {
|
||||||
|
std::filesystem::remove(file);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
connect(&dialog, &QProgressDialog::canceled, [&]() { futureWatcher.cancel(); });
|
connect(&dialog, &QProgressDialog::canceled, [&]() { futureWatcher.cancel(); });
|
||||||
connect(&futureWatcher, &QFutureWatcher<void>::progressValueChanged, &dialog,
|
connect(&futureWatcher, &QFutureWatcher<void>::progressValueChanged, &dialog,
|
||||||
|
|
|
@ -123,4 +123,8 @@ protected:
|
||||||
}
|
}
|
||||||
|
|
||||||
void resizeEvent(QResizeEvent* event) override;
|
void resizeEvent(QResizeEvent* event) override;
|
||||||
|
|
||||||
|
std::filesystem::path last_install_dir = "";
|
||||||
|
bool delete_file_on_install = false;
|
||||||
|
bool use_for_all_queued = false;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue