File indexing completed on 2024-05-19 04:59:18
0001 /* ============================================================ 0002 * Mouse Gestures plugin for Falkon 0003 * Copyright (C) 2012-2014 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 "mousegesturesplugin.h" 0019 #include "pluginproxy.h" 0020 #include "mousegestures.h" 0021 #include "mainapplication.h" 0022 #include "browserwindow.h" 0023 #include "../config.h" 0024 0025 MouseGesturesPlugin::MouseGesturesPlugin() 0026 : QObject() 0027 { 0028 } 0029 0030 void MouseGesturesPlugin::init(InitState state, const QString &settingsPath) 0031 { 0032 Q_UNUSED(state) 0033 0034 m_gestures = new MouseGestures(settingsPath, this); 0035 0036 mApp->plugins()->registerAppEventHandler(PluginProxy::MousePressHandler, this); 0037 mApp->plugins()->registerAppEventHandler(PluginProxy::MouseReleaseHandler, this); 0038 mApp->plugins()->registerAppEventHandler(PluginProxy::MouseMoveHandler, this); 0039 } 0040 0041 void MouseGesturesPlugin::unload() 0042 { 0043 m_gestures->unloadPlugin(); 0044 m_gestures->deleteLater(); 0045 } 0046 0047 bool MouseGesturesPlugin::testPlugin() 0048 { 0049 // Require the version that the plugin was built with 0050 return (QString::fromLatin1(Qz::VERSION) == QLatin1String(FALKON_VERSION)); 0051 } 0052 0053 void MouseGesturesPlugin::showSettings(QWidget* parent) 0054 { 0055 m_gestures->showSettings(parent); 0056 } 0057 0058 bool MouseGesturesPlugin::mousePress(Qz::ObjectName type, QObject* obj, QMouseEvent* event) 0059 { 0060 if (type == Qz::ON_WebView) { 0061 m_gestures->mousePress(obj, event); 0062 } 0063 0064 return false; 0065 } 0066 0067 bool MouseGesturesPlugin::mouseRelease(Qz::ObjectName type, QObject* obj, QMouseEvent* event) 0068 { 0069 if (type == Qz::ON_WebView) { 0070 return m_gestures->mouseRelease(obj, event); 0071 } 0072 0073 return false; 0074 } 0075 0076 bool MouseGesturesPlugin::mouseMove(Qz::ObjectName type, QObject* obj, QMouseEvent* event) 0077 { 0078 if (type == Qz::ON_WebView) { 0079 m_gestures->mouseMove(obj, event); 0080 } 0081 0082 return false; 0083 }