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
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
37{
38 m_page = page;
39}
40
42{
43 return m_divider;
44}
45
47{
48 m_divider = divider;
49}
50
51void 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
65{
66 m_timer->stop();
67}
68
69void FrameScroller::scrollStep()
70{
71 m_page->scroll(qCeil(m_lengthX / m_divider), qCeil(m_lengthY / m_divider));
72}
void stopScrolling()
double scrollDivider() const
FrameScroller(QObject *parent=nullptr)
void setScrollDivider(double divider)
void setPage(WebPage *page)
void startScrolling(int lengthX, int lengthY)
void scroll(int x, int y)
Definition: webpage.cpp:194