diff --git a/src/lib/navigation/navigationbar.cpp b/src/lib/navigation/navigationbar.cpp index c4f5fb715..204ff4b1f 100644 --- a/src/lib/navigation/navigationbar.cpp +++ b/src/lib/navigation/navigationbar.cpp @@ -281,6 +281,10 @@ void NavigationBar::addToolButton(AbstractButtonInterface *button) data.button = button; m_widgets[data.id] = data; + if (m_window->weView()) { + data.button->setWebPage(m_window->weView()->page()); + } + reloadLayout(); } diff --git a/src/plugins/GreaseMonkey/gm_icon.cpp b/src/plugins/GreaseMonkey/gm_icon.cpp index 0efc017fb..a611fc4d9 100644 --- a/src/plugins/GreaseMonkey/gm_icon.cpp +++ b/src/plugins/GreaseMonkey/gm_icon.cpp @@ -1,6 +1,6 @@ /* ============================================================ * GreaseMonkey plugin for Falkon -* Copyright (C) 2013-2017 David Rosca +* Copyright (C) 2013-2018 David Rosca * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,21 +17,32 @@ * ============================================================ */ #include "gm_icon.h" #include "gm_manager.h" -#include "browserwindow.h" -GM_Icon::GM_Icon(GM_Manager* manager, BrowserWindow* window) - : ClickableLabel(window) +#include "webpage.h" +#include "webview.h" + +GM_Icon::GM_Icon(GM_Manager *manager) + : AbstractButtonInterface(manager) , m_manager(manager) - , m_window(window) { - setCursor(Qt::PointingHandCursor); - setPixmap(QIcon(":gm/data/icon.svg").pixmap(16)); + setIcon(QIcon(":gm/data/icon.svg")); + setTitle(tr("GreaseMonkey")); setToolTip(tr("Open GreaseMonkey settings")); - connect(this, SIGNAL(clicked(QPoint)), this, SLOT(openSettings())); + connect(this, &AbstractButtonInterface::clicked, this, &GM_Icon::openSettings); +} + +QString GM_Icon::id() const +{ + return QSL("greasemonkey-icon"); +} + +QString GM_Icon::name() const +{ + return tr("GreaseMonkey Icon"); } void GM_Icon::openSettings() { - m_manager->showSettings(m_window); + m_manager->showSettings(webPage() ? webPage()->view() : nullptr); } diff --git a/src/plugins/GreaseMonkey/gm_icon.h b/src/plugins/GreaseMonkey/gm_icon.h index 823e486de..2017800cd 100644 --- a/src/plugins/GreaseMonkey/gm_icon.h +++ b/src/plugins/GreaseMonkey/gm_icon.h @@ -1,6 +1,6 @@ /* ============================================================ * GreaseMonkey plugin for Falkon -* Copyright (C) 2013-2014 David Rosca +* Copyright (C) 2013-2018 David Rosca * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,24 +18,25 @@ #ifndef GM_ICON_H #define GM_ICON_H -#include "clickablelabel.h" +#include "abstractbuttoninterface.h" -class BrowserWindow; class GM_Manager; -class GM_Icon : public ClickableLabel +class GM_Icon : public AbstractButtonInterface { Q_OBJECT public: - explicit GM_Icon(GM_Manager* manager, BrowserWindow* window); + explicit GM_Icon(GM_Manager *manager); + + QString id() const override; + QString name() const override; private slots: void openSettings(); private: - GM_Manager* m_manager; - BrowserWindow* m_window; + GM_Manager *m_manager; }; #endif // GM_ICON_H diff --git a/src/plugins/GreaseMonkey/gm_manager.cpp b/src/plugins/GreaseMonkey/gm_manager.cpp index 0d88104bf..1aa4d47b1 100644 --- a/src/plugins/GreaseMonkey/gm_manager.cpp +++ b/src/plugins/GreaseMonkey/gm_manager.cpp @@ -28,13 +28,13 @@ #include "qztools.h" #include "mainapplication.h" #include "networkmanager.h" +#include "navigationbar.h" #include "desktopnotificationsfactory.h" #include "javascript/externaljsobject.h" #include #include #include -#include #include #include @@ -294,14 +294,13 @@ bool GM_Manager::canRunOnScheme(const QString &scheme) void GM_Manager::mainWindowCreated(BrowserWindow* window) { - GM_Icon* icon = new GM_Icon(this, window); - window->statusBar()->addPermanentWidget(icon); + GM_Icon *icon = new GM_Icon(this); + window->navigationBar()->addToolButton(icon); m_windows[window] = icon; } void GM_Manager::mainWindowDeleted(BrowserWindow* window) { - window->statusBar()->removeWidget(m_windows[window]); - delete m_windows[window]; - m_windows.remove(window); + window->navigationBar()->removeToolButton(m_windows[window]); + delete m_windows.take(window); } diff --git a/src/plugins/GreaseMonkey/gm_plugin.cpp b/src/plugins/GreaseMonkey/gm_plugin.cpp index 4298a26a9..d1027de78 100644 --- a/src/plugins/GreaseMonkey/gm_plugin.cpp +++ b/src/plugins/GreaseMonkey/gm_plugin.cpp @@ -40,7 +40,7 @@ PluginSpec GM_Plugin::pluginSpec() spec.name = "GreaseMonkey"; spec.info = "Userscripts for Falkon"; spec.description = "Provides support for userscripts"; - spec.version = "0.9.2"; + spec.version = "0.9.3"; spec.author = "David Rosca "; spec.icon = QIcon(":gm/data/icon.svg").pixmap(32); spec.hasSettings = true;