mirror of
https://github.com/RPCS3/rpcs3.git
synced 2026-04-20 08:21:35 -06:00
Qt: Show error if any package is corrupt before installation
This commit is contained in:
parent
1d85de6236
commit
e9fb3572f9
@ -27,14 +27,22 @@ enum Roles
|
||||
pkg_install_dialog::pkg_install_dialog(const QStringList& paths, game_compatibility* compat, QWidget* parent)
|
||||
: QDialog(parent)
|
||||
{
|
||||
ensure(!paths.empty());
|
||||
|
||||
setWindowTitle(tr("PKG Installation"));
|
||||
setObjectName("pkg_install_dialog");
|
||||
|
||||
m_dir_list = new QListWidget(this);
|
||||
m_dir_list->setItemDelegate(new richtext_item_delegate(m_dir_list->itemDelegate()));
|
||||
|
||||
QStringList corrupt_paths;
|
||||
|
||||
for (const QString& path : paths)
|
||||
{
|
||||
const compat::package_info info = game_compatibility::GetPkgInfo(path, compat);
|
||||
if (!info.is_valid)
|
||||
{
|
||||
corrupt_paths << path;
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -44,12 +52,14 @@ pkg_install_dialog::pkg_install_dialog(const QStringList& paths, game_compatibil
|
||||
QString accumulated_info;
|
||||
QString tooltip;
|
||||
|
||||
const auto append_comma = [&accumulated_info]()
|
||||
const auto append_info = [&accumulated_info](const QString& info)
|
||||
{
|
||||
if (!accumulated_info.isEmpty())
|
||||
{
|
||||
accumulated_info += ", ";
|
||||
}
|
||||
|
||||
accumulated_info += info;
|
||||
};
|
||||
|
||||
if (!info.title_id.isEmpty())
|
||||
@ -59,27 +69,23 @@ pkg_install_dialog::pkg_install_dialog(const QStringList& paths, game_compatibil
|
||||
|
||||
if (info.type != compat::package_type::other)
|
||||
{
|
||||
append_comma();
|
||||
|
||||
if (info.type == compat::package_type::dlc)
|
||||
{
|
||||
accumulated_info += tr("DLC", "Package type info (DLC)");
|
||||
append_info(tr("DLC", "Package type info (DLC)"));
|
||||
}
|
||||
else
|
||||
{
|
||||
accumulated_info += tr("Update", "Package type info (Update)");
|
||||
append_info(tr("Update", "Package type info (Update)"));
|
||||
}
|
||||
}
|
||||
else if (!info.local_cat.isEmpty())
|
||||
{
|
||||
append_comma();
|
||||
accumulated_info += info.local_cat;
|
||||
append_info(info.local_cat);
|
||||
}
|
||||
|
||||
if (!info.version.isEmpty())
|
||||
{
|
||||
append_comma();
|
||||
accumulated_info += tr("v.%0", "Version info").arg(info.version);
|
||||
append_info(tr("v.%0", "Version info").arg(info.version));
|
||||
}
|
||||
|
||||
if (info.changelog.isEmpty())
|
||||
@ -91,8 +97,7 @@ pkg_install_dialog::pkg_install_dialog(const QStringList& paths, game_compatibil
|
||||
tooltip = tr("Changelog:\n\n%0", "Changelog info").arg(info.changelog);
|
||||
}
|
||||
|
||||
append_comma();
|
||||
accumulated_info += file_info.fileName();
|
||||
append_info(file_info.fileName());
|
||||
|
||||
const QString text = tr("<b>%0</b> (%1) - %2", "Package text").arg(info.title.simplified())
|
||||
.arg(accumulated_info).arg(gui::utils::format_byte_size(info.data_size));
|
||||
@ -107,18 +112,8 @@ pkg_install_dialog::pkg_install_dialog(const QStringList& paths, game_compatibil
|
||||
item->setToolTip(tooltip);
|
||||
}
|
||||
|
||||
m_dir_list->sortItems();
|
||||
m_dir_list->setCurrentRow(0);
|
||||
m_dir_list->setMinimumWidth((m_dir_list->sizeHintForColumn(0) * 125) / 100);
|
||||
|
||||
// Create contextual label (updated in connect(m_dir_list, &QListWidget::itemChanged ...))
|
||||
QLabel* installation_info = new QLabel();
|
||||
installation_info->setTextFormat(Qt::RichText); // Support HTML tags
|
||||
|
||||
// Create buttons
|
||||
QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Cancel | QDialogButtonBox::Ok);
|
||||
buttons->button(QDialogButtonBox::Ok)->setText(tr("Install"));
|
||||
buttons->button(QDialogButtonBox::Ok)->setDefault(true);
|
||||
QDialogButtonBox* buttons = new QDialogButtonBox(corrupt_paths.isEmpty() ? (QDialogButtonBox::Cancel | QDialogButtonBox::Ok) : QDialogButtonBox::Cancel);
|
||||
|
||||
connect(buttons, &QDialogButtonBox::clicked, this, [this, buttons](QAbstractButton* button)
|
||||
{
|
||||
@ -132,6 +127,35 @@ pkg_install_dialog::pkg_install_dialog(const QStringList& paths, game_compatibil
|
||||
}
|
||||
});
|
||||
|
||||
if (!corrupt_paths.isEmpty())
|
||||
{
|
||||
m_dir_list->hide();
|
||||
|
||||
QString text = tr("Can not install packages. The following packages seem to be corrupt:") + "\n";
|
||||
|
||||
for (const QString& path : corrupt_paths)
|
||||
{
|
||||
text += "\n" + path;
|
||||
}
|
||||
|
||||
QVBoxLayout* vbox = new QVBoxLayout;
|
||||
vbox->addWidget(new QLabel(text));
|
||||
vbox->addWidget(buttons);
|
||||
setLayout(vbox);
|
||||
return;
|
||||
}
|
||||
|
||||
buttons->button(QDialogButtonBox::Ok)->setText(tr("Install"));
|
||||
buttons->button(QDialogButtonBox::Ok)->setDefault(true);
|
||||
|
||||
m_dir_list->sortItems();
|
||||
m_dir_list->setCurrentRow(0);
|
||||
m_dir_list->setMinimumWidth((m_dir_list->sizeHintForColumn(0) * 125) / 100);
|
||||
|
||||
// Create contextual label (updated in connect(m_dir_list, &QListWidget::itemChanged ...))
|
||||
QLabel* installation_info = new QLabel();
|
||||
installation_info->setTextFormat(Qt::RichText); // Support HTML tags
|
||||
|
||||
QHBoxLayout* hbox = nullptr;
|
||||
if (m_dir_list->count() > 1)
|
||||
{
|
||||
@ -210,8 +234,6 @@ pkg_install_dialog::pkg_install_dialog(const QStringList& paths, game_compatibil
|
||||
vbox->addWidget(buttons);
|
||||
|
||||
setLayout(vbox);
|
||||
setWindowTitle(tr("PKG Installation"));
|
||||
setObjectName("pkg_install_dialog");
|
||||
update_info(installation_info, buttons); // Just to show and check available and required size
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user