From 5ee5d66e1822b74703d893bf19dc08ff91b3bf33 Mon Sep 17 00:00:00 2001 From: nowrep Date: Fri, 24 May 2013 14:56:47 +0200 Subject: [PATCH] [GreaseMonkey] Fixed loading userscripts when first enabling plugin. --- CHANGELOG | 1 + src/plugins/GreaseMonkey/gm_plugin.cpp | 19 ++++++++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index d6e0e74ef..9191eca60 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -10,6 +10,7 @@ Version 1.5.0 * proxy exceptions now supports wildcards (*, ?) * cancel upload when trying to upload non-readable files * GreaseMonkey: added support for GM_Settings + * GreaseMonkey: fixed userscripts when first loading plugin * oxygen: set rounded corners for tooltips * oxygen: workaround for transparent background of tooltips * fixed: size of preferences dialog on low-res screens diff --git a/src/plugins/GreaseMonkey/gm_plugin.cpp b/src/plugins/GreaseMonkey/gm_plugin.cpp index 7c1e34cdb..dc7f4fbce 100644 --- a/src/plugins/GreaseMonkey/gm_plugin.cpp +++ b/src/plugins/GreaseMonkey/gm_plugin.cpp @@ -22,6 +22,9 @@ #include "pluginproxy.h" #include "mainapplication.h" #include "emptynetworkreply.h" +#include "tabwidget.h" +#include "webtab.h" +#include "tabbedwebview.h" #include #include @@ -38,7 +41,7 @@ PluginSpec GM_Plugin::pluginSpec() spec.name = "GreaseMonkey"; spec.info = "Userscripts for QupZilla"; spec.description = "Provides support for userscripts (www.userscripts.org)"; - spec.version = "0.3.1"; + spec.version = "0.3.2"; spec.author = "David Rosca "; spec.icon = QPixmap(":gm/data/icon.png"); spec.hasSettings = true; @@ -48,12 +51,22 @@ PluginSpec GM_Plugin::pluginSpec() void GM_Plugin::init(InitState state, const QString &settingsPath) { - Q_UNUSED(state) - m_manager = new GM_Manager(settingsPath, this); m_settingsPath = settingsPath; connect(mApp->plugins(), SIGNAL(webPageCreated(WebPage*)), this, SLOT(webPageCreated(WebPage*))); + + // Make sure userscripts works also with already created WebPages + if (state == LateInitState) { + foreach (QupZilla* window, mApp->mainWindows()) { + for (int i = 0; i < window->tabWidget()->count(); ++i) { + WebTab* tab = qobject_cast(window->tabWidget()->widget(i)); + if (tab) { + webPageCreated(tab->view()->page()); + } + } + } + } } void GM_Plugin::unload()