summaryrefslogtreecommitdiffstats
path: root/tools/assistant
diff options
context:
space:
mode:
authorck <qt-info@nokia.com>2010-04-13 09:06:23 (GMT)
committerck <qt-info@nokia.com>2010-04-13 10:01:30 (GMT)
commit0fa2bea5a90c0f935aa6e4ef765cf5a24d94c23d (patch)
tree9c1ef97011ddd4de1cc0c5a8bf1d0d11ce81d9bc /tools/assistant
parentfe62f3597577f969760debcb5c8d01e398e99c55 (diff)
downloadQt-0fa2bea5a90c0f935aa6e4ef765cf5a24d94c23d.zip
Qt-0fa2bea5a90c0f935aa6e4ef765cf5a24d94c23d.tar.gz
Qt-0fa2bea5a90c0f935aa6e4ef765cf5a24d94c23d.tar.bz2
Assistant: Handle forward/backward mouse buttons on press on Linux.
Written-by: kh1 Reviewed-by: ck
Diffstat (limited to 'tools/assistant')
-rw-r--r--tools/assistant/tools/assistant/helpviewer.h3
-rw-r--r--tools/assistant/tools/assistant/helpviewer_qtb.cpp34
-rw-r--r--tools/assistant/tools/assistant/helpviewer_qtb.h3
-rw-r--r--tools/assistant/tools/assistant/helpviewer_qwv.cpp32
-rw-r--r--tools/assistant/tools/assistant/helpviewer_qwv.h2
5 files changed, 58 insertions, 16 deletions
diff --git a/tools/assistant/tools/assistant/helpviewer.h b/tools/assistant/tools/assistant/helpviewer.h
index 246700f..6f1f48d 100644
--- a/tools/assistant/tools/assistant/helpviewer.h
+++ b/tools/assistant/tools/assistant/helpviewer.h
@@ -47,6 +47,7 @@
QT_BEGIN_NAMESPACE
+class QMouseEvent;
class QUrl;
class AbstractHelpViewer
@@ -64,6 +65,8 @@ public:
virtual void resetScale() = 0;
virtual qreal scale() const = 0;
+ virtual bool handleForwardBackwardMouseButtons(QMouseEvent *e) = 0;
+
static QString AboutBlank;
static QString LocalHelpFile;
static QString PageNotFoundMessage;
diff --git a/tools/assistant/tools/assistant/helpviewer_qtb.cpp b/tools/assistant/tools/assistant/helpviewer_qtb.cpp
index 07b89eb..3ff64e8 100644
--- a/tools/assistant/tools/assistant/helpviewer_qtb.cpp
+++ b/tools/assistant/tools/assistant/helpviewer_qtb.cpp
@@ -127,6 +127,20 @@ void HelpViewer::resetScale()
zoomCount = 0;
}
+bool HelpViewer::handleForwardBackwardMouseButtons(QMouseEvent *e)
+{
+ if (e->button() == Qt::XButton1) {
+ QTextBrowser::backward();
+ return true;
+ }
+
+ if (e->button() == Qt::XButton2) {
+ QTextBrowser::forward();
+ return true;
+ }
+ return false;
+}
+
void HelpViewer::setSource(const QUrl &url)
{
TRACE_OBJ
@@ -229,15 +243,10 @@ void HelpViewer::contextMenuEvent(QContextMenuEvent *e)
void HelpViewer::mouseReleaseEvent(QMouseEvent *e)
{
TRACE_OBJ
- if (e->button() == Qt::XButton1) {
- QTextBrowser::backward();
- return;
- }
-
- if (e->button() == Qt::XButton2) {
- QTextBrowser::forward();
+#ifndef Q_OS_LINUX
+ if (handleForwardBackwardMouseButtons(e))
return;
- }
+#endif
controlPressed = e->modifiers() & Qt::ControlModifier;
if ((controlPressed && hasAnchorAt(e->pos())) ||
@@ -249,6 +258,15 @@ void HelpViewer::mouseReleaseEvent(QMouseEvent *e)
QTextBrowser::mouseReleaseEvent(e);
}
+void HelpViewer::mousePressEvent(QMouseEvent *e)
+{
+#ifdef Q_OS_LINUX
+ if (handleForwardBackwardMouseButtons(e))
+ return;
+#endif
+ QTextBrowser::mousePressEvent(e);
+}
+
void HelpViewer::keyPressEvent(QKeyEvent *e)
{
TRACE_OBJ
diff --git a/tools/assistant/tools/assistant/helpviewer_qtb.h b/tools/assistant/tools/assistant/helpviewer_qtb.h
index a05782c..acb734b 100644
--- a/tools/assistant/tools/assistant/helpviewer_qtb.h
+++ b/tools/assistant/tools/assistant/helpviewer_qtb.h
@@ -72,6 +72,8 @@ public:
void resetScale();
qreal scale() const { return zoomCount; }
+ bool handleForwardBackwardMouseButtons(QMouseEvent *e);
+
void setSource(const QUrl &url);
inline bool hasSelection() const
@@ -91,6 +93,7 @@ private:
void contextMenuEvent(QContextMenuEvent *e);
void mouseReleaseEvent(QMouseEvent *e);
void keyPressEvent(QKeyEvent *e);
+ void mousePressEvent(QMouseEvent *e);
private slots:
void openLinkInNewTab();
diff --git a/tools/assistant/tools/assistant/helpviewer_qwv.cpp b/tools/assistant/tools/assistant/helpviewer_qwv.cpp
index 18046a7..db1cd58 100644
--- a/tools/assistant/tools/assistant/helpviewer_qwv.cpp
+++ b/tools/assistant/tools/assistant/helpviewer_qwv.cpp
@@ -301,6 +301,22 @@ void HelpViewer::resetScale()
setTextSizeMultiplier(1.0);
}
+bool HelpViewer::handleForwardBackwardMouseButtons(QMouseEvent *e)
+{
+ TRACE_OBJ
+ if (e->button() == Qt::XButton1) {
+ triggerPageAction(QWebPage::Back);
+ return true;
+ }
+
+ if (e->button() == Qt::XButton2) {
+ triggerPageAction(QWebPage::Forward);
+ return true;
+ }
+
+ return false;
+}
+
void HelpViewer::setSource(const QUrl &url)
{
TRACE_OBJ
@@ -328,15 +344,10 @@ void HelpViewer::wheelEvent(QWheelEvent *e)
void HelpViewer::mouseReleaseEvent(QMouseEvent *e)
{
TRACE_OBJ
- if (e->button() == Qt::XButton1) {
- triggerPageAction(QWebPage::Back);
+#ifndef Q_OS_LINUX
+ if (handleForwardBackwardMouseButtons(e))
return;
- }
-
- if (e->button() == Qt::XButton2) {
- triggerPageAction(QWebPage::Forward);
- return;
- }
+#endif
QWebView::mouseReleaseEvent(e);
}
@@ -356,6 +367,11 @@ void HelpViewer::actionChanged()
void HelpViewer::mousePressEvent(QMouseEvent *event)
{
TRACE_OBJ
+#ifdef Q_OS_LINUX
+ if (handleForwardBackwardMouseButtons(event))
+ return;
+#endif
+
HelpPage *currentPage = static_cast<HelpPage*>(page());
if (currentPage) {
currentPage->m_pressedButtons = event->buttons();
diff --git a/tools/assistant/tools/assistant/helpviewer_qwv.h b/tools/assistant/tools/assistant/helpviewer_qwv.h
index 41ee553..a2c0389 100644
--- a/tools/assistant/tools/assistant/helpviewer_qwv.h
+++ b/tools/assistant/tools/assistant/helpviewer_qwv.h
@@ -69,6 +69,8 @@ public:
void resetScale();
qreal scale() const { return textSizeMultiplier(); }
+ bool handleForwardBackwardMouseButtons(QMouseEvent *e);
+
void setSource(const QUrl &url);
inline QUrl source() const { return url(); }