File indexing completed on 2024-05-12 04:58:17

0001 /* ============================================================
0002 * Falkon - Qt web browser
0003 * Copyright (C) 2010-2016 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 #ifndef PLUGININTERFACE_H
0019 #define PLUGININTERFACE_H
0020 
0021 #include <QtPlugin>
0022 #include <QWebEnginePage>
0023 
0024 #include "qzcommon.h"
0025 #include "webhittestresult.h"
0026 
0027 class QMenu;
0028 class QMouseEvent;
0029 class QKeyEvent;
0030 class QWheelEvent;
0031 
0032 class WebView;
0033 class WebPage;
0034 class DesktopFile;
0035 
0036 class PluginInterface
0037 {
0038 public:
0039     enum InitState {
0040         StartupInitState,
0041         LateInitState
0042     };
0043 
0044     virtual ~PluginInterface() = default;
0045 
0046     virtual void init(InitState state, const QString &settingsPath) = 0;
0047     virtual void unload() = 0;
0048     virtual bool testPlugin() = 0;
0049 
0050     virtual void showSettings(QWidget* parent = nullptr) { Q_UNUSED(parent) }
0051 
0052     virtual void populateWebViewMenu(QMenu* menu, WebView* view, const WebHitTestResult &r) { Q_UNUSED(menu) Q_UNUSED(view) Q_UNUSED(r) }
0053     virtual void populateExtensionsMenu(QMenu *menu) { Q_UNUSED(menu) }
0054 
0055     virtual bool mouseDoubleClick(Qz::ObjectName type, QObject* obj, QMouseEvent* event) { Q_UNUSED(type) Q_UNUSED(obj) Q_UNUSED(event) return false; }
0056     virtual bool mousePress(Qz::ObjectName type, QObject* obj, QMouseEvent* event) { Q_UNUSED(type) Q_UNUSED(obj) Q_UNUSED(event) return false; }
0057     virtual bool mouseRelease(Qz::ObjectName type, QObject* obj, QMouseEvent* event) { Q_UNUSED(type) Q_UNUSED(obj) Q_UNUSED(event) return false; }
0058     virtual bool mouseMove(Qz::ObjectName type, QObject* obj, QMouseEvent* event) { Q_UNUSED(type) Q_UNUSED(obj) Q_UNUSED(event) return false; }
0059 
0060     virtual bool wheelEvent(Qz::ObjectName type, QObject* obj, QWheelEvent* event) { Q_UNUSED(type) Q_UNUSED(obj) Q_UNUSED(event) return false; }
0061 
0062     virtual bool keyPress(Qz::ObjectName type, QObject* obj, QKeyEvent* event) { Q_UNUSED(type) Q_UNUSED(obj) Q_UNUSED(event) return false; }
0063     virtual bool keyRelease(Qz::ObjectName type, QObject* obj, QKeyEvent* event) { Q_UNUSED(type) Q_UNUSED(obj) Q_UNUSED(event) return false; }
0064 
0065     virtual bool acceptNavigationRequest(WebPage *page, const QUrl &url, QWebEnginePage::NavigationType type, bool isMainFrame) { Q_UNUSED(page); Q_UNUSED(url); Q_UNUSED(type); Q_UNUSED(isMainFrame); return true; }
0066 };
0067 
0068 Q_DECLARE_INTERFACE(PluginInterface, "Falkon.Browser.PluginInterface/2.4")
0069 
0070 #endif // PLUGININTERFACE_H