From dee0b63cc529eb0e9f8b125caefdf81575d7d07e Mon Sep 17 00:00:00 2001 From: sledgehammer999 Date: Wed, 14 Jun 2017 01:23:08 +0300 Subject: [PATCH] Aggregate installed/updated plugin names and use a single messagebox to inform the user. --- src/gui/search/pluginselectdlg.cpp | 20 ++++++++++++++++++-- src/gui/search/pluginselectdlg.h | 4 ++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/gui/search/pluginselectdlg.cpp b/src/gui/search/pluginselectdlg.cpp index 581ac8a51..93bf7d565 100644 --- a/src/gui/search/pluginselectdlg.cpp +++ b/src/gui/search/pluginselectdlg.cpp @@ -65,6 +65,7 @@ PluginSelectDlg::PluginSelectDlg(SearchEngine *pluginManager, QWidget *parent) , m_ui(new Ui::PluginSelectDlg()) , m_pluginManager(pluginManager) , m_asyncOps(0) + , m_pendingUpdates(0) { m_ui->setupUi(this); setAttribute(Qt::WA_DeleteOnClose); @@ -314,6 +315,16 @@ void PluginSelectDlg::finishAsyncOp() setCursor(QCursor(Qt::ArrowCursor)); } +void PluginSelectDlg::finishPluginUpdate() +{ + --m_pendingUpdates; + if (m_pendingUpdates == 0 && !m_updatedPlugins.isEmpty()) { + m_updatedPlugins.sort(Qt::CaseInsensitive); + QMessageBox::information(this, tr("Search plugin update"), tr("Plugins installed or updated: %1").arg(m_updatedPlugins.join(", "))); + m_updatedPlugins.clear(); + } +} + void PluginSelectDlg::on_installButton_clicked() { PluginSourceDlg *dlg = new PluginSourceDlg(this); @@ -414,6 +425,7 @@ void PluginSelectDlg::checkForUpdatesFinished(const QHashupdatePlugin(pluginName); } } @@ -428,13 +440,15 @@ void PluginSelectDlg::pluginInstalled(const QString &name) { addNewPlugin(name); finishAsyncOp(); - QMessageBox::information(this, tr("Search plugin install"), tr("\"%1\" search engine plugin was successfully installed.", "%1 is the name of the search engine").arg(name)); + m_updatedPlugins.append(name); + finishPluginUpdate(); } void PluginSelectDlg::pluginInstallationFailed(const QString &name, const QString &reason) { finishAsyncOp(); QMessageBox::information(this, tr("Search plugin install"), tr("Couldn't install \"%1\" search engine plugin. %2").arg(name).arg(reason)); + finishPluginUpdate(); } void PluginSelectDlg::pluginUpdated(const QString &name) @@ -443,7 +457,8 @@ void PluginSelectDlg::pluginUpdated(const QString &name) PluginVersion version = m_pluginManager->pluginInfo(name)->version; QTreeWidgetItem *item = findItemWithID(name); item->setText(PLUGIN_VERSION, version); - QMessageBox::information(this, tr("Search plugin install"), tr("\"%1\" search engine plugin was successfully updated.", "%1 is the name of the search engine").arg(name)); + m_updatedPlugins.append(name); + finishPluginUpdate(); } @@ -451,4 +466,5 @@ void PluginSelectDlg::pluginUpdateFailed(const QString &name, const QString &rea { finishAsyncOp(); QMessageBox::information(this, tr("Search plugin update"), tr("Couldn't update \"%1\" search engine plugin. %2").arg(name).arg(reason)); + finishPluginUpdate(); } diff --git a/src/gui/search/pluginselectdlg.h b/src/gui/search/pluginselectdlg.h index c767563e7..f9eaf15a0 100644 --- a/src/gui/search/pluginselectdlg.h +++ b/src/gui/search/pluginselectdlg.h @@ -37,6 +37,7 @@ #include "base/searchengine.h" class QDropEvent; +class QStringList; class QTreeWidgetItem; namespace Ui @@ -88,10 +89,13 @@ private: void addNewPlugin(QString pluginName); void startAsyncOp(); void finishAsyncOp(); + void finishPluginUpdate(); Ui::PluginSelectDlg *m_ui; SearchEngine *m_pluginManager; + QStringList m_updatedPlugins; int m_asyncOps; + int m_pendingUpdates; }; #endif // PLUGINSELECTDLG_H