From 04e0ae3a2329a6dcfab07978ca3468158d86f4db Mon Sep 17 00:00:00 2001 From: ElBread3 <92335081+ElBread3@users.noreply.github.com> Date: Tue, 28 Jan 2025 12:02:40 -0600 Subject: [PATCH] delete pkg on install checkbox + use game icon for finish window --- src/qt_gui/install_dir_select.cpp | 8 ++++++++ src/qt_gui/install_dir_select.h | 6 ++++++ src/qt_gui/main_window.cpp | 14 ++++++++++++-- src/qt_gui/main_window.h | 1 + 4 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/qt_gui/install_dir_select.cpp b/src/qt_gui/install_dir_select.cpp index b7921b69b..e90a10ee6 100644 --- a/src/qt_gui/install_dir_select.cpp +++ b/src/qt_gui/install_dir_select.cpp @@ -59,6 +59,10 @@ QWidget* InstallDirSelect::SetupInstallDirList() { 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); return group; } @@ -76,6 +80,10 @@ void InstallDirSelect::setUseForAllQueued(bool enabled) { use_for_all_queued = enabled; } +void InstallDirSelect::setDeleteFileOnInstall(bool enabled) { + delete_file_on_install = enabled; +} + QWidget* InstallDirSelect::SetupDialogActions() { auto actions = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); diff --git a/src/qt_gui/install_dir_select.h b/src/qt_gui/install_dir_select.h index f4e6e2104..e11cbf381 100644 --- a/src/qt_gui/install_dir_select.h +++ b/src/qt_gui/install_dir_select.h @@ -26,11 +26,17 @@ public: return use_for_all_queued; } + bool deleteFileOnInstall() { + return delete_file_on_install; + } + private: QWidget* SetupInstallDirList(); QWidget* SetupDialogActions(); void setSelectedDirectory(QListWidgetItem* item); + void setDeleteFileOnInstall(bool enabled); void setUseForAllQueued(bool enabled); std::filesystem::path selected_dir; + bool delete_file_on_install = false; bool use_for_all_queued = false; }; diff --git a/src/qt_gui/main_window.cpp b/src/qt_gui/main_window.cpp index f67421fc0..3678b3a82 100644 --- a/src/qt_gui/main_window.cpp +++ b/src/qt_gui/main_window.cpp @@ -726,8 +726,7 @@ void MainWindow::InstallDragDropPkg(std::filesystem::path file, int pkgNum, int } auto category = psf.GetString("CATEGORY"); - std::filesystem::path game_install_dir = last_install_dir; - if (!use_for_all_queued) { + if (!use_for_all_queued || pkgNum == 1) { InstallDirSelect ids; const auto selected = ids.exec(); if (selected == QDialog::Rejected) { @@ -735,8 +734,10 @@ void MainWindow::InstallDragDropPkg(std::filesystem::path file, int pkgNum, int } 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(); QString pkgType = QString::fromStdString(pkg.GetPkgFlags()); @@ -889,8 +890,14 @@ void MainWindow::InstallDragDropPkg(std::filesystem::path file, int pkgNum, int if (pkgNum == nPkg) { QString path; Common::FS::PathToQString(path, game_install_dir); + QIcon windowIcon( + Common::FS::PathToUTF8String(game_folder_path / "sce_sys/icon0.png") + .c_str()); QMessageBox extractMsgBox(this); extractMsgBox.setWindowTitle(tr("Extraction Finished")); + if (!windowIcon.isNull()) { + extractMsgBox.setWindowIcon(windowIcon); + } extractMsgBox.setText( QString(tr("Game successfully installed at %1")).arg(path)); extractMsgBox.addButton(QMessageBox::Ok); @@ -904,6 +911,9 @@ void MainWindow::InstallDragDropPkg(std::filesystem::path file, int pkgNum, int }); extractMsgBox.exec(); } + if (delete_file_on_install) { + std::filesystem::remove(file); + } }); connect(&dialog, &QProgressDialog::canceled, [&]() { futureWatcher.cancel(); }); connect(&futureWatcher, &QFutureWatcher::progressValueChanged, &dialog, diff --git a/src/qt_gui/main_window.h b/src/qt_gui/main_window.h index 0942bb6e6..5ac56e44c 100644 --- a/src/qt_gui/main_window.h +++ b/src/qt_gui/main_window.h @@ -125,5 +125,6 @@ protected: void resizeEvent(QResizeEvent* event) override; std::filesystem::path last_install_dir = ""; + bool delete_file_on_install = false; bool use_for_all_queued = false; };