Commit 1bb0d919 authored by Thorbjørn Lindeijer's avatar Thorbjørn Lindeijer
Browse files

Handle forward/backward mouse buttons on press on Linux

There's an issue with receiving the release event when the mouse is
moved slightly, and also on Linux it is apparently normal to handle
these events on press instead of release. Tested with Firefox and
Chromium.

Task-number: QTCREATORBUG-899
Reviewed-by: kh1
parent fb82e101
......@@ -333,18 +333,27 @@ void HelpViewer::wheelEvent(QWheelEvent *e)
QWebView::wheelEvent(e);
}
void HelpViewer::mouseReleaseEvent(QMouseEvent *e)
bool HelpViewer::handleForwardBackwardMouseButtons(QMouseEvent *e)
{
if (e->button() == Qt::XButton1) {
triggerPageAction(QWebPage::Back);
return;
return true;
}
if (e->button() == Qt::XButton2) {
triggerPageAction(QWebPage::Forward);
return;
return true;
}
return false;
}
void HelpViewer::mouseReleaseEvent(QMouseEvent *e)
{
#ifndef Q_OS_LINUX
if (handleForwardBackwardMouseButtons(e))
return;
#endif
QWebView::mouseReleaseEvent(e);
}
......@@ -366,6 +375,12 @@ void HelpViewer::mousePressEvent(QMouseEvent *event)
currentPage->m_pressedButtons = event->buttons();
currentPage->m_keyboardModifiers = event->modifiers();
}
#ifdef Q_OS_LINUX
if (handleForwardBackwardMouseButtons(event))
return;
#endif
QWebView::mousePressEvent(event);
}
......@@ -543,18 +558,27 @@ void HelpViewer::contextMenuEvent(QContextMenuEvent *e)
QApplication::clipboard()->setText(link.toString());
}
void HelpViewer::mouseReleaseEvent(QMouseEvent *e)
bool HelpViewer::handleForwardBackwardMouseButtons(QMouseEvent *e)
{
if (e->button() == Qt::XButton1) {
QTextBrowser::backward();
return;
return true;
}
if (e->button() == Qt::XButton2) {
QTextBrowser::forward();
return;
return true;
}
return false;
}
void HelpViewer::mouseReleaseEvent(QMouseEvent *e)
{
#ifndef Q_OS_LINUX
if (handleForwardBackwardMouseButtons(e))
return;
#endif
controlPressed = e->modifiers() & Qt::ControlModifier;
if ((controlPressed && hasAnchorAt(e->pos())) ||
(e->button() == Qt::MidButton && hasAnchorAt(e->pos()))) {
......@@ -567,6 +591,11 @@ void HelpViewer::mouseReleaseEvent(QMouseEvent *e)
void HelpViewer::keyPressEvent(QKeyEvent *e)
{
#ifdef Q_OS_LINUX
if (handleForwardBackwardMouseButtons(e))
return;
#endif
if ((e->key() == Qt::Key_Home && e->modifiers() != Qt::NoModifier)
|| (e->key() == Qt::Key_End && e->modifiers() != Qt::NoModifier)) {
QKeyEvent* event = new QKeyEvent(e->type(), e->key(), Qt::NoModifier,
......
......@@ -116,6 +116,8 @@ private Q_SLOTS:
void setLoadFinished(bool ok);
private:
bool handleForwardBackwardMouseButtons(QMouseEvent *e);
QHelpEngine *helpEngine;
Help::Internal::CentralWidget* parentWidget;
QUrl homeUrl;
......@@ -163,6 +165,8 @@ private slots:
void openLinkInNewTab();
private:
bool handleForwardBackwardMouseButtons(QMouseEvent *e);
int zoomCount;
bool controlPressed;
QString lastAnchor;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment