Qt: Allow user to precompile caches on demand when installing packages or adding disc games

This commit is contained in:
Megamouse 2025-12-04 00:23:53 +01:00
parent 133b19f205
commit eb956d42f6

View file

@ -1178,13 +1178,7 @@ bool main_window::HandlePackageInstallation(QStringList file_paths, bool from_bo
}
}
// Executes after PrecompileCachesFromInstalledPackages
m_notify_batch_game_action_cb = [this, paths]() mutable
{
ShowOptionalGamePreparations(tr("Success!"), tr("Successfully installed software from package(s)!"), std::move(paths));
};
PrecompileCachesFromInstalledPackages(paths);
});
}
@ -2384,6 +2378,7 @@ void main_window::ShowOptionalGamePreparations(const QString& title, const QStri
QVBoxLayout* vlayout = new QVBoxLayout(dlg);
QCheckBox* precompile_check = new QCheckBox(tr("Precompile caches"));
QCheckBox* desk_check = new QCheckBox(tr("Add desktop shortcut(s)"));
#ifdef _WIN32
QCheckBox* quick_check = new QCheckBox(tr("Add Start menu shortcut(s)"));
@ -2392,10 +2387,12 @@ void main_window::ShowOptionalGamePreparations(const QString& title, const QStri
#else
QCheckBox* quick_check = new QCheckBox(tr("Add launcher shortcut(s)"));
#endif
QLabel* label = new QLabel(tr("%1\nWould you like to install shortcuts to the installed software? (%2 new software detected)\n\n").arg(message).arg(bootable_paths.size()), dlg);
QLabel* label = new QLabel(tr("%1\nWould you like to precompile caches and install shortcuts to the installed software? (%2 new software detected)\n\n").arg(message).arg(bootable_paths.size()), dlg);
vlayout->addWidget(label);
vlayout->addStretch(10);
vlayout->addWidget(precompile_check);
vlayout->addStretch(3);
vlayout->addWidget(desk_check);
vlayout->addStretch(3);
vlayout->addWidget(quick_check);
@ -2408,6 +2405,7 @@ void main_window::ShowOptionalGamePreparations(const QString& title, const QStri
connect(btn_box, &QDialogButtonBox::accepted, this, [=, this, paths = std::move(bootable_paths)]()
{
const bool precompile_caches = precompile_check->isChecked();
const bool create_desktop_shortcuts = desk_check->isChecked();
const bool create_app_shortcut = quick_check->isChecked();
@ -2429,11 +2427,8 @@ void main_window::ShowOptionalGamePreparations(const QString& title, const QStri
locations.insert(gui::utils::shortcut_location::applications);
}
if (locations.empty())
if (!locations.empty())
{
return;
}
std::vector<game_info> game_data_shortcuts;
for (const auto& [boot_path, title_id] : paths)
@ -2459,6 +2454,12 @@ void main_window::ShowOptionalGamePreparations(const QString& title, const QStri
{
m_game_list_frame->CreateShortcuts(game_data_shortcuts, locations);
}
}
if (precompile_caches)
{
PrecompileCachesFromInstalledPackages(paths);
}
});
dlg->setAttribute(Qt::WA_DeleteOnClose);