Qt: allow bulk pkg installation

This commit is contained in:
Megamouse 2018-07-18 08:20:17 +02:00 committed by Ivan
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"); 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; 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(); 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 (*.*)")); 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 else
{ {
if (QMessageBox::question(this, tr("PKG Decrypter / Installer"), tr("Install package: %1?").arg(filePath), 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 case drop_type::drop_pkg: // install the packages
for (const auto& path : dropPaths) for (const auto& path : dropPaths)
{ {
InstallPkg(path); InstallPkg(path, dropPaths.count() > 1);
} }
m_install_bulk = QMessageBox::NoButton;
break; break;
case drop_type::drop_pup: // install the firmware case drop_type::drop_pup: // install the firmware
InstallPup(dropPaths.first()); InstallPup(dropPaths.first());

View file

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