From a89fcf90026c2400b7f63df51ca3459bbfc319ab Mon Sep 17 00:00:00 2001 From: David Rosca Date: Mon, 29 Jan 2018 22:03:43 +0100 Subject: [PATCH] GM_Manager: Remove no longer needed doDownloadScript helper downloadScript is now always called from main thread again. --- src/plugins/GreaseMonkey/gm_manager.cpp | 43 +++++++++++-------------- src/plugins/GreaseMonkey/gm_manager.h | 1 - src/plugins/GreaseMonkey/gm_plugin.cpp | 2 +- 3 files changed, 20 insertions(+), 26 deletions(-) diff --git a/src/plugins/GreaseMonkey/gm_manager.cpp b/src/plugins/GreaseMonkey/gm_manager.cpp index 4618037cb..89818e9d7 100644 --- a/src/plugins/GreaseMonkey/gm_manager.cpp +++ b/src/plugins/GreaseMonkey/gm_manager.cpp @@ -64,7 +64,25 @@ void GM_Manager::showSettings(QWidget* parent) void GM_Manager::downloadScript(const QUrl &url) { - QMetaObject::invokeMethod(this, "doDownloadScript", Qt::QueuedConnection, Q_ARG(QUrl, url)); + GM_Downloader *downloader = new GM_Downloader(url, this); + connect(downloader, &GM_Downloader::finished, this, [=](const QString &fileName) { + bool deleteScript = true; + GM_Script *script = new GM_Script(this, fileName); + if (script->isValid()) { + if (!containsScript(script->fullName())) { + GM_AddScriptDialog dialog(this, script); + deleteScript = dialog.exec() != QDialog::Accepted; + } + else { + showNotification(tr("'%1' is already installed").arg(script->name())); + } + } + + if (deleteScript) { + delete script; + QFile(fileName).remove(); + } + }); } QString GM_Manager::settinsPath() const @@ -264,29 +282,6 @@ void GM_Manager::scriptChanged() collection->insert(script->webScript()); } -void GM_Manager::doDownloadScript(const QUrl &url) -{ - GM_Downloader *downloader = new GM_Downloader(url, this); - connect(downloader, &GM_Downloader::finished, this, [=](const QString &fileName) { - bool deleteScript = true; - GM_Script *script = new GM_Script(this, fileName); - if (script->isValid()) { - if (!containsScript(script->fullName())) { - GM_AddScriptDialog dialog(this, script); - deleteScript = dialog.exec() != QDialog::Accepted; - } - else { - showNotification(tr("'%1' is already installed").arg(script->name())); - } - } - - if (deleteScript) { - delete script; - QFile(fileName).remove(); - } - }); -} - bool GM_Manager::canRunOnScheme(const QString &scheme) { return (scheme == QLatin1String("http") || scheme == QLatin1String("https") diff --git a/src/plugins/GreaseMonkey/gm_manager.h b/src/plugins/GreaseMonkey/gm_manager.h index 959040dcc..cae1bc991 100644 --- a/src/plugins/GreaseMonkey/gm_manager.h +++ b/src/plugins/GreaseMonkey/gm_manager.h @@ -73,7 +73,6 @@ public slots: private slots: void load(); void scriptChanged(); - void doDownloadScript(const QUrl &url); private: QString m_settingsPath; diff --git a/src/plugins/GreaseMonkey/gm_plugin.cpp b/src/plugins/GreaseMonkey/gm_plugin.cpp index a88372306..89035522d 100644 --- a/src/plugins/GreaseMonkey/gm_plugin.cpp +++ b/src/plugins/GreaseMonkey/gm_plugin.cpp @@ -41,7 +41,7 @@ PluginSpec GM_Plugin::pluginSpec() spec.name = "GreaseMonkey"; spec.info = "Userscripts for Falkon"; spec.description = "Provides support for userscripts"; - spec.version = "0.9.3"; + spec.version = "0.9.4"; spec.author = "David Rosca "; spec.icon = QIcon(":gm/data/icon.svg").pixmap(32); spec.hasSettings = true;