Falkon Develop
Cross-platform Qt-based web browser
autoscrollplugin.cpp
Go to the documentation of this file.
1/* ============================================================
2* AutoScroll - Autoscroll for Falkon
3* Copyright (C) 2014-2017 David Rosca <nowrep@gmail.com>
4*
5* This program is free software: you can redistribute it and/or modify
6* it under the terms of the GNU General Public License as published by
7* the Free Software Foundation, either version 3 of the License, or
8* (at your option) any later version.
9*
10* This program is distributed in the hope that it will be useful,
11* but WITHOUT ANY WARRANTY; without even the implied warranty of
12* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13* GNU General Public License for more details.
14*
15* You should have received a copy of the GNU General Public License
16* along with this program. If not, see <http://www.gnu.org/licenses/>.
17* ============================================================ */
18#include "autoscrollplugin.h"
19#include "autoscrollsettings.h"
20#include "autoscroller.h"
21#include "browserwindow.h"
22#include "pluginproxy.h"
23#include "mainapplication.h"
24#include "../config.h"
25
27 : QObject()
28 , m_scroller(nullptr)
29{
30}
31
32void AutoScrollPlugin::init(InitState state, const QString &settingsPath)
33{
34 Q_UNUSED(state)
35
36 m_scroller = new AutoScroller(settingsPath + QL1S("/extensions.ini"), this);
37
38 mApp->plugins()->registerAppEventHandler(PluginProxy::MouseMoveHandler, this);
39 mApp->plugins()->registerAppEventHandler(PluginProxy::MousePressHandler, this);
40 mApp->plugins()->registerAppEventHandler(PluginProxy::MouseReleaseHandler, this);
41 mApp->plugins()->registerAppEventHandler(PluginProxy::WheelEventHandler, this);
42}
43
45{
46 m_scroller->deleteLater();
47}
48
50{
51 // Require the version that the plugin was built with
52 return (QString::fromLatin1(Qz::VERSION) == QLatin1String(FALKON_VERSION));
53}
54
55void AutoScrollPlugin::showSettings(QWidget* parent)
56{
57 if (!m_settings) {
58 m_settings = new AutoScrollSettings(m_scroller, parent);
59 }
60
61 m_settings.data()->show();
62 m_settings.data()->raise();
63}
64
65bool AutoScrollPlugin::mouseMove(Qz::ObjectName type, QObject* obj, QMouseEvent* event)
66{
67 if (type == Qz::ON_WebView) {
68 return m_scroller->mouseMove(obj, event);
69 }
70
71 return false;
72}
73
74bool AutoScrollPlugin::mousePress(Qz::ObjectName type, QObject* obj, QMouseEvent* event)
75{
76 if (type == Qz::ON_WebView) {
77 return m_scroller->mousePress(obj, event);
78 }
79
80 return false;
81}
82
83bool AutoScrollPlugin::mouseRelease(Qz::ObjectName type, QObject* obj, QMouseEvent* event)
84{
85 if (type == Qz::ON_WebView) {
86 return m_scroller->mouseRelease(obj, event);
87 }
88
89 return false;
90}
91
92bool AutoScrollPlugin::wheelEvent(Qz::ObjectName type, QObject *obj, QWheelEvent *event)
93{
94 if (type == Qz::ON_WebView) {
95 return m_scroller->wheel(obj, event);
96 }
97
98 return false;
99}
bool mouseMove(Qz::ObjectName type, QObject *obj, QMouseEvent *event) override
bool wheelEvent(Qz::ObjectName type, QObject *obj, QWheelEvent *event) override
void unload() override
void showSettings(QWidget *parent) override
bool mousePress(Qz::ObjectName type, QObject *obj, QMouseEvent *event) override
void init(InitState state, const QString &settingsPath) override
bool testPlugin() override
bool mouseRelease(Qz::ObjectName type, QObject *obj, QMouseEvent *event) override
bool mousePress(QObject *obj, QMouseEvent *event)
bool mouseMove(QObject *obj, QMouseEvent *event)
bool wheel(QObject *obj, QWheelEvent *event)
bool mouseRelease(QObject *obj, QMouseEvent *event)
@ WheelEventHandler
Definition: pluginproxy.h:35
@ MouseReleaseHandler
Definition: pluginproxy.h:33
@ MouseMoveHandler
Definition: pluginproxy.h:34
@ MousePressHandler
Definition: pluginproxy.h:33
#define mApp
ObjectName
Definition: qzcommon.h:89
@ ON_WebView
Definition: qzcommon.h:90
FALKON_EXPORT const char * VERSION
Definition: qzcommon.cpp:26
State state
#define QL1S(x)
Definition: qzcommon.h:44