mirror of
https://invent.kde.org/network/falkon.git
synced 2024-11-11 01:22:10 +01:00
[AutoScroll] Added settings - option to change scroll divider value
This commit is contained in:
parent
65a47fd450
commit
1f7628ff05
|
@ -4,12 +4,17 @@ os2: TARGET = AutoScrl
|
|||
|
||||
SOURCES += autoscrollplugin.cpp \
|
||||
autoscroller.cpp \
|
||||
framescroller.cpp
|
||||
framescroller.cpp \
|
||||
autoscrollsettings.cpp
|
||||
|
||||
HEADERS += autoscrollplugin.h \
|
||||
autoscroller.h \
|
||||
framescroller.h
|
||||
framescroller.h \
|
||||
autoscrollsettings.h
|
||||
|
||||
RESOURCES += autoscroll.qrc
|
||||
|
||||
include(../../plugins.pri)
|
||||
|
||||
FORMS += \
|
||||
autoscrollsettings.ui
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* ============================================================
|
||||
* QupZilla - WebKit based browser
|
||||
* AutoScroll - Autoscroll for QupZilla
|
||||
* Copyright (C) 2014 David Rosca <nowrep@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
@ -22,21 +22,27 @@
|
|||
|
||||
#include <QMouseEvent>
|
||||
#include <QWebFrame>
|
||||
#include <QSettings>
|
||||
#include <QLabel>
|
||||
#include <QDebug>
|
||||
|
||||
AutoScroller::AutoScroller(const QString &settings, QObject* parent)
|
||||
AutoScroller::AutoScroller(const QString &settingsFile, QObject* parent)
|
||||
: QObject(parent)
|
||||
, m_view(0)
|
||||
, m_settingsFile(settingsFile)
|
||||
{
|
||||
Q_UNUSED(settings)
|
||||
|
||||
m_indicator = new QLabel;
|
||||
m_indicator->resize(32, 32);
|
||||
m_indicator->setContentsMargins(0, 0, 0, 0);
|
||||
m_indicator->installEventFilter(this);
|
||||
|
||||
QSettings settings(m_settingsFile, QSettings::IniFormat);
|
||||
settings.beginGroup("AutoScroll");
|
||||
|
||||
m_frameScroller = new FrameScroller(this);
|
||||
m_frameScroller->setScrollDivider(settings.value("ScrollDivider", 8.0).toDouble());
|
||||
|
||||
settings.endGroup();
|
||||
}
|
||||
|
||||
bool AutoScroller::mouseMove(QObject* obj, QMouseEvent* event)
|
||||
|
@ -104,6 +110,21 @@ bool AutoScroller::mouseRelease(QObject* obj, QMouseEvent* event)
|
|||
return false;
|
||||
}
|
||||
|
||||
double AutoScroller::scrollDivider() const
|
||||
{
|
||||
return m_frameScroller->scrollDivider();
|
||||
}
|
||||
|
||||
void AutoScroller::setScrollDivider(double divider)
|
||||
{
|
||||
QSettings settings(m_settingsFile, QSettings::IniFormat);
|
||||
settings.beginGroup("AutoScroll");
|
||||
settings.setValue("ScrollDivider", divider);
|
||||
settings.endGroup();
|
||||
|
||||
m_frameScroller->setScrollDivider(divider);
|
||||
}
|
||||
|
||||
bool AutoScroller::eventFilter(QObject* obj, QEvent* event)
|
||||
{
|
||||
if (obj == m_indicator) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* ============================================================
|
||||
* QupZilla - WebKit based browser
|
||||
* AutoScroll - Autoscroll for QupZilla
|
||||
* Copyright (C) 2014 David Rosca <nowrep@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
@ -32,12 +32,15 @@ class AutoScroller : public QObject
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit AutoScroller(const QString &settings, QObject* parent = 0);
|
||||
explicit AutoScroller(const QString &settingsFile, QObject* parent = 0);
|
||||
|
||||
bool mouseMove(QObject* obj, QMouseEvent* event);
|
||||
bool mousePress(QObject* obj, QMouseEvent* event);
|
||||
bool mouseRelease(QObject* obj, QMouseEvent* event);
|
||||
|
||||
double scrollDivider() const;
|
||||
void setScrollDivider(double divider);
|
||||
|
||||
private:
|
||||
bool eventFilter(QObject* obj, QEvent* event);
|
||||
|
||||
|
@ -49,6 +52,7 @@ private:
|
|||
WebView* m_view;
|
||||
QLabel* m_indicator;
|
||||
FrameScroller* m_frameScroller;
|
||||
QString m_settingsFile;
|
||||
};
|
||||
|
||||
#endif // AUTOSCROLLER_H
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* ============================================================
|
||||
* QupZilla - WebKit based browser
|
||||
* AutoScroll - Autoscroll for QupZilla
|
||||
* Copyright (C) 2014 David Rosca <nowrep@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
@ -16,6 +16,7 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* ============================================================ */
|
||||
#include "autoscrollplugin.h"
|
||||
#include "autoscrollsettings.h"
|
||||
#include "autoscroller.h"
|
||||
#include "qupzilla.h"
|
||||
#include "pluginproxy.h"
|
||||
|
@ -35,10 +36,10 @@ PluginSpec AutoScrollPlugin::pluginSpec()
|
|||
spec.name = "AutoScroll";
|
||||
spec.info = "AutoScroll plugin";
|
||||
spec.description = "Provides support for autoscroll with middle mouse button";
|
||||
spec.version = "0.1.1";
|
||||
spec.version = "0.1.2";
|
||||
spec.author = "David Rosca <nowrep@gmail.com>";
|
||||
spec.icon = QPixmap(":/autoscroll/data/icon.png");
|
||||
spec.hasSettings = false;
|
||||
spec.icon = QPixmap(":/autoscroll/data/scroll_all.png");
|
||||
spec.hasSettings = true;
|
||||
|
||||
return spec;
|
||||
}
|
||||
|
@ -47,7 +48,7 @@ void AutoScrollPlugin::init(InitState state, const QString &settingsPath)
|
|||
{
|
||||
Q_UNUSED(state)
|
||||
|
||||
m_scroller = new AutoScroller(settingsPath, this);
|
||||
m_scroller = new AutoScroller(settingsPath + QLatin1String("extensions.ini"), this);
|
||||
|
||||
QZ_REGISTER_EVENT_HANDLER(PluginProxy::MouseMoveHandler);
|
||||
QZ_REGISTER_EVENT_HANDLER(PluginProxy::MousePressHandler);
|
||||
|
@ -71,6 +72,16 @@ QTranslator* AutoScrollPlugin::getTranslator(const QString &locale)
|
|||
return translator;
|
||||
}
|
||||
|
||||
void AutoScrollPlugin::showSettings(QWidget* parent)
|
||||
{
|
||||
if (!m_settings) {
|
||||
m_settings = new AutoScrollSettings(m_scroller, parent);
|
||||
}
|
||||
|
||||
m_settings.data()->show();
|
||||
m_settings.data()->raise();
|
||||
}
|
||||
|
||||
bool AutoScrollPlugin::mouseMove(const Qz::ObjectName &type, QObject* obj, QMouseEvent* event)
|
||||
{
|
||||
if (type == Qz::ON_WebView) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* ============================================================
|
||||
* QupZilla - WebKit based browser
|
||||
* AutoScroll - Autoscroll for QupZilla
|
||||
* Copyright (C) 2014 David Rosca <nowrep@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
@ -21,6 +21,7 @@
|
|||
#include "plugininterface.h"
|
||||
|
||||
class AutoScroller;
|
||||
class AutoScrollSettings;
|
||||
|
||||
class AutoScrollPlugin : public QObject, public PluginInterface
|
||||
{
|
||||
|
@ -40,6 +41,7 @@ public:
|
|||
bool testPlugin();
|
||||
|
||||
QTranslator* getTranslator(const QString &locale);
|
||||
void showSettings(QWidget* parent);
|
||||
|
||||
bool mouseMove(const Qz::ObjectName &type, QObject* obj, QMouseEvent* event);
|
||||
bool mousePress(const Qz::ObjectName &type, QObject* obj, QMouseEvent* event);
|
||||
|
@ -47,6 +49,7 @@ public:
|
|||
|
||||
private:
|
||||
AutoScroller* m_scroller;
|
||||
QPointer<AutoScrollSettings> m_settings;
|
||||
};
|
||||
|
||||
#endif // TESTPLUGIN_H
|
||||
|
|
44
src/plugins/AutoScroll/autoscrollsettings.cpp
Normal file
44
src/plugins/AutoScroll/autoscrollsettings.cpp
Normal file
|
@ -0,0 +1,44 @@
|
|||
/* ============================================================
|
||||
* AutoScroll - Autoscroll for QupZilla
|
||||
* Copyright (C) 2014 David Rosca <nowrep@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* ============================================================ */
|
||||
#include "autoscrollsettings.h"
|
||||
#include "ui_autoscrollsettings.h"
|
||||
#include "autoscroller.h"
|
||||
|
||||
AutoScrollSettings::AutoScrollSettings(AutoScroller* scroller, QWidget* parent)
|
||||
: QDialog(parent)
|
||||
, ui(new Ui::AutoScrollSettings)
|
||||
, m_scroller(scroller)
|
||||
{
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
ui->setupUi(this);
|
||||
ui->divider->setValue(m_scroller->scrollDivider());
|
||||
|
||||
connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(accepted()));
|
||||
connect(ui->buttonBox, SIGNAL(rejected()), this, SLOT(close()));
|
||||
}
|
||||
|
||||
AutoScrollSettings::~AutoScrollSettings()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void AutoScrollSettings::accepted()
|
||||
{
|
||||
m_scroller->setScrollDivider(ui->divider->value());
|
||||
close();
|
||||
}
|
46
src/plugins/AutoScroll/autoscrollsettings.h
Normal file
46
src/plugins/AutoScroll/autoscrollsettings.h
Normal file
|
@ -0,0 +1,46 @@
|
|||
/* ============================================================
|
||||
* AutoScroll - Autoscroll for QupZilla
|
||||
* Copyright (C) 2014 David Rosca <nowrep@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* ============================================================ */
|
||||
#ifndef AUTOSCROLLSETTINGS_H
|
||||
#define AUTOSCROLLSETTINGS_H
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class AutoScrollSettings;
|
||||
}
|
||||
|
||||
class AutoScroller;
|
||||
|
||||
class AutoScrollSettings : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit AutoScrollSettings(AutoScroller* scroller, QWidget* parent = 0);
|
||||
~AutoScrollSettings();
|
||||
|
||||
private slots:
|
||||
void accepted();
|
||||
|
||||
private:
|
||||
Ui::AutoScrollSettings* ui;
|
||||
AutoScroller* m_scroller;
|
||||
};
|
||||
|
||||
#endif // AUTOSCROLLSETTINGS_H
|
154
src/plugins/AutoScroll/autoscrollsettings.ui
Normal file
154
src/plugins/AutoScroll/autoscrollsettings.ui
Normal file
|
@ -0,0 +1,154 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>AutoScrollSettings</class>
|
||||
<widget class="QDialog" name="AutoScrollSettings">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>411</width>
|
||||
<height>179</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="pixmap">
|
||||
<pixmap resource="autoscroll.qrc">:/autoscroll/data/scroll_all.png</pixmap>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string><h1>AutoScroll</h1></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_5">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Scroll Divider:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDoubleSpinBox" name="divider"/>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_6">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string><b>Note:</b> Setting higher divider will slow down scrolling</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="autoscroll.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
|
@ -1,5 +1,5 @@
|
|||
/* ============================================================
|
||||
* QupZilla - WebKit based browser
|
||||
* AutoScroll - Autoscroll for QupZilla
|
||||
* Copyright (C) 2014 David Rosca <nowrep@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
@ -26,6 +26,7 @@ FrameScroller::FrameScroller(QObject* parent)
|
|||
, m_frame(0)
|
||||
, m_lengthX(0)
|
||||
, m_lengthY(0)
|
||||
, m_divider(8.0)
|
||||
{
|
||||
m_timer = new QTimer(this);
|
||||
m_timer->setInterval(10);
|
||||
|
@ -37,6 +38,16 @@ void FrameScroller::setFrame(QWebFrame* frame)
|
|||
m_frame = frame;
|
||||
}
|
||||
|
||||
double FrameScroller::scrollDivider() const
|
||||
{
|
||||
return m_divider;
|
||||
}
|
||||
|
||||
void FrameScroller::setScrollDivider(double divider)
|
||||
{
|
||||
m_divider = divider;
|
||||
}
|
||||
|
||||
void FrameScroller::startScrolling(int lengthX, int lengthY)
|
||||
{
|
||||
Q_ASSERT(m_frame);
|
||||
|
@ -59,5 +70,5 @@ void FrameScroller::stopScrolling()
|
|||
|
||||
void FrameScroller::scrollStep()
|
||||
{
|
||||
m_frame->scroll(qCeil(m_lengthX / 8.0), qCeil(m_lengthY / 8.0));
|
||||
m_frame->scroll(qCeil(m_lengthX / m_divider), qCeil(m_lengthY / m_divider));
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* ============================================================
|
||||
* QupZilla - WebKit based browser
|
||||
* AutoScroll - Autoscroll for QupZilla
|
||||
* Copyright (C) 2014 David Rosca <nowrep@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
@ -32,6 +32,9 @@ public:
|
|||
|
||||
void setFrame(QWebFrame* frame);
|
||||
|
||||
double scrollDivider() const;
|
||||
void setScrollDivider(double divider);
|
||||
|
||||
void startScrolling(int lengthX, int lengthY);
|
||||
void stopScrolling();
|
||||
|
||||
|
@ -44,6 +47,7 @@ private:
|
|||
|
||||
int m_lengthX;
|
||||
int m_lengthY;
|
||||
double m_divider;
|
||||
};
|
||||
|
||||
#endif // FRAMESCROLLER_H
|
||||
|
|
Loading…
Reference in New Issue
Block a user