Browse Source

Aggregate installed/updated plugin names and use a single messagebox to inform the user.

adaptive-webui-19844
sledgehammer999 8 years ago
parent
commit
dee0b63cc5
No known key found for this signature in database
GPG Key ID: 6E4A2D025B7CC9A2
  1. 20
      src/gui/search/pluginselectdlg.cpp
  2. 4
      src/gui/search/pluginselectdlg.h

20
src/gui/search/pluginselectdlg.cpp

@ -65,6 +65,7 @@ PluginSelectDlg::PluginSelectDlg(SearchEngine *pluginManager, QWidget *parent) @@ -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() @@ -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 QHash<QString, PluginVersion @@ -414,6 +425,7 @@ void PluginSelectDlg::checkForUpdatesFinished(const QHash<QString, PluginVersion
foreach (const QString &pluginName, updateInfo.keys()) {
startAsyncOp();
m_pendingUpdates++;
m_pluginManager->updatePlugin(pluginName);
}
}
@ -428,13 +440,15 @@ void PluginSelectDlg::pluginInstalled(const QString &name) @@ -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) @@ -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 @@ -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();
}

4
src/gui/search/pluginselectdlg.h

@ -37,6 +37,7 @@ @@ -37,6 +37,7 @@
#include "base/searchengine.h"
class QDropEvent;
class QStringList;
class QTreeWidgetItem;
namespace Ui
@ -88,10 +89,13 @@ private: @@ -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

Loading…
Cancel
Save