GUI: Display PKG information & installation confirmation from main menu

This commit is contained in:
Eladash 2021-08-14 19:50:11 +03:00 committed by Megamouse
parent 62beaf299f
commit 41cfa6349a

View file

@ -567,9 +567,9 @@ void main_window::InstallPackages(QStringList file_paths)
const QFileInfo file_info(file_paths[0]);
m_gui_settings->SetValue(gui::fd_install_pkg, file_info.path());
}
else if (file_paths.count() == 1)
if (file_paths.count() == 1 && file_paths.front().endsWith(".pkg", Qt::CaseInsensitive))
{
// This can currently only happen by drag and drop and cli arg.
const QString file_path = file_paths.front();
const QFileInfo file_info(file_path);
@ -612,11 +612,13 @@ void main_window::InstallPackages(QStringList file_paths)
info.changelog = tr("\n\nChangelog:\n%0", "Block for Changelog").arg(info.changelog);
}
if (QMessageBox::question(this, tr("PKG Decrypter / Installer"), tr("Do you want to install this package?\n\n%0\n\n%1%2%3%4%5")
.arg(file_info.fileName()).arg(info.title).arg(info.local_cat).arg(info.title_id).arg(info.version).arg(info.changelog),
const QString info_string = QStringLiteral("%0\n\n%1%2%3%4%5").arg(file_info.fileName()).arg(info.title).arg(info.local_cat)
.arg(info.title_id).arg(info.version).arg(info.changelog);
if (QMessageBox::question(this, tr("PKG Decrypter / Installer"), tr("Do you want to install this package?\n\n%0").arg(info_string),
QMessageBox::Yes | QMessageBox::No, QMessageBox::No) != QMessageBox::Yes)
{
gui_log.notice("PKG: Cancelled installation from drop. File: %s", sstr(file_paths.front()));
gui_log.notice("PKG: Cancelled installation from drop.\n%s", sstr(info_string));
return;
}
}