From 3fd23a54cb914088970da646577fe3ca6729649e Mon Sep 17 00:00:00 2001 From: srazi Date: Tue, 13 Oct 2015 04:04:47 +0330 Subject: [PATCH] Plugins: Added interface for extension's submenu to Tools menu, --- src/lib/app/mainmenu.cpp | 10 ++++++++++ src/lib/app/mainmenu.h | 1 + src/lib/plugins/plugininterface.h | 1 + src/lib/plugins/pluginproxy.cpp | 11 +++++++++++ src/lib/plugins/pluginproxy.h | 1 + 5 files changed, 24 insertions(+) diff --git a/src/lib/app/mainmenu.cpp b/src/lib/app/mainmenu.cpp index 2d238b801..ecfc5a748 100644 --- a/src/lib/app/mainmenu.cpp +++ b/src/lib/app/mainmenu.cpp @@ -31,6 +31,7 @@ #include "mainapplication.h" #include "clearprivatedata.h" #include "qzsettings.h" +#include "pluginproxy.h" #include #include @@ -412,6 +413,11 @@ void MainMenu::aboutToShowToolsMenu() return; m_actions[QSL("Tools/SiteInfo")]->setEnabled(SiteInfo::canShowSiteInfo(m_window->weView()->url())); + + m_submenuExtensions->clear(); + mApp->plugins()->populateExtensionsMenu(m_submenuExtensions); + + m_submenuExtensions->menuAction()->setVisible(!m_submenuExtensions->actions().isEmpty()); } void MainMenu::aboutToHideToolsMenu() @@ -580,6 +586,10 @@ void MainMenu::init() ADD_ACTION("Tools/AdBlock", m_menuTools, QIcon(), tr("&AdBlock"), SLOT(showAdBlockDialog()), ""); ADD_ACTION("Tools/WebInspector", m_menuTools, QIcon(), tr("Web In&spector"), SLOT(toggleWebInspector()), "Ctrl+Shift+I"); ADD_ACTION("Tools/ClearRecentHistory", m_menuTools, QIcon::fromTheme(QSL("edit-clear")), tr("Clear Recent &History"), SLOT(showClearRecentHistoryDialog()), "Ctrl+Shift+Del"); + + m_submenuExtensions = new QMenu(tr("&Extensions")); + m_submenuExtensions->menuAction()->setVisible(false); + m_menuTools->addMenu(m_submenuExtensions); m_menuTools->addSeparator(); // Help menu diff --git a/src/lib/app/mainmenu.h b/src/lib/app/mainmenu.h index bb489f14a..7045be513 100644 --- a/src/lib/app/mainmenu.h +++ b/src/lib/app/mainmenu.h @@ -127,6 +127,7 @@ private: QMenu* m_menuView; QMenu* m_menuTools; QMenu* m_menuHelp; + QMenu* m_submenuExtensions; HistoryMenu* m_menuHistory; BookmarksMenu* m_menuBookmarks; }; diff --git a/src/lib/plugins/plugininterface.h b/src/lib/plugins/plugininterface.h index 015c7482e..ac91b4244 100644 --- a/src/lib/plugins/plugininterface.h +++ b/src/lib/plugins/plugininterface.h @@ -71,6 +71,7 @@ public: virtual void showSettings(QWidget* parent = 0) { Q_UNUSED(parent) } virtual void populateWebViewMenu(QMenu* menu, WebView* view, const WebHitTestResult &r) { Q_UNUSED(menu) Q_UNUSED(view) Q_UNUSED(r) } + virtual void populateExtensionsMenu(QMenu *menu) { Q_UNUSED(menu) } virtual bool mouseDoubleClick(const Qz::ObjectName &type, QObject* obj, QMouseEvent* event) { Q_UNUSED(type) Q_UNUSED(obj) Q_UNUSED(event) return false; } virtual bool mousePress(const Qz::ObjectName &type, QObject* obj, QMouseEvent* event) { Q_UNUSED(type) Q_UNUSED(obj) Q_UNUSED(event) return false; } diff --git a/src/lib/plugins/pluginproxy.cpp b/src/lib/plugins/pluginproxy.cpp index 3d507223f..2482b002d 100644 --- a/src/lib/plugins/pluginproxy.cpp +++ b/src/lib/plugins/pluginproxy.cpp @@ -100,6 +100,17 @@ void PluginProxy::populateWebViewMenu(QMenu* menu, WebView* view, const WebHitTe } } +void PluginProxy::populateExtensionsMenu(QMenu *menu) +{ + if (!menu) { + return; + } + + foreach (PluginInterface* iPlugin, m_loadedPlugins) { + iPlugin->populateExtensionsMenu(menu); + } +} + bool PluginProxy::processMouseDoubleClick(const Qz::ObjectName &type, QObject* obj, QMouseEvent* event) { bool accepted = false; diff --git a/src/lib/plugins/pluginproxy.h b/src/lib/plugins/pluginproxy.h index fc991dfc3..da593fb6f 100644 --- a/src/lib/plugins/pluginproxy.h +++ b/src/lib/plugins/pluginproxy.h @@ -40,6 +40,7 @@ public: void registerAppEventHandler(const EventHandlerType &type, PluginInterface* obj); void populateWebViewMenu(QMenu* menu, WebView* view, const WebHitTestResult &r); + void populateExtensionsMenu(QMenu *menu); bool processMouseDoubleClick(const Qz::ObjectName &type, QObject* obj, QMouseEvent* event); bool processMousePress(const Qz::ObjectName &type, QObject* obj, QMouseEvent* event);