From af7a0417148d04af35634b9486df7566c0e1f59e Mon Sep 17 00:00:00 2001 From: nowrep Date: Fri, 24 Feb 2012 21:03:44 +0100 Subject: [PATCH] Added new plugin: Mouse Gestures. - setting building plugins as default now - closes #255 --- BUILDING | 11 - scripts/coding_style.sh | 4 +- scripts/cppcheck.sh | 8 +- scripts/plugin_translations.sh | 2 + src/defines.pri | 2 +- src/install.pri | 2 +- src/lib/app/qupzilla.cpp | 1 - src/lib/app/qupzilla.h | 2 +- src/lib/preferences/pluginslist.ui | 3 + src/lib/webview/tabbedwebview.cpp | 10 + src/lib/webview/tabbedwebview.h | 4 +- src/lib/webview/webview.cpp | 9 +- src/lib/webview/webview.h | 3 +- src/main/appicon.rc | 4 +- src/main/appicon_os2.rc | 4 +- .../3rdparty/QjtMouseGesture.cpp | 57 +++ .../MouseGestures/3rdparty/QjtMouseGesture.h | 117 +++++ .../3rdparty/QjtMouseGestureFilter.cpp | 233 ++++++++++ .../3rdparty/QjtMouseGestureFilter.h | 94 ++++ .../MouseGestures/3rdparty/adv_recognizer.cpp | 170 ++++++++ .../MouseGestures/3rdparty/adv_recognizer.h | 77 ++++ .../3rdparty/mousegesturerecognizer.cpp | 409 ++++++++++++++++++ .../3rdparty/mousegesturerecognizer.h | 116 +++++ .../MouseGestures/3rdparty/ring_buffer.h | 130 ++++++ src/plugins/MouseGestures/3rdparty/src.pro | 48 ++ src/plugins/MouseGestures/MouseGestures.pro | 29 ++ src/plugins/MouseGestures/data/copyright | 34 ++ src/plugins/MouseGestures/data/down-left.gif | Bin 0 -> 361 bytes src/plugins/MouseGestures/data/down-right.gif | Bin 0 -> 434 bytes src/plugins/MouseGestures/data/down-up.gif | Bin 0 -> 417 bytes src/plugins/MouseGestures/data/down.gif | Bin 0 -> 328 bytes src/plugins/MouseGestures/data/icon.png | Bin 0 -> 4163 bytes src/plugins/MouseGestures/data/left.gif | Bin 0 -> 315 bytes src/plugins/MouseGestures/data/right.gif | Bin 0 -> 322 bytes src/plugins/MouseGestures/data/up-down.gif | Bin 0 -> 423 bytes src/plugins/MouseGestures/data/up-left.gif | Bin 0 -> 417 bytes src/plugins/MouseGestures/data/up-right.gif | Bin 0 -> 429 bytes src/plugins/MouseGestures/data/up.gif | Bin 0 -> 324 bytes src/plugins/MouseGestures/mousegestures.cpp | 115 +++++ src/plugins/MouseGestures/mousegestures.h | 42 ++ src/plugins/MouseGestures/mousegestures.qrc | 17 + .../MouseGestures/mousegesturesplugin.cpp | 89 ++++ .../MouseGestures/mousegesturesplugin.h | 32 ++ .../mousegesturessettingsdialog.cpp | 29 ++ .../mousegesturessettingsdialog.h | 27 ++ .../mousegesturessettingsdialog.ui | 267 ++++++++++++ .../MouseGestures/translations/cs_CZ.ts | 62 +++ src/plugins/TestPlugin/testplugin.cpp | 10 +- src/plugins/TestPlugin/testplugin.h | 1 + src/plugins/TestPlugin/translations/cs_CZ.ts | 10 +- src/plugins/TestPlugin/translations/de_DE.ts | 10 +- src/plugins/TestPlugin/translations/el_GR.ts | 10 +- src/plugins/TestPlugin/translations/id_ID.ts | 10 +- src/plugins/TestPlugin/translations/sk_SK.ts | 10 +- src/plugins/TestPlugin/translations/sr_BA.ts | 10 +- src/plugins/TestPlugin/translations/sr_RS.ts | 10 +- src/plugins/TestPlugin/translations/zh_CN.ts | 25 +- src/plugins/TestPlugin/translations/zh_TW.ts | 25 +- src/plugins/plugins.pro | 2 +- src/src.pro | 4 +- translations/homepage/fr_FR.php | 10 +- 61 files changed, 2308 insertions(+), 102 deletions(-) create mode 100644 src/plugins/MouseGestures/3rdparty/QjtMouseGesture.cpp create mode 100644 src/plugins/MouseGestures/3rdparty/QjtMouseGesture.h create mode 100644 src/plugins/MouseGestures/3rdparty/QjtMouseGestureFilter.cpp create mode 100644 src/plugins/MouseGestures/3rdparty/QjtMouseGestureFilter.h create mode 100644 src/plugins/MouseGestures/3rdparty/adv_recognizer.cpp create mode 100644 src/plugins/MouseGestures/3rdparty/adv_recognizer.h create mode 100644 src/plugins/MouseGestures/3rdparty/mousegesturerecognizer.cpp create mode 100644 src/plugins/MouseGestures/3rdparty/mousegesturerecognizer.h create mode 100644 src/plugins/MouseGestures/3rdparty/ring_buffer.h create mode 100644 src/plugins/MouseGestures/3rdparty/src.pro create mode 100644 src/plugins/MouseGestures/MouseGestures.pro create mode 100644 src/plugins/MouseGestures/data/copyright create mode 100644 src/plugins/MouseGestures/data/down-left.gif create mode 100644 src/plugins/MouseGestures/data/down-right.gif create mode 100644 src/plugins/MouseGestures/data/down-up.gif create mode 100644 src/plugins/MouseGestures/data/down.gif create mode 100644 src/plugins/MouseGestures/data/icon.png create mode 100644 src/plugins/MouseGestures/data/left.gif create mode 100644 src/plugins/MouseGestures/data/right.gif create mode 100644 src/plugins/MouseGestures/data/up-down.gif create mode 100644 src/plugins/MouseGestures/data/up-left.gif create mode 100644 src/plugins/MouseGestures/data/up-right.gif create mode 100644 src/plugins/MouseGestures/data/up.gif create mode 100644 src/plugins/MouseGestures/mousegestures.cpp create mode 100644 src/plugins/MouseGestures/mousegestures.h create mode 100644 src/plugins/MouseGestures/mousegestures.qrc create mode 100644 src/plugins/MouseGestures/mousegesturesplugin.cpp create mode 100644 src/plugins/MouseGestures/mousegesturesplugin.h create mode 100644 src/plugins/MouseGestures/mousegesturessettingsdialog.cpp create mode 100644 src/plugins/MouseGestures/mousegesturessettingsdialog.h create mode 100644 src/plugins/MouseGestures/mousegesturessettingsdialog.ui create mode 100644 src/plugins/MouseGestures/translations/cs_CZ.ts diff --git a/BUILDING b/BUILDING index 45141dc9e..8f158cef3 100644 --- a/BUILDING +++ b/BUILDING @@ -18,17 +18,6 @@ General 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 ---------------------------------------------------------------------------------- diff --git a/scripts/coding_style.sh b/scripts/coding_style.sh index 7ad48201a..63c1f9389 100755 --- a/scripts/coding_style.sh +++ b/scripts/coding_style.sh @@ -11,7 +11,7 @@ function format_sources { --align-pointer=type --align-reference=name \ `find -type f -name '*.cpp'` - rm */*.orig + find . -name "*.orig" -print0 | xargs -0 rm -rf } function format_headers { @@ -22,7 +22,7 @@ function format_headers { --align-pointer=type --align-reference=name \ `find -type f -name '*.h'` - rm */*.orig + find . -name "*.orig" -print0 | xargs -0 rm -rf } cd ../src diff --git a/scripts/cppcheck.sh b/scripts/cppcheck.sh index 02022ee2a..914194673 100755 --- a/scripts/cppcheck.sh +++ b/scripts/cppcheck.sh @@ -13,7 +13,13 @@ function check_code { echo "cppcheck..." -cd ../src +cd ../src/plugins +check_code + +cd ../lib/ +check_code + +cd ../main check_code read -p "Press [ENTER] to close terminal" diff --git a/scripts/plugin_translations.sh b/scripts/plugin_translations.sh index b8c0f0631..0e88c42b9 100755 --- a/scripts/plugin_translations.sh +++ b/scripts/plugin_translations.sh @@ -2,5 +2,7 @@ lupdate ../src/plugins/TestPlugin/TestPlugin.pro -no-obsolete +lupdate ../src/plugins/MouseGestures/MouseGestures.pro -no-obsolete + read -p "Press [ENTER] to close terminal" exit diff --git a/src/defines.pri b/src/defines.pri index aab603d39..c46f625d7 100644 --- a/src/defines.pri +++ b/src/defines.pri @@ -3,7 +3,7 @@ OBJECTS_DIR = $$PWD/../build MOC_DIR = $$PWD/../build RCC_DIR = $$PWD/../build UI_DIR = $$PWD/../build -VERSION = 1.1.8 +unix: VERSION = 1.1.8 # Please read BUILD information # #DEFINES += NO_SYSTEM_DATAPATH diff --git a/src/install.pri b/src/install.pri index 3906e0f18..2671aee8f 100644 --- a/src/install.pri +++ b/src/install.pri @@ -4,7 +4,7 @@ mac { bundle_target.files += $$PWD/../bin/locale 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 QMAKE_BUNDLE_DATA += bundle_target diff --git a/src/lib/app/qupzilla.cpp b/src/lib/app/qupzilla.cpp index 44f323d7f..b1f57b18c 100644 --- a/src/lib/app/qupzilla.cpp +++ b/src/lib/app/qupzilla.cpp @@ -531,7 +531,6 @@ void QupZilla::loadSettings() //Url settings settings.beginGroup("Web-URL-Settings"); m_homepage = settings.value("homepage", "qupzilla:start").toUrl(); - m_newtab = settings.value("newTabUrl", "qupzilla:speeddial").toUrl(); settings.endGroup(); QWebSettings* websettings = mApp->webSettings(); diff --git a/src/lib/app/qupzilla.h b/src/lib/app/qupzilla.h index c8117533b..d5ac627bf 100644 --- a/src/lib/app/qupzilla.h +++ b/src/lib/app/qupzilla.h @@ -113,6 +113,7 @@ public: inline QMenu* superMenu() { return m_superMenu; } inline bool isClosing() { return m_isClosing; } + inline QUrl homepageUrl() { return m_homepage; } signals: void loadHistory(); @@ -221,7 +222,6 @@ private: bool m_bookmarksMenuChanged; bool m_isClosing; QUrl m_startingUrl; - QUrl m_newtab; QUrl m_homepage; Qz::BrowserWindow m_startBehaviour; diff --git a/src/lib/preferences/pluginslist.ui b/src/lib/preferences/pluginslist.ui index a534f3871..af8354dc5 100644 --- a/src/lib/preferences/pluginslist.ui +++ b/src/lib/preferences/pluginslist.ui @@ -36,6 +36,9 @@ + + true + true diff --git a/src/lib/webview/tabbedwebview.cpp b/src/lib/webview/tabbedwebview.cpp index 1d7113d7a..ee61ea8f4 100644 --- a/src/lib/webview/tabbedwebview.cpp +++ b/src/lib/webview/tabbedwebview.cpp @@ -110,6 +110,11 @@ WebTab* TabbedWebView::webTab() const return m_webTab; } +TabWidget* TabbedWebView::tabWidget() const +{ + return m_tabWidget; +} + QString TabbedWebView::getIp() const { return m_currentIp; @@ -341,6 +346,11 @@ void TabbedWebView::openUrlInNewTab(const QUrl &url, Qz::NewTabPositionFlag posi m_tabWidget->addView(url, position); } +void TabbedWebView::openNewTab() +{ + m_tabWidget->addView(); +} + void TabbedWebView::getFocus(const QUrl &urla) { if (urla == url()) { diff --git a/src/lib/webview/tabbedwebview.h b/src/lib/webview/tabbedwebview.h index 77eaa6aa4..9771591ac 100644 --- a/src/lib/webview/tabbedwebview.h +++ b/src/lib/webview/tabbedwebview.h @@ -42,6 +42,7 @@ public: WebPage* webPage() const; WebTab* webTab() const; + TabWidget* tabWidget() const; QString getIp() const; QLabel* animationLoading(int index, bool addMovie); @@ -69,6 +70,8 @@ public slots: void loadingProgress(int prog); void closeView(); + void openUrlInNewTab(const QUrl &url, Qz::NewTabPositionFlag position); + void openNewTab(); private slots: void trackMouse(bool state) { m_mouseTrack = state; } @@ -82,7 +85,6 @@ private slots: void slotIconChanged(); void inspectElement(); - void openUrlInNewTab(const QUrl &url, Qz::NewTabPositionFlag position); private: void contextMenuEvent(QContextMenuEvent* event); diff --git a/src/lib/webview/webview.cpp b/src/lib/webview/webview.cpp index c4ffd89af..6924f0f4b 100644 --- a/src/lib/webview/webview.cpp +++ b/src/lib/webview/webview.cpp @@ -359,7 +359,14 @@ void WebView::showSiteInfo() void WebView::searchSelectedText() { - const QUrl &urlToLoad = mApp->searchEnginesManager()->searchUrl(selectedText()); + SearchEngine engine = mApp->searchEnginesManager()->activeEngine(); + if (QAction* act = qobject_cast(sender())) { + if (act->data().isValid()) { + engine = qVariantValue(act->data()); + } + } + + const QUrl &urlToLoad = mApp->searchEnginesManager()->searchUrl(engine, selectedText()); openUrlInNewTab(urlToLoad, Qz::NT_SelectedTab); } diff --git a/src/lib/webview/webview.h b/src/lib/webview/webview.h index 5c6f4ebef..14840656e 100644 --- a/src/lib/webview/webview.h +++ b/src/lib/webview/webview.h @@ -48,7 +48,6 @@ public: bool eventFilter(QObject* obj, QEvent* event); virtual QWidget* overlayForJsAlert() = 0; - virtual void openUrlInNewTab(const QUrl &url, Qz::NewTabPositionFlag position) = 0; static bool isUrlValid(const QUrl &url); static QUrl guessUrlFromString(const QString &string); @@ -73,6 +72,8 @@ public slots: void printPage(QWebFrame* frame = 0); virtual void closeView() = 0; + virtual void openUrlInNewTab(const QUrl &url, Qz::NewTabPositionFlag position) = 0; + virtual void openNewTab() { } protected slots: void slotLoadStarted(); diff --git a/src/main/appicon.rc b/src/main/appicon.rc index b7ed09c74..5df3f6ed9 100644 --- a/src/main/appicon.rc +++ b/src/main/appicon.rc @@ -1,7 +1,7 @@ #include "winver.h" -IDI_ICON1 ICON DISCARDABLE "data\icons\exeicons\qupzilla.ico" -IDI_ICON2 ICON DISCARDABLE "data\icons\exeicons\page.ico" +IDI_ICON1 ICON DISCARDABLE "..\lib\data\icons\exeicons\qupzilla.ico" +IDI_ICON2 ICON DISCARDABLE "..\lib\data\icons\exeicons\page.ico" VS_VERSION_INFO VERSIONINFO FILEVERSION 1,1,8,0 diff --git a/src/main/appicon_os2.rc b/src/main/appicon_os2.rc index 4645c5c1d..125533dc0 100644 --- a/src/main/appicon_os2.rc +++ b/src/main/appicon_os2.rc @@ -1,2 +1,2 @@ -ICON 1 "data\icons\exeicons\qupzilla_os2.ico" -ICON 2 "data\icons\exeicons\page_os2.ico" +ICON 1 "..\lib\data\icons\exeicons\qupzilla_os2.ico" +ICON 2 "..\lib\data\icons\exeicons\page_os2.ico" diff --git a/src/plugins/MouseGestures/3rdparty/QjtMouseGesture.cpp b/src/plugins/MouseGestures/3rdparty/QjtMouseGesture.cpp new file mode 100644 index 000000000..5cb27a508 --- /dev/null +++ b/src/plugins/MouseGestures/3rdparty/QjtMouseGesture.cpp @@ -0,0 +1,57 @@ +/* + * This file is part of the mouse gesture package. + * Copyright (C) 2006 Johan Thelin + * 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; +} diff --git a/src/plugins/MouseGestures/3rdparty/QjtMouseGesture.h b/src/plugins/MouseGestures/3rdparty/QjtMouseGesture.h new file mode 100644 index 000000000..32c6ba751 --- /dev/null +++ b/src/plugins/MouseGestures/3rdparty/QjtMouseGesture.h @@ -0,0 +1,117 @@ +/* + * This file is part of the mouse gesture package. + * Copyright (C) 2006 Johan Thelin + * 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 +#include + +#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 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 diff --git a/src/plugins/MouseGestures/3rdparty/QjtMouseGestureFilter.cpp b/src/plugins/MouseGestures/3rdparty/QjtMouseGestureFilter.cpp new file mode 100644 index 000000000..f571cf934 --- /dev/null +++ b/src/plugins/MouseGestures/3rdparty/QjtMouseGestureFilter.cpp @@ -0,0 +1,233 @@ +/* + * This file is part of the mouse gesture package. + * Copyright (C) 2006 Johan Thelin + * 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 +#include +#include +#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 GestureList; +typedef QList 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(event), obj)) { + return true; + } + + break; + + case QEvent::MouseButtonRelease: + if (mouseButtonReleaseEvent(dynamic_cast(event), obj)) { + return true; + } + + break; + + case QEvent::MouseMove: + if (mouseMoveEvent(dynamic_cast(event), obj)) { + return true; + } + + break; + + case QEvent::Paint: + if (paintEvent(obj, dynamic_cast(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(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(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(obj)->update(); + } + + return false; +} + +bool QjtMouseGestureFilter::paintEvent(QObject* obj, QPaintEvent* event) +{ + Q_UNUSED(event) + if (d->tracing) { + QWidget* wid = static_cast(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 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; + } +} diff --git a/src/plugins/MouseGestures/3rdparty/QjtMouseGestureFilter.h b/src/plugins/MouseGestures/3rdparty/QjtMouseGestureFilter.h new file mode 100644 index 000000000..0431a4ff5 --- /dev/null +++ b/src/plugins/MouseGestures/3rdparty/QjtMouseGestureFilter.h @@ -0,0 +1,94 @@ +/* + * This file is part of the mouse gesture package. + * Copyright (C) 2006 Johan Thelin + * 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 +#include +#include + +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 + diff --git a/src/plugins/MouseGestures/3rdparty/adv_recognizer.cpp b/src/plugins/MouseGestures/3rdparty/adv_recognizer.cpp new file mode 100644 index 000000000..d7201caac --- /dev/null +++ b/src/plugins/MouseGestures/3rdparty/adv_recognizer.cpp @@ -0,0 +1,170 @@ +/* + * This file is part of the mouse gesture package. + * Copyright (C) 2006 Johan Thelin + * 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 + +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(); + } +} diff --git a/src/plugins/MouseGestures/3rdparty/adv_recognizer.h b/src/plugins/MouseGestures/3rdparty/adv_recognizer.h new file mode 100644 index 000000000..ef6376bfe --- /dev/null +++ b/src/plugins/MouseGestures/3rdparty/adv_recognizer.h @@ -0,0 +1,77 @@ +/* + * This file is part of the mouse gesture package. + * Copyright (C) 2006 Johan Thelin + * 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 directions; + GestureList gestures; + + + int minimumMovement2; + double minimumMatch; + bool allowDiagonals; + + int lastX, lastY; + Direction lastDirection; +}; + +}; //end Gesture + +#endif // REAL_TIME_RECOGNIZER_H diff --git a/src/plugins/MouseGestures/3rdparty/mousegesturerecognizer.cpp b/src/plugins/MouseGestures/3rdparty/mousegesturerecognizer.cpp new file mode 100644 index 000000000..3d4d8a39a --- /dev/null +++ b/src/plugins/MouseGestures/3rdparty/mousegesturerecognizer.cpp @@ -0,0 +1,409 @@ +/* + * This file is part of the mouse gesture package. + * Copyright (C) 2006 Johan Thelin + * 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; +} + diff --git a/src/plugins/MouseGestures/3rdparty/mousegesturerecognizer.h b/src/plugins/MouseGestures/3rdparty/mousegesturerecognizer.h new file mode 100644 index 000000000..65641159b --- /dev/null +++ b/src/plugins/MouseGestures/3rdparty/mousegesturerecognizer.h @@ -0,0 +1,116 @@ +/* + * This file is part of the mouse gesture package. + * Copyright (C) 2006 Johan Thelin + * 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 +#include + +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 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 PosList; +typedef std::vector 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 + diff --git a/src/plugins/MouseGestures/3rdparty/ring_buffer.h b/src/plugins/MouseGestures/3rdparty/ring_buffer.h new file mode 100644 index 000000000..5fcac9d56 --- /dev/null +++ b/src/plugins/MouseGestures/3rdparty/ring_buffer.h @@ -0,0 +1,130 @@ +/* + * This file is part of the mouse gesture package. + * Copyright (C) 2006 Johan Thelin + * 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 + +/* +* Implementation of Ring Buffer +*/ +template +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 diff --git a/src/plugins/MouseGestures/3rdparty/src.pro b/src/plugins/MouseGestures/3rdparty/src.pro new file mode 100644 index 000000000..8c780078c --- /dev/null +++ b/src/plugins/MouseGestures/3rdparty/src.pro @@ -0,0 +1,48 @@ +# This file is part of the mouse gesture package. +# Copyright (C) 2006 Johan Thelin +# 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 diff --git a/src/plugins/MouseGestures/MouseGestures.pro b/src/plugins/MouseGestures/MouseGestures.pro new file mode 100644 index 000000000..346431f0e --- /dev/null +++ b/src/plugins/MouseGestures/MouseGestures.pro @@ -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 diff --git a/src/plugins/MouseGestures/data/copyright b/src/plugins/MouseGestures/data/copyright new file mode 100644 index 000000000..c7b0780db --- /dev/null +++ b/src/plugins/MouseGestures/data/copyright @@ -0,0 +1,34 @@ +Mouse gestures recognition algorithm is under following license: + +Copyright (C) 2006 Johan Thelin +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. diff --git a/src/plugins/MouseGestures/data/down-left.gif b/src/plugins/MouseGestures/data/down-left.gif new file mode 100644 index 0000000000000000000000000000000000000000..e607d3eaff18e5b9f4b9128af4240c83b28ff67d GIT binary patch literal 361 zcmV-v0hazpNk%w1VJ-kK0J8u9^z`(kq@?EN=EB0ly}iAbmX@BLp4{Br&d$z>iHUuE zeaXqmv$M0Yv9Zg`%m4rXA^8LV00000EC2ui04@M8000F4@JZpSy*TS#g_J;0G-PR> zXsVJ$07wP#&2(+wHc>oBfd9Z?;6NAzkI2t}z*r=ozy+fTt=gnit5$+_Za)BnLXnXD zy5CP>%r@W9=>wacI8VJ_!klf-eiwUVeRx{{fd+$V5(sk%9yoA{0t5*RFNumDLqU<5 z1_zvXnIE5_ex9IFqN5L`s;7#sn4_|gtF)=JsHTLmxwf!rwQsk(uf1uGysU;tooNU@ z%RvZkI0*>O#W#%BIXl|HG>i(~G?b6i+-wa8?(YW(3<(D5>NezL2K)T`1oq*OjT>Wb z%QJlCSRKSyP|HGA#Kb|ovTY)5&o0CIbx?I}$+jAjF6jC{w0racKgFmoPV^ HivR#SI!CD} literal 0 HcmV?d00001 diff --git a/src/plugins/MouseGestures/data/down-right.gif b/src/plugins/MouseGestures/data/down-right.gif new file mode 100644 index 0000000000000000000000000000000000000000..9d2e2692fbc76e77bb686b260edd162060b08592 GIT binary patch literal 434 zcmZ?wbhEHb)ML6y{&hSUkbOW&I6trHvLT`!6t`<<=8F z8oT*dtD3U#1dk&hqc^SBkSbBAm2k-ogx7^tT0y$qL-g9*f;1c}g@#y}t z%6Xq}C`vwHIK;%vDx{^eA)$Yt@s~cHfCmc}9qpPcC-jh=Eq-6a^EVGJa|AA!RS|BX z|ENf`XsO^-y`v$8lBwLbg76t}u E0B;Gq0{{R3 literal 0 HcmV?d00001 diff --git a/src/plugins/MouseGestures/data/down-up.gif b/src/plugins/MouseGestures/data/down-up.gif new file mode 100644 index 0000000000000000000000000000000000000000..53b5c92bf8d45ac5b7985964b92fd5e489ce2f1e GIT binary patch literal 417 zcmV;S0bc$`Nk%w1VJ-kK0J8u9|NsB@_xJDb@8{>|+uPg9%F4pR!oI$~va+(Krlz8z zqMn|fmX?;1l9GmohJAf~A^8LV2LS&7EC2ui04@M8000F45Xe!gy*TS#hm=9mAY^Ht zXsVJ;5=hPQ&2(+w_Q3!|g8#r^f^d)pk4TAuR7g631?F>Viz1rTti+1dQn}umKoA6n zXT`Gg3~D$$KQm51fd2xG$KxGe-w=8a40bhmfqP^(ay5X53@LE1EzHr}k%+txSa#^&MNGwQW!=;O@U>@(ug_22g&`Q7_~An3Qn z-3Jm#8U#ev%fkCjtOFkjKM+ literal 0 HcmV?d00001 diff --git a/src/plugins/MouseGestures/data/down.gif b/src/plugins/MouseGestures/data/down.gif new file mode 100644 index 0000000000000000000000000000000000000000..2c4d00ce403bce493b5a7535bfda9e7fc32b870f GIT binary patch literal 328 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 N002ovPDHLkV1f<76&wHn literal 0 HcmV?d00001 diff --git a/src/plugins/MouseGestures/data/left.gif b/src/plugins/MouseGestures/data/left.gif new file mode 100644 index 0000000000000000000000000000000000000000..c467c9586821f8abbdb0a15a9634e15123da4c40 GIT binary patch literal 315 zcmV-B0mS}CNk%w1VJ-kK0J8u9ii(Qn=H`}`mY$xTy}iAzuCCtR-le6b*4Ea+!NGlf zeaXqmv$M0Yv9Zg`%m4rXA^8LV00000EC2ui04@M8000E&@X6q+y*TS#gZzWgjAUt^ zXgUgq_Xxx%&vb3qiSQuD?f<|7f{*|jkDmmAu|PV13kLH^twpERtmN9%X1U(4v>Sec z%jPjUja?tlZX-MnRnvjvlh11&zv zebRc=ch+>+aoTR&Yu;$!W#VDvUglcpVxxe`3`FfVN<8s3LJtEm^&hMtA}Rm_qF~`- N0*8YLHx!Hj06UeVlgj`A literal 0 HcmV?d00001 diff --git a/src/plugins/MouseGestures/data/right.gif b/src/plugins/MouseGestures/data/right.gif new file mode 100644 index 0000000000000000000000000000000000000000..8c1289852fa35146a17c0e46c9e5a3682afdda67 GIT binary patch literal 322 zcmV-I0lof5Nk%w1VJ-kK0J8u9q@<*WhljqtzUJoUmzS5Go}Sy=+peyz&d$#B^YeXu zeaXqmv$M0y%geE`vH$=7A^8LV00000EC2ui04@M8000E<@X67ty*TS#hm;9GIAm#_ zXsVI~kVu5^&2(+wwm>`vfd9ZCz#xzXk4Q<8u}C_B3kLH^wMD1ZtmN9%X1U(4v>Sec z%jPjUja?(p?jt-7Rnvp>`z^1p@%uA>9|8di3I#7g0|<3(H3Ei_0f|2b3XC{{4~3D2 zn3bNHb~c@n1x2W-s0Wb@d!sd_h5)Ly0<5#Ijx@NElsJ|O2co+(2?dfKL6*bBWH$o_ z2EUcf&Vbk0R2B+5?P%|1@nKO#-H!r2_cTKfr~66@fDo~w Upg|Qaeo^4Su%QNJ4{bfd9Z?;2;fKMa3B1qymmQ(iv_3V=TX28EA>K5hV% zSD8Qogh!%|Sw9AiM@y!VIH^gjKZZB3NU}JzHnyuWv!JM|LAW=%HN3;VxxlZ&K*XP? z&9TbG%(c#y)zPll)U83t&)YS|9|r&m00^Ep(B;=N4QFOM$>2BX^a`Um?=@!2I z#=jW>2P!B?`*!Wx zwQ19)Wy_W=TC`~1ym`~6P3!9Fs;#XB>LL>8FaQC_E(X?r3JQGgne#GMt$V7_#q?RH zB=>&By378`9eqc#J#?h{kF_udBq+?kps{#@gUk9G;z}DWQube9KFh5qel<uU0i@ z-b1DvWldc~KK=Y5yYqQ_iAPzj0AE{s8<$>uqkFR;H|wOytZdw^-Qm4`wT14S0y7h< zYbyLX`6FgG&GQgoo3*5#fsJ=#=4J*)!R>jQ7Y44bTx~$ru*%zyKeW>9;P3^a`D>p!!K{WE($(%Ih%O_xBaX0+5LhC-u+5r`64Ni zcyfPbDxZMN41UEKEZo0M{x~ZrwRG0Y>ExvHEttu`$5Hs^g~9ag(s%a^G`mn=p&*QI|@yuL&t!=FWf?bvFB@xVg0^Dq@Q>U?Vch!6J z1u_dbd2n_&0Ez7#+sb19`pC@Z}eyNKFqMo{rJgK z2hN;0eA?~o$t$kcE?>BMY2OW(TleqWyjSzU`O)(y51;LP^YUH(3w_^nUl^FU7wA1c z>Nejbx9a=)4(7(LIsubVmW4`fX)i2$CS>vMb>ZM#qwSG06mc&2$}ke#)-{iLAIB(2zs{0XsVKcfk?ve z&2(+w_8>fof&ajuA#soek4VYjuwW#gK*pj8t=gnit5$+_ZnfPncfc6PmqafkBEeplbCjjRg{^In~jE? zNs>vRotmkpNT^7vr=FLji>^noK@0!@qOY_^2mpEjFRQ;m1A1+^IJ!6j%nCcmP}0oR zv#dY{(>~Tu0n;AgPX)vZ0E3}ok-_e{@bOXe^w0M9R|`e@u?Ic;9U1ZffHQ#)1^@sd WVuizpDq0+yz@ehW4dot00027!$)SJ% literal 0 HcmV?d00001 diff --git a/src/plugins/MouseGestures/mousegestures.cpp b/src/plugins/MouseGestures/mousegestures.cpp new file mode 100644 index 000000000..4e403d2d2 --- /dev/null +++ b/src/plugins/MouseGestures/mousegestures.cpp @@ -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(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; +} diff --git a/src/plugins/MouseGestures/mousegestures.h b/src/plugins/MouseGestures/mousegestures.h new file mode 100644 index 000000000..4ddc52633 --- /dev/null +++ b/src/plugins/MouseGestures/mousegestures.h @@ -0,0 +1,42 @@ +#ifndef MOUSEGESTURES_H +#define MOUSEGESTURES_H + +#include +#include +#include + +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 diff --git a/src/plugins/MouseGestures/mousegestures.qrc b/src/plugins/MouseGestures/mousegestures.qrc new file mode 100644 index 000000000..6c32ed935 --- /dev/null +++ b/src/plugins/MouseGestures/mousegestures.qrc @@ -0,0 +1,17 @@ + + + data/icon.png + data/down.gif + data/down-left.gif + data/down-right.gif + data/down-up.gif + data/left.gif + data/right.gif + data/up.gif + data/up-down.gif + data/up-left.gif + data/up-right.gif + data/copyright + locale/cs_CZ.qm + + diff --git a/src/plugins/MouseGestures/mousegesturesplugin.cpp b/src/plugins/MouseGestures/mousegesturesplugin.cpp new file mode 100644 index 000000000..9f757d45f --- /dev/null +++ b/src/plugins/MouseGestures/mousegesturesplugin.cpp @@ -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 "; + 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) diff --git a/src/plugins/MouseGestures/mousegesturesplugin.h b/src/plugins/MouseGestures/mousegesturesplugin.h new file mode 100644 index 000000000..be11365a8 --- /dev/null +++ b/src/plugins/MouseGestures/mousegesturesplugin.h @@ -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 diff --git a/src/plugins/MouseGestures/mousegesturessettingsdialog.cpp b/src/plugins/MouseGestures/mousegesturessettingsdialog.cpp new file mode 100644 index 000000000..0a5a10032 --- /dev/null +++ b/src/plugins/MouseGestures/mousegesturessettingsdialog.cpp @@ -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(); +} diff --git a/src/plugins/MouseGestures/mousegesturessettingsdialog.h b/src/plugins/MouseGestures/mousegesturessettingsdialog.h new file mode 100644 index 000000000..683cc7f6d --- /dev/null +++ b/src/plugins/MouseGestures/mousegesturessettingsdialog.h @@ -0,0 +1,27 @@ +#ifndef MOUSEGESTURESSETTINGSDIALOG_H +#define MOUSEGESTURESSETTINGSDIALOG_H + +#include +#include + +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 diff --git a/src/plugins/MouseGestures/mousegesturessettingsdialog.ui b/src/plugins/MouseGestures/mousegesturessettingsdialog.ui new file mode 100644 index 000000000..63c0bcb8b --- /dev/null +++ b/src/plugins/MouseGestures/mousegesturessettingsdialog.ui @@ -0,0 +1,267 @@ + + + MouseGesturesSettingsDialog + + + + 0 + 0 + 502 + 325 + + + + Mouse Gestures + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + :/mousegestures/data/icon.png + + + + + + + <h1>Mouse Gestures</h1> + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + 20 + + + 20 + + + + + + 0 + 0 + + + + :/mousegestures/data/up.gif + + + + + + + <b>Stop</b><br/>Stop loading page + + + + + + + :/mousegestures/data/down.gif + + + + + + + <b>New tab</b><br/>Open new tab + + + + + + + :/mousegestures/data/left.gif + + + + + + + <b>Back</b><br/>Go back in history + + + + + + + :/mousegestures/data/right.gif + + + + + + + <b>Forward</b><br/>Go forward in history + + + + + + + + 0 + 0 + + + + :/mousegestures/data/up-down.gif + + + + + + + <b>Reload</b><br/>Reload page + + + + + + + :/mousegestures/data/down-right.gif + + + + + + + <b>Close tab</b><br/>Close current tab + + + + + + + :/mousegestures/data/down-left.gif + + + + + + + <b>Home</b><br/>Go to homepage + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + License + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Close + + + + + + + + + + + + + buttonBox + accepted() + MouseGesturesSettingsDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + MouseGesturesSettingsDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/src/plugins/MouseGestures/translations/cs_CZ.ts b/src/plugins/MouseGestures/translations/cs_CZ.ts new file mode 100644 index 000000000..aae5eb140 --- /dev/null +++ b/src/plugins/MouseGestures/translations/cs_CZ.ts @@ -0,0 +1,62 @@ + + + + + MouseGesturesSettingsDialog + + + Mouse Gestures + Gesta myší + + + + <h1>Mouse Gestures</h1> + <h1>Gesta myší</h1> + + + + <b>Stop</b><br/>Stop loading page + <b>Zastavit</b><br/>Zastavit načítání stránky + + + + <b>New tab</b><br/>Open new tab + <b>Nový panel</b><br/>Otevřít nový panel + + + + <b>Back</b><br/>Go back in history + <b>Zpět</b><br/>Přejít zpět v historii + + + + <b>Forward</b><br/>Go forward in history + <b>Vpřed</b><br/>Přejít vpřed v historii + + + + <b>Reload</b><br/>Reload page + <b>Obnovit</b><br/>Obnovit stránku + + + + <b>Close tab</b><br/>Close current tab + <b>Zavřít panel</b><br/>Zavřít aktuální panel + + + + <b>Home</b><br/>Go to homepage + <b>Domů</b><br/>Přejít na domovskou stránku + + + + License + Licence + + + + License Viewer + Prohlížeč licence + + + diff --git a/src/plugins/TestPlugin/testplugin.cpp b/src/plugins/TestPlugin/testplugin.cpp index be0fccff2..bfbd702e3 100644 --- a/src/plugins/TestPlugin/testplugin.cpp +++ b/src/plugins/TestPlugin/testplugin.cpp @@ -3,6 +3,15 @@ #include "webview.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 spec; @@ -26,7 +35,6 @@ void TestPlugin::init(const QString &sPath) // so it is recommended not to call any QupZilla function here m_settingsPath = sPath; - m_view = 0; QZ_REGISTER_EVENT_HANDLER(PluginProxy::MousePressHandler); } diff --git a/src/plugins/TestPlugin/testplugin.h b/src/plugins/TestPlugin/testplugin.h index 2854f9da7..cf56e6ff8 100644 --- a/src/plugins/TestPlugin/testplugin.h +++ b/src/plugins/TestPlugin/testplugin.h @@ -21,6 +21,7 @@ class TestPlugin : public QObject, public PluginInterface Q_INTERFACES(PluginInterface) public: + explicit TestPlugin(); PluginSpec pluginSpec(); void init(const QString &sPath); diff --git a/src/plugins/TestPlugin/translations/cs_CZ.ts b/src/plugins/TestPlugin/translations/cs_CZ.ts index d48590965..7c042b754 100644 --- a/src/plugins/TestPlugin/translations/cs_CZ.ts +++ b/src/plugins/TestPlugin/translations/cs_CZ.ts @@ -4,27 +4,27 @@ TestPlugin - + Close Zavřít - + Example Plugin Settings Nastavení ukázkového doplňku - + My first plugin action Moje první akce z doplňku - + Hello Ahoj - + First plugin action works :-) První akce funguje :-) diff --git a/src/plugins/TestPlugin/translations/de_DE.ts b/src/plugins/TestPlugin/translations/de_DE.ts index f8cc94fdf..3bd0466d5 100644 --- a/src/plugins/TestPlugin/translations/de_DE.ts +++ b/src/plugins/TestPlugin/translations/de_DE.ts @@ -4,27 +4,27 @@ TestPlugin - + Close - + Example Plugin Settings - + My first plugin action Meine erste Aktion - + Hello Hallo - + First plugin action works :-) Meine erste Aktion funktioniert :-) diff --git a/src/plugins/TestPlugin/translations/el_GR.ts b/src/plugins/TestPlugin/translations/el_GR.ts index ec515b47a..0065502cf 100644 --- a/src/plugins/TestPlugin/translations/el_GR.ts +++ b/src/plugins/TestPlugin/translations/el_GR.ts @@ -4,27 +4,27 @@ TestPlugin - + Close - + Example Plugin Settings - + My first plugin action Η ενέργεια του πρώτου μου προσθέτου - + Hello Γεια - + First plugin action works :-) Η ενέργεια του πρώτου προσθέτου δουλεύει :-) diff --git a/src/plugins/TestPlugin/translations/id_ID.ts b/src/plugins/TestPlugin/translations/id_ID.ts index 045820578..74d6e685e 100644 --- a/src/plugins/TestPlugin/translations/id_ID.ts +++ b/src/plugins/TestPlugin/translations/id_ID.ts @@ -4,27 +4,27 @@ TestPlugin - + Close Tutup - + Example Plugin Settings Pengaturan Contoh Pengaya - + My first plugin action Aksi pengaya pertama saya - + Hello Halo - + First plugin action works :-) Aksi pengaya pertama saya bekerja :-) diff --git a/src/plugins/TestPlugin/translations/sk_SK.ts b/src/plugins/TestPlugin/translations/sk_SK.ts index c610d2f6d..2e34e171a 100644 --- a/src/plugins/TestPlugin/translations/sk_SK.ts +++ b/src/plugins/TestPlugin/translations/sk_SK.ts @@ -4,27 +4,27 @@ TestPlugin - + Close - + Example Plugin Settings - + My first plugin action Moje první akce z doplnku - + Hello Ahoj - + First plugin action works :-) První doplnek funguje :-) diff --git a/src/plugins/TestPlugin/translations/sr_BA.ts b/src/plugins/TestPlugin/translations/sr_BA.ts index d27cd87ec..ef43b4841 100644 --- a/src/plugins/TestPlugin/translations/sr_BA.ts +++ b/src/plugins/TestPlugin/translations/sr_BA.ts @@ -4,27 +4,27 @@ TestPlugin - + Close Затвори - + Example Plugin Settings Подешавања пробног прикључка - + My first plugin action Радња мог првог прикључка - + Hello Здраво - + First plugin action works :-) Радња прикључка ради :-) diff --git a/src/plugins/TestPlugin/translations/sr_RS.ts b/src/plugins/TestPlugin/translations/sr_RS.ts index d27cd87ec..ef43b4841 100644 --- a/src/plugins/TestPlugin/translations/sr_RS.ts +++ b/src/plugins/TestPlugin/translations/sr_RS.ts @@ -4,27 +4,27 @@ TestPlugin - + Close Затвори - + Example Plugin Settings Подешавања пробног прикључка - + My first plugin action Радња мог првог прикључка - + Hello Здраво - + First plugin action works :-) Радња прикључка ради :-) diff --git a/src/plugins/TestPlugin/translations/zh_CN.ts b/src/plugins/TestPlugin/translations/zh_CN.ts index f92825872..7266f64b9 100644 --- a/src/plugins/TestPlugin/translations/zh_CN.ts +++ b/src/plugins/TestPlugin/translations/zh_CN.ts @@ -4,34 +4,27 @@ TestPlugin - - Example Plugin - 示范应用扩展 + + Close + - - Example minimal plugin - 用来做示范的小型应用扩展 + + Example Plugin Settings + - - Very simple minimal plugin example - 非常简单的应用括展示范 - - - - - + My first plugin action 我的第一个动作应用扩展 - + Hello 哈啰 - + First plugin action works :-) 我的第一个动作应用扩展运行了:-) diff --git a/src/plugins/TestPlugin/translations/zh_TW.ts b/src/plugins/TestPlugin/translations/zh_TW.ts index c9fdaf11d..9b9a37afb 100644 --- a/src/plugins/TestPlugin/translations/zh_TW.ts +++ b/src/plugins/TestPlugin/translations/zh_TW.ts @@ -4,34 +4,27 @@ TestPlugin - - Example Plugin - 範例外掛 + + Close + - - Example minimal plugin - 用來做示範的極小外掛 + + Example Plugin Settings + - - Very simple minimal plugin example - 非常簡單的外掛範例 - - - - - + My first plugin action 我的第一個動作外掛 - + Hello 哈囉 - + First plugin action works :-) 我的第一個動作外掛運作了:-) diff --git a/src/plugins/plugins.pro b/src/plugins/plugins.pro index fe7f4d449..2e1556e35 100644 --- a/src/plugins/plugins.pro +++ b/src/plugins/plugins.pro @@ -1,2 +1,2 @@ TEMPLATE = subdirs -SUBDIRS = TestPlugin +SUBDIRS = TestPlugin MouseGestures diff --git a/src/src.pro b/src/src.pro index 59cb83bda..157ad45f8 100644 --- a/src/src.pro +++ b/src/src.pro @@ -1,5 +1,3 @@ TEMPLATE = subdirs -SUBDIRS = lib main -build_plugins: SUBDIRS += plugins - +SUBDIRS = lib main plugins CONFIG += ordered diff --git a/translations/homepage/fr_FR.php b/translations/homepage/fr_FR.php index 4260771e1..c1f1eb724 100644 --- a/translations/homepage/fr_FR.php +++ b/translations/homepage/fr_FR.php @@ -2,7 +2,7 @@ // Header + Footer $site_title = "QupZilla - Un navigateur web lger et multi-plateforme"; $qupzilla = "QupZilla"; -$header_description = "Navigateur web" +$header_description = "Navigateur web"; $menu_home = "Accueil"; $menu_screenshots = "Screenshots"; @@ -10,7 +10,7 @@ $menu_download = "T $menu_faq = "FAQ"; $menu_about = "Contribuer"; $footer_site = "www.qupzilla.com"; -$translated_by = ""; // "Page traduite par eyome et lamessen" +$translated_by = "Page traduite par Jrme Giry et Nicolas Ourceau"; //Home Page $actual_version = "Version actuelle"; @@ -25,7 +25,7 @@ $reportbug_text = "Avez-vous trouv Pour le rapporter, faites un rapport de bug sur GitHub."; $reportbug_button = "Rapporter"; $technology = "Technologie"; -$technology_text = "QupZilla est un navigateur web bas sur le moteur de rendu WebKit et sur le framework Qt. WebKit garantie une navigation rapide +$technology_text = "QupZilla est un navigateur web bas sur le moteur de rendu WebKit et sur le framework Qt. WebKit garantie une navigation rapide et Qt une disponibilit sur toutes les plateformes majeures."; $technology_button = "WebKit & Qt"; $looknfeel_header = "Style et comportements natifs"; @@ -57,7 +57,7 @@ $download_snapshot = "T // Contribute Page $contribute_to = "Contribuer QupZilla"; -$contribute_text = "QupZilla est un projet Open Source, donc votre aide est la bienvenue ! Je serais trs heureux d'inclure les patches que vous m'enverriez. Mais coder +$contribute_text = "QupZilla est un projet Open Source, donc votre aide est la bienvenue ! Je serais trs heureux d'inclure les patches que vous m'enverriez. Mais coder n'est pas la seule manire d'aider : vous pouvez traduire QupZilla dans votre langue ou juste en parler vos amis. Souvenez-vous, toutes les participations (mmes petites) sont hautement apprcies"; $getting_source = "Obtenir le fichier source"; $getting_source_text1 = "La faon la plus simple d'obtenir les sources de QupZilla est de les cloner partir du dpt sur GitHub. Vous pouvez le faire en utilisant cette commande"; @@ -70,4 +70,4 @@ $creators_text = "Le responsable du projet, mainteneur et d Outre le codage, d'autres contributeurs participent galement en ralisant les traductions ou en soutenant QupZilla. La liste complte des contributeurs peut tre trouve ici [sur GitHub].

Vous pouvez aussi rejoindre le canal IRC #qupzilla sur irc.freenode.net pour discuter avec les gens impliqus dans QupZilla."; $share_with_friends = "Partagez avec vos amis!"; $share_with_friends_text = "Vous aimez QupZilla ? Alors partagez-le avec vos amis !!" -?> \ No newline at end of file +?>