1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 10:46:35 +01:00

Added new plugin: Mouse Gestures.

- setting building plugins as default now
- closes #255
This commit is contained in:
nowrep 2012-02-24 21:03:44 +01:00
parent 49a177d67a
commit af7a041714
61 changed files with 2308 additions and 102 deletions

View File

@ -18,17 +18,6 @@ General
QupZilla requires Qt (>=4.7.0) and QtWebKit (at least version included in Qt 4.7) QupZilla requires Qt (>=4.7.0) and QtWebKit (at least version included in Qt 4.7)
Building plugins
----------------------------------------------------------------------------------
To build plugins, it is neccessary to build QupZilla as static library first.
You can do this by running this command
qmake CONFIG+=build_plugins
and then build the project.
You will now have the libqupzilla.a static library that you need to link to plugins.
Microsoft Windows Microsoft Windows
---------------------------------------------------------------------------------- ----------------------------------------------------------------------------------

View File

@ -11,7 +11,7 @@ function format_sources {
--align-pointer=type --align-reference=name \ --align-pointer=type --align-reference=name \
`find -type f -name '*.cpp'` `find -type f -name '*.cpp'`
rm */*.orig find . -name "*.orig" -print0 | xargs -0 rm -rf
} }
function format_headers { function format_headers {
@ -22,7 +22,7 @@ function format_headers {
--align-pointer=type --align-reference=name \ --align-pointer=type --align-reference=name \
`find -type f -name '*.h'` `find -type f -name '*.h'`
rm */*.orig find . -name "*.orig" -print0 | xargs -0 rm -rf
} }
cd ../src cd ../src

View File

@ -13,7 +13,13 @@ function check_code {
echo "cppcheck..." echo "cppcheck..."
cd ../src cd ../src/plugins
check_code
cd ../lib/
check_code
cd ../main
check_code check_code
read -p "Press [ENTER] to close terminal" read -p "Press [ENTER] to close terminal"

View File

@ -2,5 +2,7 @@
lupdate ../src/plugins/TestPlugin/TestPlugin.pro -no-obsolete lupdate ../src/plugins/TestPlugin/TestPlugin.pro -no-obsolete
lupdate ../src/plugins/MouseGestures/MouseGestures.pro -no-obsolete
read -p "Press [ENTER] to close terminal" read -p "Press [ENTER] to close terminal"
exit exit

View File

@ -3,7 +3,7 @@ OBJECTS_DIR = $$PWD/../build
MOC_DIR = $$PWD/../build MOC_DIR = $$PWD/../build
RCC_DIR = $$PWD/../build RCC_DIR = $$PWD/../build
UI_DIR = $$PWD/../build UI_DIR = $$PWD/../build
VERSION = 1.1.8 unix: VERSION = 1.1.8
# Please read BUILD information # # Please read BUILD information #
#DEFINES += NO_SYSTEM_DATAPATH #DEFINES += NO_SYSTEM_DATAPATH

View File

@ -4,7 +4,7 @@ mac {
bundle_target.files += $$PWD/../bin/locale bundle_target.files += $$PWD/../bin/locale
bundle_target.files += $$PWD/../bin/themes bundle_target.files += $$PWD/../bin/themes
build_plugins: bundle_target.files += $$PWD/../bin/plugins bundle_target.files += $$PWD/../bin/plugins
bundle_target.path = Contents/Resources bundle_target.path = Contents/Resources
QMAKE_BUNDLE_DATA += bundle_target QMAKE_BUNDLE_DATA += bundle_target

View File

@ -531,7 +531,6 @@ void QupZilla::loadSettings()
//Url settings //Url settings
settings.beginGroup("Web-URL-Settings"); settings.beginGroup("Web-URL-Settings");
m_homepage = settings.value("homepage", "qupzilla:start").toUrl(); m_homepage = settings.value("homepage", "qupzilla:start").toUrl();
m_newtab = settings.value("newTabUrl", "qupzilla:speeddial").toUrl();
settings.endGroup(); settings.endGroup();
QWebSettings* websettings = mApp->webSettings(); QWebSettings* websettings = mApp->webSettings();

View File

@ -113,6 +113,7 @@ public:
inline QMenu* superMenu() { return m_superMenu; } inline QMenu* superMenu() { return m_superMenu; }
inline bool isClosing() { return m_isClosing; } inline bool isClosing() { return m_isClosing; }
inline QUrl homepageUrl() { return m_homepage; }
signals: signals:
void loadHistory(); void loadHistory();
@ -221,7 +222,6 @@ private:
bool m_bookmarksMenuChanged; bool m_bookmarksMenuChanged;
bool m_isClosing; bool m_isClosing;
QUrl m_startingUrl; QUrl m_startingUrl;
QUrl m_newtab;
QUrl m_homepage; QUrl m_homepage;
Qz::BrowserWindow m_startBehaviour; Qz::BrowserWindow m_startBehaviour;

View File

@ -36,6 +36,9 @@
<layout class="QVBoxLayout" name="appExtensionFrame"> <layout class="QVBoxLayout" name="appExtensionFrame">
<item> <item>
<widget class="QListWidget" name="list"> <widget class="QListWidget" name="list">
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="uniformItemSizes"> <property name="uniformItemSizes">
<bool>true</bool> <bool>true</bool>
</property> </property>

View File

@ -110,6 +110,11 @@ WebTab* TabbedWebView::webTab() const
return m_webTab; return m_webTab;
} }
TabWidget* TabbedWebView::tabWidget() const
{
return m_tabWidget;
}
QString TabbedWebView::getIp() const QString TabbedWebView::getIp() const
{ {
return m_currentIp; return m_currentIp;
@ -341,6 +346,11 @@ void TabbedWebView::openUrlInNewTab(const QUrl &url, Qz::NewTabPositionFlag posi
m_tabWidget->addView(url, position); m_tabWidget->addView(url, position);
} }
void TabbedWebView::openNewTab()
{
m_tabWidget->addView();
}
void TabbedWebView::getFocus(const QUrl &urla) void TabbedWebView::getFocus(const QUrl &urla)
{ {
if (urla == url()) { if (urla == url()) {

View File

@ -42,6 +42,7 @@ public:
WebPage* webPage() const; WebPage* webPage() const;
WebTab* webTab() const; WebTab* webTab() const;
TabWidget* tabWidget() const;
QString getIp() const; QString getIp() const;
QLabel* animationLoading(int index, bool addMovie); QLabel* animationLoading(int index, bool addMovie);
@ -69,6 +70,8 @@ public slots:
void loadingProgress(int prog); void loadingProgress(int prog);
void closeView(); void closeView();
void openUrlInNewTab(const QUrl &url, Qz::NewTabPositionFlag position);
void openNewTab();
private slots: private slots:
void trackMouse(bool state) { m_mouseTrack = state; } void trackMouse(bool state) { m_mouseTrack = state; }
@ -82,7 +85,6 @@ private slots:
void slotIconChanged(); void slotIconChanged();
void inspectElement(); void inspectElement();
void openUrlInNewTab(const QUrl &url, Qz::NewTabPositionFlag position);
private: private:
void contextMenuEvent(QContextMenuEvent* event); void contextMenuEvent(QContextMenuEvent* event);

View File

@ -359,7 +359,14 @@ void WebView::showSiteInfo()
void WebView::searchSelectedText() void WebView::searchSelectedText()
{ {
const QUrl &urlToLoad = mApp->searchEnginesManager()->searchUrl(selectedText()); SearchEngine engine = mApp->searchEnginesManager()->activeEngine();
if (QAction* act = qobject_cast<QAction*>(sender())) {
if (act->data().isValid()) {
engine = qVariantValue<SearchEngine>(act->data());
}
}
const QUrl &urlToLoad = mApp->searchEnginesManager()->searchUrl(engine, selectedText());
openUrlInNewTab(urlToLoad, Qz::NT_SelectedTab); openUrlInNewTab(urlToLoad, Qz::NT_SelectedTab);
} }

View File

@ -48,7 +48,6 @@ public:
bool eventFilter(QObject* obj, QEvent* event); bool eventFilter(QObject* obj, QEvent* event);
virtual QWidget* overlayForJsAlert() = 0; virtual QWidget* overlayForJsAlert() = 0;
virtual void openUrlInNewTab(const QUrl &url, Qz::NewTabPositionFlag position) = 0;
static bool isUrlValid(const QUrl &url); static bool isUrlValid(const QUrl &url);
static QUrl guessUrlFromString(const QString &string); static QUrl guessUrlFromString(const QString &string);
@ -73,6 +72,8 @@ public slots:
void printPage(QWebFrame* frame = 0); void printPage(QWebFrame* frame = 0);
virtual void closeView() = 0; virtual void closeView() = 0;
virtual void openUrlInNewTab(const QUrl &url, Qz::NewTabPositionFlag position) = 0;
virtual void openNewTab() { }
protected slots: protected slots:
void slotLoadStarted(); void slotLoadStarted();

View File

@ -1,7 +1,7 @@
#include "winver.h" #include "winver.h"
IDI_ICON1 ICON DISCARDABLE "data\icons\exeicons\qupzilla.ico" IDI_ICON1 ICON DISCARDABLE "..\lib\data\icons\exeicons\qupzilla.ico"
IDI_ICON2 ICON DISCARDABLE "data\icons\exeicons\page.ico" IDI_ICON2 ICON DISCARDABLE "..\lib\data\icons\exeicons\page.ico"
VS_VERSION_INFO VERSIONINFO VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,1,8,0 FILEVERSION 1,1,8,0

View File

@ -1,2 +1,2 @@
ICON 1 "data\icons\exeicons\qupzilla_os2.ico" ICON 1 "..\lib\data\icons\exeicons\qupzilla_os2.ico"
ICON 2 "data\icons\exeicons\page_os2.ico" ICON 2 "..\lib\data\icons\exeicons\page_os2.ico"

View File

@ -0,0 +1,57 @@
/*
* This file is part of the mouse gesture package.
* Copyright (C) 2006 Johan Thelin <e8johan@gmail.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the
* following conditions are met:
*
* - Redistributions of source code must retain the above
* copyright notice, this list of conditions and the
* following disclaimer.
* - Redistributions in binary form must reproduce the
* above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or
* other materials provided with the distribution.
* - The names of its contributors may be used to endorse
* or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
#include "QjtMouseGesture.h"
QjtMouseGesture::QjtMouseGesture(const DirectionList &directions, QObject* parent) : QObject(parent)
{
m_directions = directions;
}
QjtMouseGesture::~QjtMouseGesture()
{
}
void QjtMouseGesture::emitGestured()
{
emit(gestured());
}
const DirectionList QjtMouseGesture::directions() const
{
return m_directions;
}

View File

@ -0,0 +1,117 @@
/*
* This file is part of the mouse gesture package.
* Copyright (C) 2006 Johan Thelin <e8johan@gmail.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the
* following conditions are met:
*
* - Redistributions of source code must retain the above
* copyright notice, this list of conditions and the
* following disclaimer.
* - Redistributions in binary form must reproduce the
* above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or
* other materials provided with the distribution.
* - The names of its contributors may be used to endorse
* or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef QJTMOUSEGESTURE_H
#define QJTMOUSEGESTURE_H
#include <QObject>
#include <QList>
#include "mousegesturerecognizer.h"
class GestureCallbackToSignal;
/*
* A Direction can be any of the following:
*
* Up
* Down
* Left
* Right
* AnyHorizontal (Left or Right)
* AnyVertical (Up or Down)
* UpLeft (diagnonal)
* UpRight (diagnonal)
* DownLeft (diagnonal)
* DownRight (diagnonal)
*
* In addition to these, the NoMatch enum is
* available. A gesture holding only the NoMatch
* enum is gestured when no other gesture can be
* matched to the mouse gesture performed.
*/
typedef Gesture::Direction Direction;
using Gesture::Up;
using Gesture::Down;
using Gesture::Left;
using Gesture::Right;
using Gesture::AnyHorizontal;
using Gesture::AnyVertical;
using Gesture::UpLeft;
using Gesture::UpRight;
using Gesture::DownLeft;
using Gesture::DownRight;
using Gesture::NoMatch;
/*
* A list of Directions
*/
typedef QList<Direction> DirectionList;
/*
* A mouse gesture is a list of Directions that
* trigger the gestured signal. Create instances
* and add to a QjtMouseGestureFilter object.
*/
class QjtMouseGesture : public QObject
{
Q_OBJECT
public:
QjtMouseGesture(const DirectionList &directions, QObject* parent = 0);
~QjtMouseGesture();
const DirectionList directions() const;
signals:
void gestured();
private:
friend class GestureCallbackToSignal;
/*
* Emits the gestured signal.
*
* Required to connect this to the toolkit
* independent recognizer in a tidy way.
*/
void emitGestured();
DirectionList m_directions;
};
#endif // QJTMOUSEGESTURE_H

View File

@ -0,0 +1,233 @@
/*
* This file is part of the mouse gesture package.
* Copyright (C) 2006 Johan Thelin <e8johan@gmail.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the
* following conditions are met:
*
* - Redistributions of source code must retain the above
* copyright notice, this list of conditions and the
* following disclaimer.
* - Redistributions in binary form must reproduce the
* above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or
* other materials provided with the distribution.
* - The names of its contributors may be used to endorse
* or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
#include "QjtMouseGestureFilter.h"
#include "QjtMouseGesture.h"
#include <QWidget>
#include <QPainter>
#include <QPixmap>
#include "mousegesturerecognizer.h"
/*
* Internal support class to bridge the
* toolkit independent mouse gesture
* recognizer and the Qt specific
* implementation.
*/
class GestureCallbackToSignal : public Gesture::MouseGestureCallback
{
public:
GestureCallbackToSignal(QjtMouseGesture* object) {
m_object = object;
}
void callback() {
m_object->emitGestured();
}
private:
QjtMouseGesture* m_object;
};
typedef QList<QjtMouseGesture*> GestureList;
typedef QList<GestureCallbackToSignal> BridgeList;
/*
* Private members of the QjtMouseGestureFilter class
*/
class QjtMouseGestureFilter::Private
{
public:
Qt::MouseButton gestureButton;
bool tracing;
Gesture::MouseGestureRecognizer* mgr;
QPixmap px;
GestureList gestures;
BridgeList bridges;
};
/**********************************************************/
QjtMouseGestureFilter::QjtMouseGestureFilter(bool allowDiagonals, Qt::MouseButton gestureButton, int minimumMovement, double minimumMatch, QObject* parent) : QObject(parent)
{
d = new Private;
d->gestureButton = gestureButton;
d->tracing = false;
d->mgr = new Gesture::MouseGestureRecognizer(minimumMovement, minimumMatch, allowDiagonals);
}
QjtMouseGestureFilter::~QjtMouseGestureFilter()
{
delete d->mgr;
delete d;
}
/*
* Converts the DirectionList to a Gesture::DirecionList,
* creates a bridge and adds the gesture to the recognizer.
*/
void QjtMouseGestureFilter::addGesture(QjtMouseGesture* gesture)
{
Gesture::DirectionList dl;
for (DirectionList::const_iterator source = gesture->directions().begin(); source != gesture->directions().end(); ++source) {
dl.push_back(*source);
}
d->bridges.append(GestureCallbackToSignal(gesture));
d->gestures.append(gesture);
d->mgr->addGestureDefinition(Gesture::GestureDefinition(dl, &(d->bridges[ d->bridges.size() - 1 ])));
}
void QjtMouseGestureFilter::clearGestures(bool deleteGestures)
{
if (deleteGestures)
for (GestureList::const_iterator i = d->gestures.begin(); i != d->gestures.end(); ++i) {
delete *i;
}
d->gestures.clear();
d->bridges.clear();
d->mgr->clearGestureDefinitions();
}
bool QjtMouseGestureFilter::eventFilter(QObject* obj, QEvent* event)
{
switch (event->type()) {
case QEvent::MouseButtonPress:
if (mouseButtonPressEvent(dynamic_cast<QMouseEvent*>(event), obj)) {
return true;
}
break;
case QEvent::MouseButtonRelease:
if (mouseButtonReleaseEvent(dynamic_cast<QMouseEvent*>(event), obj)) {
return true;
}
break;
case QEvent::MouseMove:
if (mouseMoveEvent(dynamic_cast<QMouseEvent*>(event), obj)) {
return true;
}
break;
case QEvent::Paint:
if (paintEvent(obj, dynamic_cast<QPaintEvent*>(event))) {
return true;
}
default:
break;
}
return QObject::eventFilter(obj, event);
}
bool QjtMouseGestureFilter::mouseButtonPressEvent(QMouseEvent* event, QObject* obj)
{
Q_UNUSED(obj)
if (event->button() == d->gestureButton) {
// d->px = QPixmap::grabWidget(static_cast<QWidget*>(obj));
d->mgr->startGesture(event->pos().x(), event->pos().y());
d->tracing = true;
}
return false;
}
bool QjtMouseGestureFilter::mouseButtonReleaseEvent(QMouseEvent* event, QObject* obj)
{
Q_UNUSED(obj)
if (d->tracing && event->button() == d->gestureButton) {
d->tracing = false;
return d->mgr->endGesture(event->pos().x(), event->pos().y());
// d->px = QPixmap();
// static_cast<QWidget*>(obj)->update();
}
return false;
}
bool QjtMouseGestureFilter::mouseMoveEvent(QMouseEvent* event, QObject* obj)
{
Q_UNUSED(obj)
if (d->tracing) {
d->mgr->addPoint(event->pos().x(), event->pos().y());
// static_cast<QWidget*>(obj)->update();
}
return false;
}
bool QjtMouseGestureFilter::paintEvent(QObject* obj, QPaintEvent* event)
{
Q_UNUSED(event)
if (d->tracing) {
QWidget* wid = static_cast<QWidget*>(obj);
QPainter painter(wid);
painter.drawPixmap(0, 0, d->px);
const Gesture::PosList &points = d->mgr->currentPath();
painter.save();
QPen pe;
pe.setColor(Qt::red);
pe.setWidth(2);
painter.setPen(pe);
QVector<QPoint> pointPairs;
for (Gesture::PosList::const_iterator iter = points.begin(); iter != points.end(); ++iter) {
pointPairs << QPoint(iter->x, iter->y);
}
painter.setRenderHint(QPainter::Antialiasing, true);
painter.drawPolyline(&pointPairs[0], pointPairs.count());
painter.restore();
painter.end();
return true;
}
else {
return false;
}
}

View File

@ -0,0 +1,94 @@
/*
* This file is part of the mouse gesture package.
* Copyright (C) 2006 Johan Thelin <e8johan@gmail.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the
* following conditions are met:
*
* - Redistributions of source code must retain the above
* copyright notice, this list of conditions and the
* following disclaimer.
* - Redistributions in binary form must reproduce the
* above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or
* other materials provided with the distribution.
* - The names of its contributors may be used to endorse
* or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef QJTMOUSEGESTUREFILTER_H
#define QJTMOUSEGESTUREFILTER_H
#include <QObject>
#include <QEvent>
#include <QMouseEvent>
class QjtMouseGesture;
/*
* The QjtMouseGestureFilter class is a mouse
* gesture recognizing event filter.
*
* Use it by creating it, install it as a filter
* for the affected widget and add QjtMouseGesture
* instances to it.
*
*/
class QjtMouseGestureFilter : public QObject
{
public:
/*
* The gestureButton controls which mouse button
* that has to be pressed during the mouse gesture.
* Notice that this all events for this button are
* swallowed by the filter.
*/
QjtMouseGestureFilter(bool allowDiagonals = false, Qt::MouseButton gestureButton = Qt::RightButton, int minimumMovement = 5, double minimumMatch = 0.9, QObject* parent = 0);
~QjtMouseGestureFilter();
/*
* Adds a gesture to the filter.
*/
void addGesture(QjtMouseGesture* gesture);
/*
* Clears the filter from gestures.
*
* If deleteGestures is true, the QjtMouseGesture objects are deleted.
*/
void clearGestures(bool deleteGestures = false);
bool mouseButtonPressEvent(QMouseEvent* event, QObject* obj = 0);
bool mouseButtonReleaseEvent(QMouseEvent* event, QObject* obj = 0);
bool mouseMoveEvent(QMouseEvent* event, QObject* obj = 0);
protected:
bool eventFilter(QObject* obj, QEvent* event);
private:
bool paintEvent(QObject* obj, QPaintEvent* event);
class Private;
Private* d;
};
#endif // QJTMOUSEGESTUREFILTER_H

View File

@ -0,0 +1,170 @@
/*
* This file is part of the mouse gesture package.
* Copyright (C) 2006 Johan Thelin <e8johan@gmail.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the
* following conditions are met:
*
* - Redistributions of source code must retain the above
* copyright notice, this list of conditions and the
* following disclaimer.
* - Redistributions in binary form must reproduce the
* above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or
* other materials provided with the distribution.
* - The names of its contributors may be used to endorse
* or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
#include "adv_recognizer.h"
#include <algorithm>
using namespace Gesture;
RealTimeMouseGestureRecognizer::RealTimeMouseGestureRecognizer(int minimumMovement, double minimumMatch, bool allowDiagonals)
: minimumMatch(minimumMatch), allowDiagonals(allowDiagonals)
{
minimumMovement2 = minimumMovement * minimumMovement;
directions.resize(64);
lastX = 0;
lastY = 0;
lastDirection = NoMatch;
}
RealTimeMouseGestureRecognizer::~RealTimeMouseGestureRecognizer()
{
}
const Direction dirsD[8] = {
Down,
Up,
Right,
Left,
DownRight,
DownLeft,
UpLeft,
UpRight
};
void RealTimeMouseGestureRecognizer::addPoint(int x, int y)
{
int dx, dy;
dx = x - lastX;
dy = y - lastY;
if (dx * dx + dy * dy < minimumMovement2) {
return;
}
Direction direction;
const int _directions[8][2] = {
{0, 15}, //down 0
{0, -15}, //up 1
{15, 0}, //right 2
{ -15, 0}, //left 3
{10, 10}, //down right 4
{ -10, 10}, //down left 5
{ -10, -10}, //up left 6
{10, -10}//up right 7
};
int maxValue = 0;
int maxIndex = -1;
for (int i = 0; i < (allowDiagonals ? 8 : 4); i++) {
int value = dx * _directions[i][0] + dy * _directions[i][1];
if (value > maxValue) {
maxValue = value;
maxIndex = i;
}
}
direction = dirsD[maxIndex];
if (direction != lastDirection) {
directions.push_back(direction);
recognizeGesture();
}
lastX = x;
lastY = y;
lastDirection = direction;
}
struct DirectionSort {
bool operator()(GestureDefinition a, GestureDefinition b) {
return a.directions.size() > b.directions.size();
}
};
void RealTimeMouseGestureRecognizer::addGestureDefinition(const GestureDefinition &gesture)
{
gestures.push_back(gesture);
std::sort(gestures.begin(), gestures.end(), DirectionSort());
}
void RealTimeMouseGestureRecognizer::clearGestureDefinitions()
{
gestures.clear();
}
void RealTimeMouseGestureRecognizer::recognizeGesture()
{
int first = gestures.size();
for (GestureList::const_iterator gi = gestures.begin(); gi != gestures.end(); ++gi) {
int readIndex = directions.getReadPointer();
bool match = true;
try {
for (DirectionList::const_iterator di = gi->directions.begin(); di != gi->directions.end() && match; ++di) {
Direction d = directions.pop();
if (*di != d) {
match = false;
}
}
if (match) {
if (gi->callbackClass) {
gi->callbackClass->callback();
}
return;
}
else {
first--;
directions.setReadPointerTo(readIndex);
}
}
catch (const std::exception &e) {
directions.setReadPointerTo(readIndex);
}
}
if (first == 0) {
directions.pop();
}
}

View File

@ -0,0 +1,77 @@
/*
* This file is part of the mouse gesture package.
* Copyright (C) 2006 Johan Thelin <e8johan@gmail.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the
* following conditions are met:
*
* - Redistributions of source code must retain the above
* copyright notice, this list of conditions and the
* following disclaimer.
* - Redistributions in binary form must reproduce the
* above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or
* other materials provided with the distribution.
* - The names of its contributors may be used to endorse
* or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef REAL_TIME_RECOGNIZER_H
#define REAL_TIME_RECOGNIZER_H
#include "mousegesturerecognizer.h"
#include "ring_buffer.h"
namespace Gesture
{
class RealTimeMouseGestureRecognizer
{
public:
RealTimeMouseGestureRecognizer(int minimumMovement = 5, double minimumMatch = 0.9, bool allowDiagonals = true);
~RealTimeMouseGestureRecognizer();
void addGestureDefinition(const GestureDefinition &gesture);
void clearGestureDefinitions();
void addPoint(int x, int y);
void abortGesture();
private:
void recognizeGesture();
RingBuffer<Direction> directions;
GestureList gestures;
int minimumMovement2;
double minimumMatch;
bool allowDiagonals;
int lastX, lastY;
Direction lastDirection;
};
}; //end Gesture
#endif // REAL_TIME_RECOGNIZER_H

View File

@ -0,0 +1,409 @@
/*
* This file is part of the mouse gesture package.
* Copyright (C) 2006 Johan Thelin <e8johan@gmail.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the
* following conditions are met:
*
* - Redistributions of source code must retain the above
* copyright notice, this list of conditions and the
* following disclaimer.
* - Redistributions in binary form must reproduce the
* above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or
* other materials provided with the distribution.
* - The names of its contributors may be used to endorse
* or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
#include "mousegesturerecognizer.h"
using namespace Gesture;
// Private data structure
struct MouseGestureRecognizer::Private {
PosList positions;
GestureList gestures;
int minimumMovement2;
double minimumMatch;
bool allowDiagonals;
};
// Class implementation
MouseGestureRecognizer::MouseGestureRecognizer(int minimumMovement, double minimumMatch, bool allowDiagonals)
{
d = new Private;
d->minimumMovement2 = minimumMovement * minimumMovement;
d->minimumMatch = minimumMatch;
d->allowDiagonals = allowDiagonals;
}
MouseGestureRecognizer::~MouseGestureRecognizer()
{
delete d;
}
void MouseGestureRecognizer::addGestureDefinition(const GestureDefinition &gesture)
{
d->gestures.push_back(gesture);
}
void MouseGestureRecognizer::clearGestureDefinitions()
{
d->gestures.clear();
}
void MouseGestureRecognizer::startGesture(int x, int y)
{
d->positions.clear();
d->positions.push_back(Pos(x, y));
}
bool MouseGestureRecognizer::endGesture(int x, int y)
{
bool matched = false;
if (x != d->positions.back().x || y != d->positions.back().y) {
d->positions.push_back(Pos(x, y));
}
int dx = x - d->positions.at(0).x;
int dy = y - d->positions.at(0).y;
if (dx* dx + dy* dy < d->minimumMovement2) {
return false;
}
if (d->positions.size() > 1) {
matched = recognizeGesture();
}
d->positions.clear();
return matched;
}
void MouseGestureRecognizer::abortGesture()
{
d->positions.clear();
}
void MouseGestureRecognizer::addPoint(int x, int y)
{
int dx, dy;
dx = x - d->positions.back().x;
dy = y - d->positions.back().y;
if (dx* dx + dy* dy >= d->minimumMovement2) {
d->positions.push_back(Pos(x, y));
}
}
PosList MouseGestureRecognizer::currentPath() const
{
return d->positions;
}
bool MouseGestureRecognizer::recognizeGesture()
{
PosList directions = simplify(limitDirections(d->positions, d->allowDiagonals));
double minLength = calcLength(directions) * d->minimumMatch;
while (directions.size() > 0 && calcLength(directions) > minLength) {
for (GestureList::const_iterator gi = d->gestures.begin(); gi != d->gestures.end(); ++gi) {
if (gi->directions.size() == directions.size()) {
bool match = true;
PosList::const_iterator pi = directions.begin();
for (DirectionList::const_iterator di = gi->directions.begin(); di != gi->directions.end() && match; ++di, ++pi) {
switch (*di) {
case UpLeft:
if (!(pi->y < 0 && pi->x < 0)) {
match = false;
}
break;
case UpRight:
if (!(pi->y < 0 && pi->x > 0)) {
match = false;
}
break;
case DownLeft:
if (!(pi->y > 0 && pi->x < 0)) {
match = false;
}
break;
case DownRight:
if (!(pi->y > 0 && pi->x > 0)) {
match = false;
}
break;
case Up:
if (pi->y >= 0 || pi->x != 0) {
match = false;
}
break;
case Down:
if (pi->y <= 0 || pi->x != 0) {
match = false;
}
break;
case Left:
if (pi->x >= 0 || pi->y != 0) {
match = false;
}
break;
case Right:
if (pi->x <= 0 || pi->y != 0) {
match = false;
}
break;
case AnyHorizontal:
if (pi->x == 0 || pi->y != 0) {
match = false;
}
break;
case AnyVertical:
if (pi->y == 0 || pi->x != 0) {
match = false;
}
break;
case NoMatch:
match = false;
break;
}
}
if (match) {
gi->callbackClass->callback();
return true;
}
}
}
directions = simplify(removeShortest(directions));
}
for (GestureList::const_iterator gi = d->gestures.begin(); gi != d->gestures.end(); ++gi) {
if (gi->directions.size() == 1) {
if (gi->directions.back() == NoMatch) {
gi->callbackClass->callback();
return true;
}
}
}
return false;
}
// Support functions implementation
/*
* limitDirections - limits the directions of a list to up, down, left or right.
*
* Notice! This function converts the list to a set of relative moves instead of a set of screen coordinates.
*/
PosList MouseGestureRecognizer::limitDirections(const PosList &positions, bool allowDiagonals)
{
PosList res;
int lastx, lasty;
bool firstTime = true;
for (PosList::const_iterator ii = positions.begin(); ii != positions.end(); ++ii) {
if (firstTime) {
lastx = ii->x;
lasty = ii->y;
firstTime = false;
}
else {
int dx, dy;
dx = ii->x - lastx;
dy = ii->y - lasty;
const int directions[8][2] = { {0, 15}, {0, -15}, {15, 0}, { -15, 0}, {10, 10}, { -10, 10}, { -10, -10}, {10, -10} };
int maxValue = 0;
int maxIndex = -1;
for (int i = 0; i < (allowDiagonals ? 8 : 4); i++) {
int value = dx * directions[i][0] + dy * directions[i][1];
if (value > maxValue) {
maxValue = value;
maxIndex = i;
}
}
if (maxIndex == -1) {
dx = dy = 0;
}
else {
dx = directions[maxIndex][0]; // * abs(sqrt(maxValue))
dy = directions[maxIndex][1]; // * abs(sqrt(maxValue))
}
res.push_back(Pos(dx, dy));
lastx = ii->x;
lasty = ii->y;
}
}
return res;
}
/*
* simplify - joins together contignous movements in the same direction.
*
* Notice! This function expects a list of limited directions.
*/
PosList MouseGestureRecognizer::simplify(const PosList &positions)
{
PosList res;
int lastdx = 0, lastdy = 0;
bool firstTime = true;
for (PosList::const_iterator ii = positions.begin(); ii != positions.end(); ++ii) {
if (firstTime) {
lastdx = ii->x;
lastdy = ii->y;
firstTime = false;
}
else {
bool joined = false;
//horizontal lines
if (((lastdx > 0 && ii->x > 0) || (lastdx < 0 && ii->x < 0)) && (lastdy == 0 && ii->y == 0)) {
lastdx += ii->x;
joined = true;
}
//vertical
if (((lastdy > 0 && ii->y > 0) || (lastdy < 0 && ii->y < 0)) && (lastdx == 0 && ii->x == 0)) {
lastdy += ii->y;
joined = true;
}
//down right/left
if (((lastdx > 0 && ii->x > 0) || (lastdx < 0 && ii->x < 0)) && (lastdy > 0 && ii->y > 0)) {
lastdx += ii->x;
lastdy += ii->y;
joined = true;
}
//up left/right
if (((lastdx > 0 && ii->x > 0) || (lastdx < 0 && ii->x < 0)) && (lastdy < 0 && ii->y < 0)) {
lastdx += ii->x;
lastdy += ii->y;
joined = true;
}
if (!joined) {
res.push_back(Pos(lastdx, lastdy));
lastdx = ii->x;
lastdy = ii->y;
}
}
}
if (lastdx != 0 || lastdy != 0) {
res.push_back(Pos(lastdx, lastdy));
}
return res;
}
/*
* removeShortest - removes the shortest segment from a list of movements.
*
* If there are several equally short segments, the first one is removed.
*/
PosList MouseGestureRecognizer::removeShortest(const PosList &positions)
{
PosList res;
int shortestSoFar;
PosList::const_iterator shortest;
bool firstTime = true;
for (PosList::const_iterator ii = positions.begin(); ii != positions.end(); ++ii) {
if (firstTime) {
shortestSoFar = ii->x * ii->x + ii->y * ii->y;
shortest = ii;
firstTime = false;
}
else {
if ((ii->x * ii->x + ii->y * ii->y) < shortestSoFar) {
shortestSoFar = ii->x * ii->x + ii->y * ii->y;
shortest = ii;
}
}
}
for (PosList::const_iterator ii = positions.begin(); ii != positions.end(); ++ii) {
if (ii != shortest) {
res.push_back(*ii);
}
}
return res;
}
/*
* calcLength - calculates the total length of the movements from a list of relative movements.
*/
int MouseGestureRecognizer::calcLength(const PosList &positions)
{
int res = 0;
for (PosList::const_iterator ii = positions.begin(); ii != positions.end(); ++ii) {
if (ii->x > 0) {
res += ii->x;
}
else if (ii->x < 0) {
res -= ii->x;
}
else if (ii->y > 0) {
res += ii->y;
}
else {
res -= ii->y;
}
}
return res;
}

View File

@ -0,0 +1,116 @@
/*
* This file is part of the mouse gesture package.
* Copyright (C) 2006 Johan Thelin <e8johan@gmail.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the
* following conditions are met:
*
* - Redistributions of source code must retain the above
* copyright notice, this list of conditions and the
* following disclaimer.
* - Redistributions in binary form must reproduce the
* above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or
* other materials provided with the distribution.
* - The names of its contributors may be used to endorse
* or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef MOUSEGESTURERECOGNIZER_H
#define MOUSEGESTURERECOGNIZER_H
#include <list>
#include <vector>
namespace Gesture
{
/*
* Sub-class and implement callback method and register along a gesture description.
*/
class MouseGestureCallback
{
public:
virtual void callback() = 0;
};
/*
* The available directions.
*/
typedef enum { Up, Down, Left, Right, AnyHorizontal, AnyVertical, UpLeft, UpRight, DownLeft, DownRight, NoMatch } Direction;
/*
* A list of directions.
*/
typedef std::list<Direction> DirectionList;
/*
* Create lists of directions and connect to a callback.
*/
struct GestureDefinition {
GestureDefinition(const DirectionList &d, MouseGestureCallback* c) : directions(d), callbackClass(c) {}
DirectionList directions;
MouseGestureCallback* callbackClass;
};
/*
* Data types for internal use
*/
struct Pos {
Pos(int ix, int iy) : x(ix), y(iy) {}
int x, y;
};
typedef std::vector<Pos> PosList;
typedef std::vector<GestureDefinition> GestureList;
class MouseGestureRecognizer
{
public:
MouseGestureRecognizer(int minimumMovement = 5, double minimumMatch = 0.9, bool allowDiagonals = false);
~MouseGestureRecognizer();
void addGestureDefinition(const GestureDefinition &gesture);
void clearGestureDefinitions();
void startGesture(int x, int y);
void addPoint(int x, int y);
bool endGesture(int x, int y);
void abortGesture();
PosList currentPath() const;
private:
bool recognizeGesture();
static PosList limitDirections(const PosList &positions, bool allowDiagnonals);
static PosList simplify(const PosList &positions);
static PosList removeShortest(const PosList &positions);
static int calcLength(const PosList &positions);
struct Private;
Private* d;
};
};
#endif // MOUSEGESTURERECOGNIZER_H

View File

@ -0,0 +1,130 @@
/*
* This file is part of the mouse gesture package.
* Copyright (C) 2006 Johan Thelin <e8johan@gmail.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the
* following conditions are met:
*
* - Redistributions of source code must retain the above
* copyright notice, this list of conditions and the
* following disclaimer.
* - Redistributions in binary form must reproduce the
* above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or
* other materials provided with the distribution.
* - The names of its contributors may be used to endorse
* or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef RING_BUFFER_H
#define RING_BUFFER_H
#include <vector>
/*
* Implementation of Ring Buffer
*/
template<typename T>
class RingBuffer
{
public:
typedef T* iterator;
typedef const T* const_iterator;
RingBuffer() {
size = 0;
read = 0;
write = 0;
empty = true;
overflow = false;
}
RingBuffer(int size) {
size = 0;
read = 0;
write = 0;
empty = true;
overflow = false;
resize(size);
}
void push_back(T item) {
/*
if(overflow)
{
throw std::exception("container overflow!");
}
*/
array[write++] = item;
if (write >= size) write = 0;
empty = false;
if (write == read) {
overflow = true;
}
}
T &pop() {
/*
if ( empty )
{
throw std::exception("container is empty");
}
*/
int tmp = read;
read++;
if (read >= size) read = 0;
overflow = false;
if (write == read)
empty = true;
return array[tmp];
}
void setReadPointerTo(int index) {
read = index;
if (read >= size) read = 0;
if (write != read) empty = false;
}
int getReadPointer() {
return read;
}
bool is_empty() {
return empty;
}
void resize(int s) {
size = s;
array = new T[size];
}
protected:
T* array;
int size;
int read;
int write;
bool overflow;
bool empty;
};
#endif

View File

@ -0,0 +1,48 @@
# This file is part of the mouse gesture package.
# Copyright (C) 2006 Johan Thelin <e8johan@gmail.com>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or
# without modification, are permitted provided that the
# following conditions are met:
#
# - Redistributions of source code must retain the above
# copyright notice, this list of conditions and the
# following disclaimer.
# - Redistributions in binary form must reproduce the
# above copyright notice, this list of conditions and
# the following disclaimer in the documentation and/or
# other materials provided with the distribution.
# - The names of its contributors may be used to endorse
# or promote products derived from this software without
# specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
TEMPLATE = lib
VERSION = 0.2.0
TARGET = mgesturer
DESTDIR = ../lib
INCLUDEPATH = ../include
CONFIG += staticlib
HEADERS += ../include/QjtMouseGesture.h \
../include/QjtMouseGestureFilter.h
SOURCES += mousegesturerecognizer.cpp \
QjtMouseGesture.cpp \
QjtMouseGestureFilter.cpp \
adv_recognizer.cpp

View File

@ -0,0 +1,29 @@
QT += network webkit
TARGET = MouseGestures
INCLUDEPATH = 3rdparty
SOURCES = \
3rdparty/mousegesturerecognizer.cpp \
3rdparty/QjtMouseGesture.cpp \
3rdparty/QjtMouseGestureFilter.cpp \
3rdparty/adv_recognizer.cpp \
mousegestures.cpp \
mousegesturesplugin.cpp \
mousegesturessettingsdialog.cpp
HEADERS = \
3rdparty/QjtMouseGesture.h \
3rdparty/QjtMouseGestureFilter.h \
mousegestures.h \
mousegesturesplugin.h \
mousegesturessettingsdialog.h
RESOURCES = mousegestures.qrc
TRANSLATIONS = translations/cs_CZ.ts
include(../../plugins.pri)
FORMS += \
mousegesturessettingsdialog.ui

View File

@ -0,0 +1,34 @@
Mouse gestures recognition algorithm is under following license:
Copyright (C) 2006 Johan Thelin <e8johan@gmail.com>
All rights reserved.
Redistribution and use in source and binary forms, with or
without modification, are permitted provided that the
following conditions are met:
- Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
- Redistributions in binary form must reproduce the
above copyright notice, this list of conditions and
the following disclaimer in the documentation and/or
other materials provided with the distribution.
- The names of its contributors may be used to endorse
or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.

Binary file not shown.

After

Width:  |  Height:  |  Size: 361 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 434 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 417 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 328 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 315 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 322 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 423 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 417 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 429 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 324 B

View File

@ -0,0 +1,115 @@
#include "mousegestures.h"
#include "QjtMouseGestureFilter.h"
#include "QjtMouseGesture.h"
#include "webview.h"
#include "mainapplication.h"
#include "qupzilla.h"
#include "mousegesturessettingsdialog.h"
MouseGestures::MouseGestures(QObject* parent) :
QObject(parent)
{
m_filter = new QjtMouseGestureFilter(false, Qt::MiddleButton, 20);
QjtMouseGesture* upGesture = new QjtMouseGesture(DirectionList() << Up, m_filter);
connect(upGesture, SIGNAL(gestured()), this, SLOT(upGestured()));
QjtMouseGesture* downGesture = new QjtMouseGesture(DirectionList() << Down, m_filter);
connect(downGesture, SIGNAL(gestured()), this, SLOT(downGestured()));
QjtMouseGesture* leftGesture = new QjtMouseGesture(DirectionList() << Left, m_filter);
connect(leftGesture, SIGNAL(gestured()), this, SLOT(leftGestured()));
QjtMouseGesture* rightGesture = new QjtMouseGesture(DirectionList() << Right, m_filter);
connect(rightGesture, SIGNAL(gestured()), this, SLOT(rightGestured()));
QjtMouseGesture* downRightGesture = new QjtMouseGesture(DirectionList() << Down << Right, m_filter);
connect(downRightGesture, SIGNAL(gestured()), this, SLOT(downRightGestured()));
QjtMouseGesture* downLeftGesture = new QjtMouseGesture(DirectionList() << Down << Left, m_filter);
connect(downLeftGesture, SIGNAL(gestured()), this, SLOT(downLeftGestured()));
QjtMouseGesture* upDownGesture = new QjtMouseGesture(DirectionList() << Up << Down, m_filter);
connect(upDownGesture, SIGNAL(gestured()), this, SLOT(upDownGestured()));
m_filter->addGesture(upGesture);
m_filter->addGesture(downGesture);
m_filter->addGesture(leftGesture);
m_filter->addGesture(rightGesture);
m_filter->addGesture(downRightGesture);
m_filter->addGesture(downLeftGesture);
m_filter->addGesture(upDownGesture);
}
bool MouseGestures::mousePress(QObject* obj, QMouseEvent* event)
{
m_view = qobject_cast<WebView*>(obj);
m_filter->mouseButtonPressEvent(event);
return false;
}
bool MouseGestures::mouseRelease(QObject* obj, QMouseEvent* event)
{
Q_UNUSED(obj)
return m_filter->mouseButtonReleaseEvent(event);
}
bool MouseGestures::mouseMove(QObject* obj, QMouseEvent* event)
{
Q_UNUSED(obj)
m_filter->mouseMoveEvent(event);
return false;
}
void MouseGestures::showSettings(QWidget* parent)
{
MouseGesturesSettingsDialog* d = new MouseGesturesSettingsDialog(parent);
d->show();
}
void MouseGestures::upGestured()
{
m_view->stop();
}
void MouseGestures::downGestured()
{
m_view->openNewTab();
}
void MouseGestures::leftGestured()
{
m_view->back();
}
void MouseGestures::rightGestured()
{
m_view->forward();
}
void MouseGestures::downRightGestured()
{
m_view->closeView();
}
void MouseGestures::downLeftGestured()
{
m_view->load(mApp->getWindow()->homepageUrl());
}
void MouseGestures::upDownGestured()
{
m_view->reload();
}
MouseGestures::~MouseGestures()
{
m_filter->clearGestures(true);
delete m_filter;
}

View File

@ -0,0 +1,42 @@
#ifndef MOUSEGESTURES_H
#define MOUSEGESTURES_H
#include <QDebug>
#include <QObject>
#include <QMouseEvent>
class WebView;
class QjtMouseGestureFilter;
class MouseGestures : public QObject
{
Q_OBJECT
public:
explicit MouseGestures(QObject* parent = 0);
~MouseGestures();
bool mousePress(QObject* obj, QMouseEvent* event);
bool mouseRelease(QObject* obj, QMouseEvent* event);
bool mouseMove(QObject* obj, QMouseEvent* event);
void showSettings(QWidget* parent);
private slots:
void upGestured();
void downGestured();
void leftGestured();
void rightGestured();
void downRightGestured();
void downLeftGestured();
void upDownGestured();
// void upLeftGestured();
// void upRightGestured();
private:
QjtMouseGestureFilter* m_filter;
WebView* m_view;
};
#endif // MOUSEGESTURES_H

View File

@ -0,0 +1,17 @@
<RCC>
<qresource prefix="/mousegestures">
<file>data/icon.png</file>
<file>data/down.gif</file>
<file>data/down-left.gif</file>
<file>data/down-right.gif</file>
<file>data/down-up.gif</file>
<file>data/left.gif</file>
<file>data/right.gif</file>
<file>data/up.gif</file>
<file>data/up-down.gif</file>
<file>data/up-left.gif</file>
<file>data/up-right.gif</file>
<file>data/copyright</file>
<file>locale/cs_CZ.qm</file>
</qresource>
</RCC>

View File

@ -0,0 +1,89 @@
#include "mousegesturesplugin.h"
#include "pluginproxy.h"
#include "mousegestures.h"
#include "qupzilla.h"
MouseGesturesPlugin::MouseGesturesPlugin()
: QObject()
, m_gestures(0)
{
}
PluginSpec MouseGesturesPlugin::pluginSpec()
{
PluginSpec spec;
spec.name = "Mouse Gestures";
spec.info = "Mouse gestures for QupZilla";
spec.description = "Provides support for navigating by mouse gestures through webpages";
spec.version = "0.1.0";
spec.author = "David Rosca <nowrep@gmail.com>";
spec.icon = QIcon(":/mousegestures/data/icon.png");
spec.hasSettings = true;
return spec;
}
void MouseGesturesPlugin::init(const QString &sPath)
{
Q_UNUSED(sPath)
m_gestures = new MouseGestures(this);
QZ_REGISTER_EVENT_HANDLER(PluginProxy::MousePressHandler);
QZ_REGISTER_EVENT_HANDLER(PluginProxy::MouseReleaseHandler);
QZ_REGISTER_EVENT_HANDLER(PluginProxy::MouseMoveHandler);
}
void MouseGesturesPlugin::unload()
{
m_gestures->deleteLater();
}
bool MouseGesturesPlugin::testPlugin()
{
// Let's be sure, require latest version of QupZilla
return (QupZilla::VERSION == "1.1.8");
}
QTranslator* MouseGesturesPlugin::getTranslator(const QString &locale)
{
QTranslator* translator = new QTranslator();
translator->load(":/mousegestures/locale/" + locale);
return translator;
}
void MouseGesturesPlugin::showSettings(QWidget* parent)
{
m_gestures->showSettings(parent);
}
bool MouseGesturesPlugin::mousePress(const Qz::ObjectName &type, QObject* obj, QMouseEvent* event)
{
if (type == Qz::ON_WebView) {
m_gestures->mousePress(obj, event);
}
return false;
}
bool MouseGesturesPlugin::mouseRelease(const Qz::ObjectName &type, QObject* obj, QMouseEvent* event)
{
if (type == Qz::ON_WebView) {
return m_gestures->mouseRelease(obj, event);
}
return false;
}
bool MouseGesturesPlugin::mouseMove(const Qz::ObjectName &type, QObject* obj, QMouseEvent* event)
{
if (type == Qz::ON_WebView) {
m_gestures->mouseMove(obj, event);
}
return false;
}
Q_EXPORT_PLUGIN2(MouseGestures, MouseGesturesPlugin)

View File

@ -0,0 +1,32 @@
#ifndef MOUSEGESTURESPLUGIN_H
#define MOUSEGESTURESPLUGIN_H
#include "plugininterface.h"
class MouseGestures;
class MouseGesturesPlugin : public QObject, public PluginInterface
{
Q_OBJECT
Q_INTERFACES(PluginInterface)
public:
MouseGesturesPlugin();
PluginSpec pluginSpec();
void init(const QString &sPath);
void unload();
bool testPlugin();
QTranslator* getTranslator(const QString &locale);
void showSettings(QWidget* parent = 0);
bool mousePress(const Qz::ObjectName &type, QObject* obj, QMouseEvent* event);
bool mouseRelease(const Qz::ObjectName &type, QObject* obj, QMouseEvent* event);
bool mouseMove(const Qz::ObjectName &type, QObject* obj, QMouseEvent* event);
private:
MouseGestures* m_gestures;
};
#endif // MOUSEGESTURESPLUGIN_H

View File

@ -0,0 +1,29 @@
#include "mousegesturessettingsdialog.h"
#include "ui_mousegesturessettingsdialog.h"
#include "globalfunctions.h"
MouseGesturesSettingsDialog::MouseGesturesSettingsDialog(QWidget* parent)
: QDialog(parent)
, ui(new Ui::MouseGesturesSettingsDialog)
{
ui->setupUi(this);
setAttribute(Qt::WA_DeleteOnClose);
connect(ui->licenseButton, SIGNAL(clicked()), this, SLOT(showLicense()));
}
MouseGesturesSettingsDialog::~MouseGesturesSettingsDialog()
{
delete ui;
}
void MouseGesturesSettingsDialog::showLicense()
{
QTextBrowser* b = new QTextBrowser();
b->setAttribute(Qt::WA_DeleteOnClose);
b->setWindowTitle(tr("License Viewer"));
b->resize(450, 500);
b->setText(qz_readAllFileContents(":mousegestures/data/copyright"));
qz_centerWidgetOnScreen(b);
b->show();
}

View File

@ -0,0 +1,27 @@
#ifndef MOUSEGESTURESSETTINGSDIALOG_H
#define MOUSEGESTURESSETTINGSDIALOG_H
#include <QDialog>
#include <QTextBrowser>
namespace Ui
{
class MouseGesturesSettingsDialog;
}
class MouseGesturesSettingsDialog : public QDialog
{
Q_OBJECT
public:
explicit MouseGesturesSettingsDialog(QWidget* parent = 0);
~MouseGesturesSettingsDialog();
private slots:
void showLicense();
private:
Ui::MouseGesturesSettingsDialog* ui;
};
#endif // MOUSEGESTURESSETTINGSDIALOG_H

View File

@ -0,0 +1,267 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MouseGesturesSettingsDialog</class>
<widget class="QDialog" name="MouseGesturesSettingsDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>502</width>
<height>325</height>
</rect>
</property>
<property name="windowTitle">
<string>Mouse Gestures</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<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>
<item>
<widget class="QLabel" name="label_2">
<property name="pixmap">
<pixmap resource="mousegestures.qrc">:/mousegestures/data/icon.png</pixmap>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>&lt;h1&gt;Mouse Gestures&lt;/h1&gt;</string>
</property>
</widget>
</item>
<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>
</layout>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QGridLayout" name="gridLayout">
<property name="leftMargin">
<number>20</number>
</property>
<property name="rightMargin">
<number>20</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_3">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="pixmap">
<pixmap resource="mousegestures.qrc">:/mousegestures/data/up.gif</pixmap>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="label_10">
<property name="text">
<string>&lt;b&gt;Stop&lt;/b&gt;&lt;br/&gt;Stop loading page</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_4">
<property name="pixmap">
<pixmap resource="mousegestures.qrc">:/mousegestures/data/down.gif</pixmap>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="label_12">
<property name="text">
<string>&lt;b&gt;New tab&lt;/b&gt;&lt;br/&gt;Open new tab</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_5">
<property name="pixmap">
<pixmap resource="mousegestures.qrc">:/mousegestures/data/left.gif</pixmap>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="label_13">
<property name="text">
<string>&lt;b&gt;Back&lt;/b&gt;&lt;br/&gt;Go back in history</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_6">
<property name="pixmap">
<pixmap resource="mousegestures.qrc">:/mousegestures/data/right.gif</pixmap>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLabel" name="label_9">
<property name="text">
<string>&lt;b&gt;Forward&lt;/b&gt;&lt;br/&gt;Go forward in history</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="label_8">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="pixmap">
<pixmap resource="mousegestures.qrc">:/mousegestures/data/up-down.gif</pixmap>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QLabel" name="label_11">
<property name="text">
<string>&lt;b&gt;Reload&lt;/b&gt;&lt;br/&gt;Reload page</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLabel" name="label_7">
<property name="pixmap">
<pixmap resource="mousegestures.qrc">:/mousegestures/data/down-right.gif</pixmap>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QLabel" name="label_15">
<property name="text">
<string>&lt;b&gt;Close tab&lt;/b&gt;&lt;br/&gt;Close current tab</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QLabel" name="label_14">
<property name="pixmap">
<pixmap resource="mousegestures.qrc">:/mousegestures/data/down-left.gif</pixmap>
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="QLabel" name="label_16">
<property name="text">
<string>&lt;b&gt;Home&lt;/b&gt;&lt;br/&gt;Go to homepage</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QPushButton" name="licenseButton">
<property name="text">
<string>License</string>
</property>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Close</set>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources>
<include location="mousegestures.qrc"/>
</resources>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>MouseGesturesSettingsDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>MouseGesturesSettingsDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -0,0 +1,62 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.0" language="cs_CZ">
<context>
<name>MouseGesturesSettingsDialog</name>
<message>
<location filename="../mousegesturessettingsdialog.ui" line="14"/>
<source>Mouse Gestures</source>
<translation>Gesta myší</translation>
</message>
<message>
<location filename="../mousegesturessettingsdialog.ui" line="42"/>
<source>&lt;h1&gt;Mouse Gestures&lt;/h1&gt;</source>
<translation>&lt;h1&gt;Gesta myší&lt;/h1&gt;</translation>
</message>
<message>
<location filename="../mousegesturessettingsdialog.ui" line="98"/>
<source>&lt;b&gt;Stop&lt;/b&gt;&lt;br/&gt;Stop loading page</source>
<translation>&lt;b&gt;Zastavit&lt;/b&gt;&lt;br/&gt;Zastavit načítání stránky</translation>
</message>
<message>
<location filename="../mousegesturessettingsdialog.ui" line="112"/>
<source>&lt;b&gt;New tab&lt;/b&gt;&lt;br/&gt;Open new tab</source>
<translation>&lt;b&gt;Nový panel&lt;/b&gt;&lt;br/&gt;Otevřít nový panel</translation>
</message>
<message>
<location filename="../mousegesturessettingsdialog.ui" line="126"/>
<source>&lt;b&gt;Back&lt;/b&gt;&lt;br/&gt;Go back in history</source>
<translation>&lt;b&gt;Zpět&lt;/b&gt;&lt;br/&gt;Přejít zpět v historii</translation>
</message>
<message>
<location filename="../mousegesturessettingsdialog.ui" line="140"/>
<source>&lt;b&gt;Forward&lt;/b&gt;&lt;br/&gt;Go forward in history</source>
<translation>&lt;b&gt;Vpřed&lt;/b&gt;&lt;br/&gt;Přejít vpřed v historii</translation>
</message>
<message>
<location filename="../mousegesturessettingsdialog.ui" line="160"/>
<source>&lt;b&gt;Reload&lt;/b&gt;&lt;br/&gt;Reload page</source>
<translation>&lt;b&gt;Obnovit&lt;/b&gt;&lt;br/&gt;Obnovit stránku</translation>
</message>
<message>
<location filename="../mousegesturessettingsdialog.ui" line="174"/>
<source>&lt;b&gt;Close tab&lt;/b&gt;&lt;br/&gt;Close current tab</source>
<translation>&lt;b&gt;Zavřít panel&lt;/b&gt;&lt;br/&gt;Zavřít aktuální panel</translation>
</message>
<message>
<location filename="../mousegesturessettingsdialog.ui" line="188"/>
<source>&lt;b&gt;Home&lt;/b&gt;&lt;br/&gt;Go to homepage</source>
<translation>&lt;b&gt;Domů&lt;/b&gt;&lt;br/&gt;Přejít na domovskou stránku</translation>
</message>
<message>
<location filename="../mousegesturessettingsdialog.ui" line="212"/>
<source>License</source>
<translation>Licence</translation>
</message>
<message>
<location filename="../mousegesturessettingsdialog.cpp" line="24"/>
<source>License Viewer</source>
<translation>Prohlížeč licence</translation>
</message>
</context>
</TS>

View File

@ -3,6 +3,15 @@
#include "webview.h" #include "webview.h"
#include "pluginproxy.h" #include "pluginproxy.h"
TestPlugin::TestPlugin()
: QObject()
, m_view(0)
{
// Don't do anything expensive in constructor!
// It will be called even if user doesn't have
// plugin allowed
}
PluginSpec TestPlugin::pluginSpec() PluginSpec TestPlugin::pluginSpec()
{ {
PluginSpec spec; PluginSpec spec;
@ -26,7 +35,6 @@ void TestPlugin::init(const QString &sPath)
// so it is recommended not to call any QupZilla function here // so it is recommended not to call any QupZilla function here
m_settingsPath = sPath; m_settingsPath = sPath;
m_view = 0;
QZ_REGISTER_EVENT_HANDLER(PluginProxy::MousePressHandler); QZ_REGISTER_EVENT_HANDLER(PluginProxy::MousePressHandler);
} }

View File

@ -21,6 +21,7 @@ class TestPlugin : public QObject, public PluginInterface
Q_INTERFACES(PluginInterface) Q_INTERFACES(PluginInterface)
public: public:
explicit TestPlugin();
PluginSpec pluginSpec(); PluginSpec pluginSpec();
void init(const QString &sPath); void init(const QString &sPath);

View File

@ -4,27 +4,27 @@
<context> <context>
<name>TestPlugin</name> <name>TestPlugin</name>
<message> <message>
<location filename="testplugin.cpp" line="59"/> <location filename="../testplugin.cpp" line="70"/>
<source>Close</source> <source>Close</source>
<translation>Zavřít</translation> <translation>Zavřít</translation>
</message> </message>
<message> <message>
<location filename="testplugin.cpp" line="70"/> <location filename="../testplugin.cpp" line="81"/>
<source>Example Plugin Settings</source> <source>Example Plugin Settings</source>
<translation>Nastavení ukázkového doplňku</translation> <translation>Nastavení ukázkového doplňku</translation>
</message> </message>
<message> <message>
<location filename="testplugin.cpp" line="95"/> <location filename="../testplugin.cpp" line="105"/>
<source>My first plugin action</source> <source>My first plugin action</source>
<translation>Moje první akce z doplňku</translation> <translation>Moje první akce z doplňku</translation>
</message> </message>
<message> <message>
<location filename="testplugin.cpp" line="100"/> <location filename="../testplugin.cpp" line="117"/>
<source>Hello</source> <source>Hello</source>
<translation>Ahoj</translation> <translation>Ahoj</translation>
</message> </message>
<message> <message>
<location filename="testplugin.cpp" line="100"/> <location filename="../testplugin.cpp" line="117"/>
<source>First plugin action works :-)</source> <source>First plugin action works :-)</source>
<translation>První akce funguje :-)</translation> <translation>První akce funguje :-)</translation>
</message> </message>

View File

@ -4,27 +4,27 @@
<context> <context>
<name>TestPlugin</name> <name>TestPlugin</name>
<message> <message>
<location filename="testplugin.cpp" line="59"/> <location filename="../testplugin.cpp" line="70"/>
<source>Close</source> <source>Close</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="testplugin.cpp" line="70"/> <location filename="../testplugin.cpp" line="81"/>
<source>Example Plugin Settings</source> <source>Example Plugin Settings</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="testplugin.cpp" line="95"/> <location filename="../testplugin.cpp" line="105"/>
<source>My first plugin action</source> <source>My first plugin action</source>
<translation>Meine erste Aktion</translation> <translation>Meine erste Aktion</translation>
</message> </message>
<message> <message>
<location filename="testplugin.cpp" line="100"/> <location filename="../testplugin.cpp" line="117"/>
<source>Hello</source> <source>Hello</source>
<translation>Hallo</translation> <translation>Hallo</translation>
</message> </message>
<message> <message>
<location filename="testplugin.cpp" line="100"/> <location filename="../testplugin.cpp" line="117"/>
<source>First plugin action works :-)</source> <source>First plugin action works :-)</source>
<translation>Meine erste Aktion funktioniert :-)</translation> <translation>Meine erste Aktion funktioniert :-)</translation>
</message> </message>

View File

@ -4,27 +4,27 @@
<context> <context>
<name>TestPlugin</name> <name>TestPlugin</name>
<message> <message>
<location filename="testplugin.cpp" line="59"/> <location filename="../testplugin.cpp" line="70"/>
<source>Close</source> <source>Close</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="testplugin.cpp" line="70"/> <location filename="../testplugin.cpp" line="81"/>
<source>Example Plugin Settings</source> <source>Example Plugin Settings</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="testplugin.cpp" line="95"/> <location filename="../testplugin.cpp" line="105"/>
<source>My first plugin action</source> <source>My first plugin action</source>
<translation>Η ενέργεια του πρώτου μου προσθέτου</translation> <translation>Η ενέργεια του πρώτου μου προσθέτου</translation>
</message> </message>
<message> <message>
<location filename="testplugin.cpp" line="100"/> <location filename="../testplugin.cpp" line="117"/>
<source>Hello</source> <source>Hello</source>
<translation>Γεια</translation> <translation>Γεια</translation>
</message> </message>
<message> <message>
<location filename="testplugin.cpp" line="100"/> <location filename="../testplugin.cpp" line="117"/>
<source>First plugin action works :-)</source> <source>First plugin action works :-)</source>
<translation>Η ενέργεια του πρώτου προσθέτου δουλεύει :-)</translation> <translation>Η ενέργεια του πρώτου προσθέτου δουλεύει :-)</translation>
</message> </message>

View File

@ -4,27 +4,27 @@
<context> <context>
<name>TestPlugin</name> <name>TestPlugin</name>
<message> <message>
<location filename="testplugin.cpp" line="59"/> <location filename="../testplugin.cpp" line="70"/>
<source>Close</source> <source>Close</source>
<translation>Tutup</translation> <translation>Tutup</translation>
</message> </message>
<message> <message>
<location filename="testplugin.cpp" line="70"/> <location filename="../testplugin.cpp" line="81"/>
<source>Example Plugin Settings</source> <source>Example Plugin Settings</source>
<translation>Pengaturan Contoh Pengaya</translation> <translation>Pengaturan Contoh Pengaya</translation>
</message> </message>
<message> <message>
<location filename="testplugin.cpp" line="95"/> <location filename="../testplugin.cpp" line="105"/>
<source>My first plugin action</source> <source>My first plugin action</source>
<translation>Aksi pengaya pertama saya</translation> <translation>Aksi pengaya pertama saya</translation>
</message> </message>
<message> <message>
<location filename="testplugin.cpp" line="100"/> <location filename="../testplugin.cpp" line="117"/>
<source>Hello</source> <source>Hello</source>
<translation>Halo</translation> <translation>Halo</translation>
</message> </message>
<message> <message>
<location filename="testplugin.cpp" line="100"/> <location filename="../testplugin.cpp" line="117"/>
<source>First plugin action works :-)</source> <source>First plugin action works :-)</source>
<translation>Aksi pengaya pertama saya bekerja :-)</translation> <translation>Aksi pengaya pertama saya bekerja :-)</translation>
</message> </message>

View File

@ -4,27 +4,27 @@
<context> <context>
<name>TestPlugin</name> <name>TestPlugin</name>
<message> <message>
<location filename="testplugin.cpp" line="59"/> <location filename="../testplugin.cpp" line="70"/>
<source>Close</source> <source>Close</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="testplugin.cpp" line="70"/> <location filename="../testplugin.cpp" line="81"/>
<source>Example Plugin Settings</source> <source>Example Plugin Settings</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="testplugin.cpp" line="95"/> <location filename="../testplugin.cpp" line="105"/>
<source>My first plugin action</source> <source>My first plugin action</source>
<translation>Moje první akce z doplnku</translation> <translation>Moje první akce z doplnku</translation>
</message> </message>
<message> <message>
<location filename="testplugin.cpp" line="100"/> <location filename="../testplugin.cpp" line="117"/>
<source>Hello</source> <source>Hello</source>
<translation>Ahoj</translation> <translation>Ahoj</translation>
</message> </message>
<message> <message>
<location filename="testplugin.cpp" line="100"/> <location filename="../testplugin.cpp" line="117"/>
<source>First plugin action works :-)</source> <source>First plugin action works :-)</source>
<translation>První doplnek funguje :-)</translation> <translation>První doplnek funguje :-)</translation>
</message> </message>

View File

@ -4,27 +4,27 @@
<context> <context>
<name>TestPlugin</name> <name>TestPlugin</name>
<message> <message>
<location filename="../testplugin.cpp" line="62"/> <location filename="../testplugin.cpp" line="70"/>
<source>Close</source> <source>Close</source>
<translation>Затвори</translation> <translation>Затвори</translation>
</message> </message>
<message> <message>
<location filename="../testplugin.cpp" line="73"/> <location filename="../testplugin.cpp" line="81"/>
<source>Example Plugin Settings</source> <source>Example Plugin Settings</source>
<translation>Подешавања пробног прикључка</translation> <translation>Подешавања пробног прикључка</translation>
</message> </message>
<message> <message>
<location filename="../testplugin.cpp" line="97"/> <location filename="../testplugin.cpp" line="105"/>
<source>My first plugin action</source> <source>My first plugin action</source>
<translation>Радња мог првог прикључка</translation> <translation>Радња мог првог прикључка</translation>
</message> </message>
<message> <message>
<location filename="../testplugin.cpp" line="109"/> <location filename="../testplugin.cpp" line="117"/>
<source>Hello</source> <source>Hello</source>
<translation>Здраво</translation> <translation>Здраво</translation>
</message> </message>
<message> <message>
<location filename="../testplugin.cpp" line="109"/> <location filename="../testplugin.cpp" line="117"/>
<source>First plugin action works :-)</source> <source>First plugin action works :-)</source>
<translation>Радња прикључка ради :-)</translation> <translation>Радња прикључка ради :-)</translation>
</message> </message>

View File

@ -4,27 +4,27 @@
<context> <context>
<name>TestPlugin</name> <name>TestPlugin</name>
<message> <message>
<location filename="../testplugin.cpp" line="62"/> <location filename="../testplugin.cpp" line="70"/>
<source>Close</source> <source>Close</source>
<translation>Затвори</translation> <translation>Затвори</translation>
</message> </message>
<message> <message>
<location filename="../testplugin.cpp" line="73"/> <location filename="../testplugin.cpp" line="81"/>
<source>Example Plugin Settings</source> <source>Example Plugin Settings</source>
<translation>Подешавања пробног прикључка</translation> <translation>Подешавања пробног прикључка</translation>
</message> </message>
<message> <message>
<location filename="../testplugin.cpp" line="97"/> <location filename="../testplugin.cpp" line="105"/>
<source>My first plugin action</source> <source>My first plugin action</source>
<translation>Радња мог првог прикључка</translation> <translation>Радња мог првог прикључка</translation>
</message> </message>
<message> <message>
<location filename="../testplugin.cpp" line="109"/> <location filename="../testplugin.cpp" line="117"/>
<source>Hello</source> <source>Hello</source>
<translation>Здраво</translation> <translation>Здраво</translation>
</message> </message>
<message> <message>
<location filename="../testplugin.cpp" line="109"/> <location filename="../testplugin.cpp" line="117"/>
<source>First plugin action works :-)</source> <source>First plugin action works :-)</source>
<translation>Радња прикључка ради :-)</translation> <translation>Радња прикључка ради :-)</translation>
</message> </message>

View File

@ -4,34 +4,27 @@
<context> <context>
<name>TestPlugin</name> <name>TestPlugin</name>
<message> <message>
<location filename="testplugin.h" line="24"/> <location filename="../testplugin.cpp" line="70"/>
<source>Example Plugin</source> <source>Close</source>
<translation></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="testplugin.h" line="25"/> <location filename="../testplugin.cpp" line="81"/>
<source>Example minimal plugin</source> <source>Example Plugin Settings</source>
<translation></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="testplugin.h" line="26"/> <location filename="../testplugin.cpp" line="105"/>
<source>Very simple minimal plugin example</source>
<translation></translation>
</message>
<message>
<location filename="testplugin.cpp" line="49"/>
<location filename="testplugin.cpp" line="54"/>
<location filename="testplugin.cpp" line="59"/>
<source>My first plugin action</source> <source>My first plugin action</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="testplugin.cpp" line="64"/> <location filename="../testplugin.cpp" line="117"/>
<source>Hello</source> <source>Hello</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="testplugin.cpp" line="64"/> <location filename="../testplugin.cpp" line="117"/>
<source>First plugin action works :-)</source> <source>First plugin action works :-)</source>
<translation>:-)</translation> <translation>:-)</translation>
</message> </message>

View File

@ -4,34 +4,27 @@
<context> <context>
<name>TestPlugin</name> <name>TestPlugin</name>
<message> <message>
<location filename="testplugin.h" line="24"/> <location filename="../testplugin.cpp" line="70"/>
<source>Example Plugin</source> <source>Close</source>
<translation></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="testplugin.h" line="25"/> <location filename="../testplugin.cpp" line="81"/>
<source>Example minimal plugin</source> <source>Example Plugin Settings</source>
<translation></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="testplugin.h" line="26"/> <location filename="../testplugin.cpp" line="105"/>
<source>Very simple minimal plugin example</source>
<translation></translation>
</message>
<message>
<location filename="testplugin.cpp" line="49"/>
<location filename="testplugin.cpp" line="54"/>
<location filename="testplugin.cpp" line="59"/>
<source>My first plugin action</source> <source>My first plugin action</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="testplugin.cpp" line="64"/> <location filename="../testplugin.cpp" line="117"/>
<source>Hello</source> <source>Hello</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="testplugin.cpp" line="64"/> <location filename="../testplugin.cpp" line="117"/>
<source>First plugin action works :-)</source> <source>First plugin action works :-)</source>
<translation>:-)</translation> <translation>:-)</translation>
</message> </message>

View File

@ -1,2 +1,2 @@
TEMPLATE = subdirs TEMPLATE = subdirs
SUBDIRS = TestPlugin SUBDIRS = TestPlugin MouseGestures

View File

@ -1,5 +1,3 @@
TEMPLATE = subdirs TEMPLATE = subdirs
SUBDIRS = lib main SUBDIRS = lib main plugins
build_plugins: SUBDIRS += plugins
CONFIG += ordered CONFIG += ordered

View File

@ -2,7 +2,7 @@
// Header + Footer // Header + Footer
$site_title = "QupZilla - Un navigateur web léger et multi-plateforme"; $site_title = "QupZilla - Un navigateur web léger et multi-plateforme";
$qupzilla = "QupZilla"; $qupzilla = "QupZilla";
$header_description = "Navigateur web" $header_description = "Navigateur web";
$menu_home = "Accueil"; $menu_home = "Accueil";
$menu_screenshots = "Screenshots"; $menu_screenshots = "Screenshots";
@ -10,7 +10,7 @@ $menu_download = "T
$menu_faq = "FAQ"; $menu_faq = "FAQ";
$menu_about = "Contribuer"; $menu_about = "Contribuer";
$footer_site = "www.qupzilla.com"; $footer_site = "www.qupzilla.com";
$translated_by = ""; // "Page traduite par eyome et lamessen" $translated_by = "Page traduite par Jérôme Giry et Nicolas Ourceau";
//Home Page //Home Page
$actual_version = "Version actuelle"; $actual_version = "Version actuelle";