Falkon
Develop
Cross-platform Qt-based web browser
framescroller.cpp
Go to the documentation of this file.
1
/* ============================================================
2
* AutoScroll - Autoscroll for Falkon
3
* Copyright (C) 2014 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 "
framescroller.h
"
19
#include "
webpage.h
"
20
21
#include <QTimer>
22
#include <QtMath>
23
24
FrameScroller::FrameScroller
(QObject* parent)
25
: QObject(parent)
26
, m_page(nullptr)
27
, m_lengthX(0)
28
, m_lengthY(0)
29
, m_divider(8.0)
30
{
31
m_timer =
new
QTimer(
this
);
32
m_timer->setInterval(10);
33
connect(m_timer, &QTimer::timeout,
this
, &FrameScroller::scrollStep);
34
}
35
36
void
FrameScroller::setPage
(
WebPage
*page)
37
{
38
m_page = page;
39
}
40
41
double
FrameScroller::scrollDivider
()
const
42
{
43
return
m_divider;
44
}
45
46
void
FrameScroller::setScrollDivider
(
double
divider)
47
{
48
m_divider = divider;
49
}
50
51
void
FrameScroller::startScrolling
(
int
lengthX,
int
lengthY)
52
{
53
m_lengthX = lengthX;
54
m_lengthY = lengthY;
55
56
if
(m_lengthX == 0 && m_lengthY == 0) {
57
m_timer->stop();
58
}
59
else
if
(!m_timer->isActive()) {
60
m_timer->start();
61
}
62
}
63
64
void
FrameScroller::stopScrolling
()
65
{
66
m_timer->stop();
67
}
68
69
void
FrameScroller::scrollStep()
70
{
71
m_page->
scroll
(qCeil(m_lengthX / m_divider), qCeil(m_lengthY / m_divider));
72
}
FrameScroller::stopScrolling
void stopScrolling()
Definition:
framescroller.cpp:64
FrameScroller::scrollDivider
double scrollDivider() const
Definition:
framescroller.cpp:41
FrameScroller::FrameScroller
FrameScroller(QObject *parent=nullptr)
Definition:
framescroller.cpp:24
FrameScroller::setScrollDivider
void setScrollDivider(double divider)
Definition:
framescroller.cpp:46
FrameScroller::setPage
void setPage(WebPage *page)
Definition:
framescroller.cpp:36
FrameScroller::startScrolling
void startScrolling(int lengthX, int lengthY)
Definition:
framescroller.cpp:51
WebPage
Definition:
webpage.h:39
WebPage::scroll
void scroll(int x, int y)
Definition:
webpage.cpp:194
framescroller.h
webpage.h
src
plugins
AutoScroll
framescroller.cpp
Generated by
1.9.3