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

MouseGestures: Added 2 new gestures for switching tabs

- up + right and up + left
This commit is contained in:
nowrep 2012-09-08 20:10:41 +02:00
parent 398c1ffdd6
commit 14c2166e57
3 changed files with 76 additions and 19 deletions

View File

@ -16,8 +16,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* ============================================================ */
#include "mousegestures.h"
#include "webview.h"
#include "webpage.h"
#include "tabbedwebview.h"
#include "tabwidget.h"
#include "mainapplication.h"
#include "qupzilla.h"
#include "mousegesturessettingsdialog.h"
@ -54,6 +55,12 @@ MouseGestures::MouseGestures(QObject* parent) :
QjtMouseGesture* upDownGesture = new QjtMouseGesture(DirectionList() << Up << Down, m_filter);
connect(upDownGesture, SIGNAL(gestured()), this, SLOT(upDownGestured()));
QjtMouseGesture* upLeftGesture = new QjtMouseGesture(DirectionList() << Up << Left, m_filter);
connect(upLeftGesture, SIGNAL(gestured()), this, SLOT(upLeftGestured()));
QjtMouseGesture* upRightGesture = new QjtMouseGesture(DirectionList() << Up << Right, m_filter);
connect(upRightGesture, SIGNAL(gestured()), this, SLOT(upRightGestured()));
m_filter->addGesture(upGesture);
m_filter->addGesture(downGesture);
m_filter->addGesture(leftGesture);
@ -62,6 +69,8 @@ MouseGestures::MouseGestures(QObject* parent) :
m_filter->addGesture(downRightGesture);
m_filter->addGesture(downLeftGesture);
m_filter->addGesture(upDownGesture);
m_filter->addGesture(upLeftGesture);
m_filter->addGesture(upRightGesture);
}
bool MouseGestures::mousePress(QObject* obj, QMouseEvent* event)
@ -165,6 +174,26 @@ void MouseGestures::upDownGestured()
m_view.data()->reload();
}
void MouseGestures::upLeftGestured()
{
TabbedWebView* view = qobject_cast<TabbedWebView*>(m_view.data());
if (!view) {
return;
}
view->tabWidget()->previousTab();
}
void MouseGestures::upRightGestured()
{
TabbedWebView* view = qobject_cast<TabbedWebView*>(m_view.data());
if (!view) {
return;
}
view->tabWidget()->nextTab();
}
MouseGestures::~MouseGestures()
{
m_filter->clearGestures(true);

View File

@ -49,8 +49,8 @@ private slots:
void downLeftGestured();
void upDownGestured();
// void upLeftGestured();
// void upRightGestured();
void upLeftGestured();
void upRightGestured();
private:
QjtMouseGestureFilter* m_filter;

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>502</width>
<height>355</height>
<height>420</height>
</rect>
</property>
<property name="windowTitle">
@ -140,20 +140,6 @@
</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">
@ -189,19 +175,61 @@
</widget>
</item>
<item row="2" column="2">
<widget class="QLabel" name="label_6">
<property name="pixmap">
<pixmap resource="mousegestures.qrc">:/mousegestures/data/right.gif</pixmap>
</property>
</widget>
</item>
<item row="2" column="3">
<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="3" column="1">
<widget class="QLabel" name="label_19">
<property name="text">
<string>&lt;b&gt;Previous tab&lt;/b&gt;&lt;br/&gt;Switch to previous tab</string>
</property>
</widget>
</item>
<item row="4" column="0">
<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">
<item row="4" column="1">
<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>
<item row="3" column="2">
<widget class="QLabel" name="label_20">
<property name="pixmap">
<pixmap resource="mousegestures.qrc">:/mousegestures/data/up-right.gif</pixmap>
</property>
</widget>
</item>
<item row="3" column="3">
<widget class="QLabel" name="label_21">
<property name="text">
<string>&lt;b&gt;Next tab&lt;/b&gt;&lt;br/&gt;Switch to next tab</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_18">
<property name="pixmap">
<pixmap resource="mousegestures.qrc">:/mousegestures/data/up-left.gif</pixmap>
</property>
</widget>
</item>
</layout>
</item>
<item>