Skip to content

Commit bba1cf4

Browse files
committed
Qt: ask user for install options before starting the installation
1 parent 92f5621 commit bba1cf4

File tree

4 files changed

+133
-172
lines changed

4 files changed

+133
-172
lines changed

rpcs3/rpcs3qt/main_window.cpp

Lines changed: 61 additions & 141 deletions
Original file line numberDiff line numberDiff line change
@@ -801,7 +801,7 @@ bool main_window::InstallPackages(QStringList file_paths, bool from_boot)
801801

802802
if (file_paths.count() == 1)
803803
{
804-
const QString file_path = file_paths.front();
804+
const QString& file_path = file_paths.front();
805805
const QFileInfo file_info(file_path);
806806

807807
if (file_info.isDir())
@@ -819,92 +819,6 @@ bool main_window::InstallPackages(QStringList file_paths, bool from_boot)
819819

820820
return InstallPackages(dir_file_paths, from_boot);
821821
}
822-
823-
if (file_info.suffix().compare("pkg", Qt::CaseInsensitive) == 0)
824-
{
825-
compat::package_info info = game_compatibility::GetPkgInfo(file_path, m_game_list_frame ? m_game_list_frame->GetGameCompatibility() : nullptr);
826-
827-
if (!info.is_valid)
828-
{
829-
QMessageBox::warning(this, tr("Invalid package!"), tr("The selected package is invalid!\n\nPath:\n%0").arg(file_path));
830-
return false;
831-
}
832-
833-
if (info.type != compat::package_type::other)
834-
{
835-
if (info.type == compat::package_type::dlc)
836-
{
837-
info.local_cat = tr("\nDLC", "Block for package type (DLC)");
838-
}
839-
else
840-
{
841-
info.local_cat = tr("\nUpdate", "Block for package type (Update)");
842-
}
843-
}
844-
else if (!info.local_cat.isEmpty())
845-
{
846-
info.local_cat = tr("\n%0", "Block for package type").arg(info.local_cat);
847-
}
848-
849-
if (!info.title_id.isEmpty())
850-
{
851-
info.title_id = tr("\n%0", "Block for Title ID").arg(info.title_id);
852-
}
853-
854-
if (!info.version.isEmpty())
855-
{
856-
info.version = tr("\nVersion %0", "Block for Version").arg(info.version);
857-
}
858-
859-
if (!info.changelog.isEmpty())
860-
{
861-
info.changelog = tr("Changelog:\n%0", "Block for Changelog").arg(info.changelog);
862-
}
863-
864-
u64 free_space = 0;
865-
866-
// Retrieve disk space info on data path's drive
867-
if (fs::device_stat stat{}; fs::statfs(rpcs3::utils::get_hdd0_dir(), stat))
868-
{
869-
free_space = stat.avail_free;
870-
}
871-
872-
const QString installation_info =
873-
tr("Installation path: %0\nAvailable disk space: %1%2\nRequired disk space: %3")
874-
.arg(QString::fromStdString(rpcs3::utils::get_hdd0_game_dir()))
875-
.arg(gui::utils::format_byte_size(free_space))
876-
.arg(info.data_size <= free_space ? QString() : tr(" - <b>NOT ENOUGH SPACE</b>"))
877-
.arg(gui::utils::format_byte_size(info.data_size));
878-
879-
const QString info_string = QStringLiteral("%0\n\n%1%2%3%4").arg(file_info.fileName()).arg(info.title).arg(info.local_cat).arg(info.title_id).arg(info.version);
880-
QString message = tr("Do you want to install this package?\n\n%0\n\n%1").arg(info_string).arg(installation_info);
881-
882-
QMessageBox mb(QMessageBox::Icon::Question, tr("PKG Decrypter / Installer"), gui::utils::make_paragraph(message), QMessageBox::Yes | QMessageBox::No, this);
883-
mb.setDefaultButton(QMessageBox::No);
884-
mb.setTextFormat(Qt::RichText); // Support HTML tags
885-
mb.button(QMessageBox::Yes)->setEnabled(info.data_size <= free_space);
886-
887-
if (!info.changelog.isEmpty())
888-
{
889-
mb.setInformativeText(tr("To see the changelog, please click \"Show Details\"."));
890-
mb.setDetailedText(info.changelog);
891-
892-
// Smartass hack to make the unresizeable message box wide enough for the changelog
893-
const int log_width = QLabel(info.changelog).sizeHint().width();
894-
while (QLabel(message).sizeHint().width() < log_width)
895-
{
896-
message += " ";
897-
}
898-
899-
mb.setText(message);
900-
}
901-
902-
if (mb.exec() != QMessageBox::Yes)
903-
{
904-
gui_log.notice("PKG: Cancelled installation from drop.\n%s\n%s", info_string, info.changelog);
905-
return true;
906-
}
907-
}
908822
}
909823

910824
// Install rap files if available
@@ -983,28 +897,22 @@ bool main_window::HandlePackageInstallation(QStringList file_paths, bool from_bo
983897
}
984898

985899
std::vector<compat::package_info> packages;
900+
bool precompile_caches = false;
901+
bool create_desktop_shortcuts = false;
902+
bool create_app_shortcut = false;
986903

987904
game_compatibility* compat = m_game_list_frame ? m_game_list_frame->GetGameCompatibility() : nullptr;
988905

989-
if (file_paths.size() > 1)
906+
// Let the user choose the packages to install and select the order in which they shall be installed.
907+
pkg_install_dialog dlg(file_paths, compat, this);
908+
connect(&dlg, &QDialog::accepted, this, [&]()
990909
{
991-
// Let the user choose the packages to install and select the order in which they shall be installed.
992-
pkg_install_dialog dlg(file_paths, compat, this);
993-
connect(&dlg, &QDialog::accepted, this, [&packages, &dlg]()
994-
{
995-
packages = dlg.GetPathsToInstall();
996-
});
997-
dlg.exec();
998-
}
999-
else
1000-
{
1001-
packages.push_back(game_compatibility::GetPkgInfo(file_paths.front(), compat));
1002-
}
1003-
1004-
if (packages.empty())
1005-
{
1006-
return true;
1007-
}
910+
packages = dlg.get_paths_to_install();
911+
precompile_caches = dlg.precompile_caches();
912+
create_desktop_shortcuts = dlg.create_desktop_shortcuts();
913+
create_app_shortcut = dlg.create_app_shortcut();
914+
});
915+
dlg.exec();
1008916

1009917
if (!from_boot)
1010918
{
@@ -1178,7 +1086,7 @@ bool main_window::HandlePackageInstallation(QStringList file_paths, bool from_bo
11781086

11791087
if (!bootable_paths_installed.empty())
11801088
{
1181-
m_game_list_frame->AddRefreshedSlot([this, paths = std::move(bootable_paths_installed)](std::set<std::string>& claimed_paths) mutable
1089+
m_game_list_frame->AddRefreshedSlot([this, create_desktop_shortcuts, precompile_caches, create_app_shortcut, paths = std::move(bootable_paths_installed)](std::set<std::string>& claimed_paths) mutable
11821090
{
11831091
// Try to claim operations on ID
11841092
for (auto it = paths.begin(); it != paths.end();)
@@ -1196,7 +1104,12 @@ bool main_window::HandlePackageInstallation(QStringList file_paths, bool from_bo
11961104
}
11971105
}
11981106

1199-
ShowOptionalGamePreparations(tr("Success!"), tr("Successfully installed software from package(s)!"), std::move(paths));
1107+
CreateShortCuts(paths, create_desktop_shortcuts, create_app_shortcut);
1108+
1109+
if (precompile_caches)
1110+
{
1111+
PrecompileCachesFromInstalledPackages(paths);
1112+
}
12001113
});
12011114
}
12021115

@@ -2431,58 +2344,65 @@ void main_window::ShowOptionalGamePreparations(const QString& title, const QStri
24312344
dlg->hide();
24322345
dlg->accept();
24332346

2434-
std::set<gui::utils::shortcut_location> locations;
2347+
CreateShortCuts(paths, create_desktop_shortcuts, create_app_shortcut);
24352348

2436-
#ifdef _WIN32
2437-
locations.insert(gui::utils::shortcut_location::rpcs3_shortcuts);
2438-
#endif
2439-
if (create_desktop_shortcuts)
2349+
if (precompile_caches)
24402350
{
2441-
locations.insert(gui::utils::shortcut_location::desktop);
2351+
PrecompileCachesFromInstalledPackages(paths);
24422352
}
2353+
});
24432354

2444-
if (create_app_shortcut)
2445-
{
2446-
locations.insert(gui::utils::shortcut_location::applications);
2447-
}
2355+
dlg->setAttribute(Qt::WA_DeleteOnClose);
2356+
dlg->open();
2357+
}
24482358

2449-
if (!locations.empty())
2450-
{
2451-
std::vector<game_info> game_data_shortcuts;
2359+
void main_window::CreateShortCuts(const std::map<std::string, QString>& paths, bool create_desktop_shortcuts, bool create_app_shortcut)
2360+
{
2361+
if (paths.empty()) return;
2362+
2363+
std::set<gui::utils::shortcut_location> locations;
2364+
2365+
#ifdef _WIN32
2366+
locations.insert(gui::utils::shortcut_location::rpcs3_shortcuts);
2367+
#endif
2368+
if (create_desktop_shortcuts)
2369+
{
2370+
locations.insert(gui::utils::shortcut_location::desktop);
2371+
}
2372+
2373+
if (create_app_shortcut)
2374+
{
2375+
locations.insert(gui::utils::shortcut_location::applications);
2376+
}
2377+
2378+
if (!locations.empty())
2379+
{
2380+
std::vector<game_info> game_data_shortcuts;
24522381

2453-
for (const auto& [boot_path, title_id] : paths)
2382+
for (const auto& [boot_path, title_id] : paths)
2383+
{
2384+
for (const game_info& gameinfo : m_game_list_frame->GetGameInfo())
24542385
{
2455-
for (const game_info& gameinfo : m_game_list_frame->GetGameInfo())
2386+
if (gameinfo && gameinfo->info.serial == title_id.toStdString())
24562387
{
2457-
if (gameinfo && gameinfo->info.serial == title_id.toStdString())
2388+
if (Emu.IsPathInsideDir(boot_path, gameinfo->info.path))
24582389
{
2459-
if (Emu.IsPathInsideDir(boot_path, gameinfo->info.path))
2390+
if (!locations.empty())
24602391
{
2461-
if (!locations.empty())
2462-
{
2463-
game_data_shortcuts.push_back(gameinfo);
2464-
}
2392+
game_data_shortcuts.push_back(gameinfo);
24652393
}
2466-
2467-
break;
24682394
}
2469-
}
2470-
}
24712395

2472-
if (!game_data_shortcuts.empty() && !locations.empty())
2473-
{
2474-
m_game_list_frame->CreateShortcuts(game_data_shortcuts, locations);
2396+
break;
2397+
}
24752398
}
24762399
}
24772400

2478-
if (precompile_caches)
2401+
if (!game_data_shortcuts.empty() && !locations.empty())
24792402
{
2480-
PrecompileCachesFromInstalledPackages(paths);
2403+
m_game_list_frame->CreateShortcuts(game_data_shortcuts, locations);
24812404
}
2482-
});
2483-
2484-
dlg->setAttribute(Qt::WA_DeleteOnClose);
2485-
dlg->open();
2405+
}
24862406
}
24872407

24882408
void main_window::PrecompileCachesFromInstalledPackages(const std::map<std::string, QString>& bootable_paths)

rpcs3/rpcs3qt/main_window.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ private Q_SLOTS:
149149
static bool InstallFileInExData(const std::string& extension, const QString& path, const std::string& filename);
150150

151151
bool HandlePackageInstallation(QStringList file_paths, bool from_boot);
152+
void CreateShortCuts(const std::map<std::string, QString>& paths, bool create_desktop_shortcuts, bool create_app_shortcut);
152153

153154
void HandlePupInstallation(const QString& file_path, const QString& dir_path = "");
154155
void ExtractPup();

0 commit comments

Comments
 (0)