mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 18:56:34 +01:00
[MouseGestures] Implement "Rocker navigation"
Left+Right click - Forward Right+Left click - Back It is currently disabled by default and there is no GUI to enable it.
This commit is contained in:
parent
6874df57d7
commit
f69c8645fb
@ -28,9 +28,13 @@
|
|||||||
|
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
#include <QWebFrame>
|
#include <QWebFrame>
|
||||||
|
#include <QWebHistory>
|
||||||
|
|
||||||
MouseGestures::MouseGestures(QObject* parent) :
|
MouseGestures::MouseGestures(QObject* parent)
|
||||||
QObject(parent)
|
: QObject(parent)
|
||||||
|
, m_blockNextRightMouseRelease(false)
|
||||||
|
, m_blockNextLeftMouseRelease(false)
|
||||||
|
, m_enableRockerNavigation(false)
|
||||||
{
|
{
|
||||||
m_filter = new QjtMouseGestureFilter(false, Qt::MiddleButton, 20);
|
m_filter = new QjtMouseGestureFilter(false, Qt::MiddleButton, 20);
|
||||||
|
|
||||||
@ -85,6 +89,25 @@ bool MouseGestures::mousePress(QObject* obj, QMouseEvent* event)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_enableRockerNavigation && event->buttons() == (Qt::RightButton | Qt::LeftButton)) {
|
||||||
|
bool accepted = false;
|
||||||
|
|
||||||
|
if (event->button() == Qt::LeftButton && m_view.data()->history()->canGoBack()) {
|
||||||
|
m_view.data()->back();
|
||||||
|
accepted = true;
|
||||||
|
}
|
||||||
|
else if (event->button() == Qt::RightButton && m_view.data()->history()->canGoForward()) {
|
||||||
|
m_view.data()->forward();
|
||||||
|
accepted = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (accepted) {
|
||||||
|
m_blockNextLeftMouseRelease = true;
|
||||||
|
m_blockNextRightMouseRelease = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
m_filter->mouseButtonPressEvent(event);
|
m_filter->mouseButtonPressEvent(event);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -94,6 +117,16 @@ bool MouseGestures::mouseRelease(QObject* obj, QMouseEvent* event)
|
|||||||
{
|
{
|
||||||
Q_UNUSED(obj)
|
Q_UNUSED(obj)
|
||||||
|
|
||||||
|
if (m_blockNextRightMouseRelease && event->button() == Qt::RightButton) {
|
||||||
|
m_blockNextRightMouseRelease = false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_blockNextLeftMouseRelease && event->button() == Qt::LeftButton) {
|
||||||
|
m_blockNextLeftMouseRelease = false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return m_filter->mouseButtonReleaseEvent(event);
|
return m_filter->mouseButtonReleaseEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,6 +58,10 @@ private:
|
|||||||
QjtMouseGestureFilter* m_filter;
|
QjtMouseGestureFilter* m_filter;
|
||||||
QPointer<MouseGesturesSettingsDialog> m_settings;
|
QPointer<MouseGesturesSettingsDialog> m_settings;
|
||||||
QPointer<WebView> m_view;
|
QPointer<WebView> m_view;
|
||||||
|
bool m_blockNextRightMouseRelease;
|
||||||
|
bool m_blockNextLeftMouseRelease;
|
||||||
|
|
||||||
|
bool m_enableRockerNavigation;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MOUSEGESTURES_H
|
#endif // MOUSEGESTURES_H
|
||||||
|
Loading…
Reference in New Issue
Block a user