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
26
AutoScrollPlugin::AutoScrollPlugin
()
27
: QObject()
28
, m_scroller(nullptr)
29
{
30
}
31
32
void
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
44
void
AutoScrollPlugin::unload
()
45
{
46
m_scroller->deleteLater();
47
}
48
49
bool
AutoScrollPlugin::testPlugin
()
50
{
51
// Require the version that the plugin was built with
52
return
(QString::fromLatin1(
Qz::VERSION
) == QLatin1String(FALKON_VERSION));
53
}
54
55
void
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
65
bool
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
74
bool
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
83
bool
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
92
bool
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
}
autoscroller.h
autoscrollplugin.h
autoscrollsettings.h
browserwindow.h
AutoScrollPlugin::mouseMove
bool mouseMove(Qz::ObjectName type, QObject *obj, QMouseEvent *event) override
Definition:
autoscrollplugin.cpp:65
AutoScrollPlugin::wheelEvent
bool wheelEvent(Qz::ObjectName type, QObject *obj, QWheelEvent *event) override
Definition:
autoscrollplugin.cpp:92
AutoScrollPlugin::unload
void unload() override
Definition:
autoscrollplugin.cpp:44
AutoScrollPlugin::showSettings
void showSettings(QWidget *parent) override
Definition:
autoscrollplugin.cpp:55
AutoScrollPlugin::mousePress
bool mousePress(Qz::ObjectName type, QObject *obj, QMouseEvent *event) override
Definition:
autoscrollplugin.cpp:74
AutoScrollPlugin::init
void init(InitState state, const QString &settingsPath) override
Definition:
autoscrollplugin.cpp:32
AutoScrollPlugin::testPlugin
bool testPlugin() override
Definition:
autoscrollplugin.cpp:49
AutoScrollPlugin::AutoScrollPlugin
AutoScrollPlugin()
Definition:
autoscrollplugin.cpp:26
AutoScrollPlugin::mouseRelease
bool mouseRelease(Qz::ObjectName type, QObject *obj, QMouseEvent *event) override
Definition:
autoscrollplugin.cpp:83
AutoScrollSettings
Definition:
autoscrollsettings.h:31
AutoScroller
Definition:
autoscroller.h:46
AutoScroller::mousePress
bool mousePress(QObject *obj, QMouseEvent *event)
Definition:
autoscroller.cpp:132
AutoScroller::mouseMove
bool mouseMove(QObject *obj, QMouseEvent *event)
Definition:
autoscroller.cpp:104
AutoScroller::wheel
bool wheel(QObject *obj, QWheelEvent *event)
Definition:
autoscroller.cpp:169
AutoScroller::mouseRelease
bool mouseRelease(QObject *obj, QMouseEvent *event)
Definition:
autoscroller.cpp:155
PluginInterface::InitState
InitState
Definition:
plugininterface.h:39
PluginProxy::WheelEventHandler
@ WheelEventHandler
Definition:
pluginproxy.h:35
PluginProxy::MouseReleaseHandler
@ MouseReleaseHandler
Definition:
pluginproxy.h:33
PluginProxy::MouseMoveHandler
@ MouseMoveHandler
Definition:
pluginproxy.h:34
PluginProxy::MousePressHandler
@ MousePressHandler
Definition:
pluginproxy.h:33
mainapplication.h
mApp
#define mApp
Definition:
mainapplication.h:21
Qz::ObjectName
ObjectName
Definition:
qzcommon.h:89
Qz::ON_WebView
@ ON_WebView
Definition:
qzcommon.h:90
Qz::VERSION
FALKON_EXPORT const char * VERSION
Definition:
qzcommon.cpp:26
pluginproxy.h
state
State state
Definition:
pythonplugin.cpp:37
QL1S
#define QL1S(x)
Definition:
qzcommon.h:44
src
plugins
AutoScroll
autoscrollplugin.cpp
Generated by
1.9.3