Falkon Develop
Cross-platform Qt-based web browser
autoscroller.h
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#ifndef AUTOSCROLLER_H
19#define AUTOSCROLLER_H
20
21#include <QObject>
22#include <QLabel>
23
24class QMouseEvent;
25class QWheelEvent;
26class QRect;
27
28class WebView;
29class FrameScroller;
30
31class ScrollIndicator : public QLabel
32{
33public:
34 explicit ScrollIndicator(QWidget *parent = nullptr);
35
36 Qt::Orientations orientations() const;
37 void setOrientations(Qt::Orientations orientations);
38
39private:
40 void paintEvent(QPaintEvent *event) override;
41
42 Qt::Orientations m_orientations;
43};
44
45class AutoScroller : public QObject
46{
47 Q_OBJECT
48public:
49 explicit AutoScroller(const QString &settingsFile, QObject* parent = nullptr);
50 ~AutoScroller() override;
51
52 bool mouseMove(QObject* obj, QMouseEvent* event);
53 bool mousePress(QObject* obj, QMouseEvent* event);
54 bool mouseRelease(QObject* obj, QMouseEvent* event);
55 bool wheel(QObject* obj, QWheelEvent *event);
56
57 double scrollDivider() const;
58 void setScrollDivider(double divider);
59
60private:
61 bool eventFilter(QObject* obj, QEvent* event) override;
62
63 bool showIndicator(WebView* view, const QPoint &pos);
64 void stopScrolling();
65
66 QRect indicatorGlobalRect() const;
67
68 WebView* m_view;
69 ScrollIndicator* m_indicator;
70 FrameScroller* m_frameScroller;
71 QString m_settingsFile;
72};
73
74#endif // AUTOSCROLLER_H
~AutoScroller() override
bool mousePress(QObject *obj, QMouseEvent *event)
bool mouseMove(QObject *obj, QMouseEvent *event)
void setScrollDivider(double divider)
double scrollDivider() const
bool wheel(QObject *obj, QWheelEvent *event)
AutoScroller(const QString &settingsFile, QObject *parent=nullptr)
bool mouseRelease(QObject *obj, QMouseEvent *event)
Qt::Orientations orientations() const
ScrollIndicator(QWidget *parent=nullptr)
void setOrientations(Qt::Orientations orientations)