Qt: allow bulk pkg installation

This commit is contained in:
Megamouse 2018-07-18 08:20:17 +02:00 committed by Ivan
parent 05c5763492
commit 60a276e9ce
2 changed files with 38 additions and 4 deletions

View file

@ -380,15 +380,46 @@ void main_window::BootRsxCapture()
LOG_SUCCESS(LOADER, "Capture Boot Success");
}
void main_window::InstallPkg(const QString& dropPath)
void main_window::InstallPkg(const QString& dropPath, bool is_bulk)
{
QString filePath = dropPath;
if (filePath.isEmpty())
if (m_install_bulk == QMessageBox::NoToAll)
{
LOG_NOTICE(LOADER, "PKG: Skipped installation from drop. File: %s", sstr(filePath));
return;
}
else if (m_install_bulk == QMessageBox::YesToAll)
{
LOG_NOTICE(LOADER, "PKG: Continuing bulk installation from drop. File: %s", sstr(filePath));
}
else if (filePath.isEmpty())
{
QString path_last_PKG = guiSettings->GetValue(gui::fd_install_pkg).toString();
filePath = QFileDialog::getOpenFileName(this, tr("Select PKG To Install"), path_last_PKG, tr("PKG files (*.pkg);;All files (*.*)"));
}
else if (is_bulk)
{
QMessageBox::StandardButton ret = QMessageBox::question(this, tr("PKG Decrypter / Installer"), tr("Install package: %1?").arg(filePath),
QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::NoToAll | QMessageBox::No, QMessageBox::No);
if (ret == QMessageBox::No)
{
LOG_NOTICE(LOADER, "PKG: Cancelled installation from drop. File: %s", sstr(filePath));
return;
}
else if (ret == QMessageBox::NoToAll)
{
LOG_NOTICE(LOADER, "PKG: Cancelled bulk installation from drop. File: %s", sstr(filePath));
m_install_bulk = ret;
return;
}
else if (ret == QMessageBox::YesToAll)
{
LOG_NOTICE(LOADER, "PKG: Accepted bulk installation from drop. File: %s", sstr(filePath));
m_install_bulk = ret;
}
}
else
{
if (QMessageBox::question(this, tr("PKG Decrypter / Installer"), tr("Install package: %1?").arg(filePath),
@ -1714,8 +1745,9 @@ void main_window::dropEvent(QDropEvent* event)
case drop_type::drop_pkg: // install the packages
for (const auto& path : dropPaths)
{
InstallPkg(path);
InstallPkg(path, dropPaths.count() > 1);
}
m_install_bulk = QMessageBox::NoButton;
break;
case drop_type::drop_pup: // install the firmware
InstallPup(dropPaths.first());

View file

@ -115,7 +115,7 @@ private:
void CreateConnects();
void CreateDockWindows();
void EnableMenus(bool enabled);
void InstallPkg(const QString& dropPath = "");
void InstallPkg(const QString& dropPath = "", bool is_bulk = false);
void InstallPup(const QString& dropPath = "");
int IsValidFile(const QMimeData& md, QStringList* dropPaths = nullptr);
@ -132,6 +132,8 @@ private:
QActionGroup* m_listModeActGroup;
QActionGroup* m_categoryVisibleActGroup;
QMessageBox::StandardButton m_install_bulk = QMessageBox::NoButton;
// Dockable widget frames
QMainWindow *m_mw;
log_frame *m_logFrame;