1
0
mirror of https://github.com/d47081/qBittorrent.git synced 2025-01-27 06:54:20 +00:00

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

This commit is contained in:
sledgehammer999 2017-06-14 01:23:08 +03:00
parent c2a2d306da
commit dee0b63cc5
No known key found for this signature in database
GPG Key ID: 6E4A2D025B7CC9A2
2 changed files with 22 additions and 2 deletions

View File

@ -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 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)
{
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();
}

View File

@ -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