Warning, file /network/falkon/src/lib/plugins/pluginproxy.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* ============================================================ 0002 * Falkon - Qt web browser 0003 * Copyright (C) 2010-2018 David Rosca <nowrep@gmail.com> 0004 * 0005 * This program is free software: you can redistribute it and/or modify 0006 * it under the terms of the GNU General Public License as published by 0007 * the Free Software Foundation, either version 3 of the License, or 0008 * (at your option) any later version. 0009 * 0010 * This program is distributed in the hope that it will be useful, 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0013 * GNU General Public License for more details. 0014 * 0015 * You should have received a copy of the GNU General Public License 0016 * along with this program. If not, see <http://www.gnu.org/licenses/>. 0017 * ============================================================ */ 0018 #include "pluginproxy.h" 0019 #include "plugininterface.h" 0020 #include "mainapplication.h" 0021 #include "settings.h" 0022 0023 #include <QMenu> 0024 0025 PluginProxy::PluginProxy(QObject *parent) 0026 : Plugins(parent) 0027 { 0028 connect(this, SIGNAL(pluginUnloaded(PluginInterface*)), this, SLOT(pluginUnloaded(PluginInterface*))); 0029 } 0030 0031 void PluginProxy::registerAppEventHandler(PluginProxy::EventHandlerType type, PluginInterface* obj) 0032 { 0033 switch (type) { 0034 case MouseDoubleClickHandler: 0035 if (!m_mouseDoubleClickHandlers.contains(obj)) { 0036 m_mouseDoubleClickHandlers.append(obj); 0037 } 0038 break; 0039 0040 case MousePressHandler: 0041 if (!m_mousePressHandlers.contains(obj)) { 0042 m_mousePressHandlers.append(obj); 0043 } 0044 break; 0045 0046 case MouseReleaseHandler: 0047 if (!m_mouseReleaseHandlers.contains(obj)) { 0048 m_mouseReleaseHandlers.append(obj); 0049 } 0050 break; 0051 0052 case MouseMoveHandler: 0053 if (!m_mouseMoveHandlers.contains(obj)) { 0054 m_mouseMoveHandlers.append(obj); 0055 } 0056 break; 0057 0058 case KeyPressHandler: 0059 if (!m_keyPressHandlers.contains(obj)) { 0060 m_keyPressHandlers.append(obj); 0061 } 0062 break; 0063 0064 case KeyReleaseHandler: 0065 if (!m_keyReleaseHandlers.contains(obj)) { 0066 m_keyReleaseHandlers.append(obj); 0067 } 0068 break; 0069 0070 case WheelEventHandler: 0071 if (!m_wheelEventHandlers.contains(obj)) { 0072 m_wheelEventHandlers.append(obj); 0073 } 0074 break; 0075 0076 default: 0077 qWarning("PluginProxy::registerAppEventHandler registering unknown event handler type"); 0078 break; 0079 } 0080 } 0081 0082 void PluginProxy::pluginUnloaded(PluginInterface* plugin) 0083 { 0084 m_mousePressHandlers.removeOne(plugin); 0085 m_mouseReleaseHandlers.removeOne(plugin); 0086 m_mouseMoveHandlers.removeOne(plugin); 0087 m_wheelEventHandlers.removeOne(plugin); 0088 0089 m_keyPressHandlers.removeOne(plugin); 0090 m_keyReleaseHandlers.removeOne(plugin); 0091 } 0092 0093 void PluginProxy::populateWebViewMenu(QMenu* menu, WebView* view, const WebHitTestResult &r) 0094 { 0095 if (!menu || !view) { 0096 return; 0097 } 0098 0099 for (PluginInterface* iPlugin : std::as_const(m_loadedPlugins)) { 0100 iPlugin->populateWebViewMenu(menu, view, r); 0101 } 0102 } 0103 0104 void PluginProxy::populateExtensionsMenu(QMenu *menu) 0105 { 0106 if (!menu) { 0107 return; 0108 } 0109 0110 for (PluginInterface* iPlugin : std::as_const(m_loadedPlugins)) { 0111 iPlugin->populateExtensionsMenu(menu); 0112 } 0113 } 0114 0115 bool PluginProxy::processMouseDoubleClick(Qz::ObjectName type, QObject* obj, QMouseEvent* event) 0116 { 0117 bool accepted = false; 0118 0119 for (PluginInterface* iPlugin : std::as_const(m_mouseDoubleClickHandlers)) { 0120 if (iPlugin->mouseDoubleClick(type, obj, event)) { 0121 accepted = true; 0122 } 0123 } 0124 0125 return accepted; 0126 } 0127 0128 bool PluginProxy::processMousePress(Qz::ObjectName type, QObject* obj, QMouseEvent* event) 0129 { 0130 bool accepted = false; 0131 0132 for (PluginInterface* iPlugin : std::as_const(m_mousePressHandlers)) { 0133 if (iPlugin->mousePress(type, obj, event)) { 0134 accepted = true; 0135 } 0136 } 0137 0138 return accepted; 0139 } 0140 0141 bool PluginProxy::processMouseRelease(Qz::ObjectName type, QObject* obj, QMouseEvent* event) 0142 { 0143 bool accepted = false; 0144 0145 for (PluginInterface* iPlugin : std::as_const(m_mouseReleaseHandlers)) { 0146 if (iPlugin->mouseRelease(type, obj, event)) { 0147 accepted = true; 0148 } 0149 } 0150 0151 return accepted; 0152 } 0153 0154 bool PluginProxy::processMouseMove(Qz::ObjectName type, QObject* obj, QMouseEvent* event) 0155 { 0156 bool accepted = false; 0157 0158 for (PluginInterface* iPlugin : std::as_const(m_mouseMoveHandlers)) { 0159 if (iPlugin->mouseMove(type, obj, event)) { 0160 accepted = true; 0161 } 0162 } 0163 0164 return accepted; 0165 } 0166 0167 bool PluginProxy::processWheelEvent(Qz::ObjectName type, QObject* obj, QWheelEvent* event) 0168 { 0169 bool accepted = false; 0170 0171 for (PluginInterface* iPlugin : std::as_const(m_wheelEventHandlers)) { 0172 if (iPlugin->wheelEvent(type, obj, event)) { 0173 accepted = true; 0174 } 0175 } 0176 0177 return accepted; 0178 } 0179 0180 bool PluginProxy::processKeyPress(Qz::ObjectName type, QObject* obj, QKeyEvent* event) 0181 { 0182 bool accepted = false; 0183 0184 for (PluginInterface* iPlugin : std::as_const(m_keyPressHandlers)) { 0185 if (iPlugin->keyPress(type, obj, event)) { 0186 accepted = true; 0187 } 0188 } 0189 0190 return accepted; 0191 } 0192 0193 bool PluginProxy::processKeyRelease(Qz::ObjectName type, QObject* obj, QKeyEvent* event) 0194 { 0195 bool accepted = false; 0196 0197 for (PluginInterface* iPlugin : std::as_const(m_keyReleaseHandlers)) { 0198 if (iPlugin->keyRelease(type, obj, event)) { 0199 accepted = true; 0200 } 0201 } 0202 0203 return accepted; 0204 } 0205 0206 bool PluginProxy::acceptNavigationRequest(WebPage *page, const QUrl &url, QWebEnginePage::NavigationType type, bool isMainFrame) 0207 { 0208 bool accepted = true; 0209 0210 for (PluginInterface* iPlugin : std::as_const(m_loadedPlugins)) { 0211 if (!iPlugin->acceptNavigationRequest(page, url, type, isMainFrame)) { 0212 accepted = false; 0213 } 0214 } 0215 0216 return accepted; 0217 } 0218 0219 void PluginProxy::emitWebPageCreated(WebPage* page) 0220 { 0221 Q_EMIT webPageCreated(page); 0222 } 0223 0224 void PluginProxy::emitWebPageDeleted(WebPage* page) 0225 { 0226 Q_EMIT webPageDeleted(page); 0227 } 0228 0229 void PluginProxy::emitMainWindowCreated(BrowserWindow* window) 0230 { 0231 Q_EMIT mainWindowCreated(window); 0232 } 0233 0234 void PluginProxy::emitMainWindowDeleted(BrowserWindow* window) 0235 { 0236 Q_EMIT mainWindowDeleted(window); 0237 }