summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gui/kernel/qwidget_win.cpp3
-rw-r--r--src/gui/widgets/qabstractscrollarea.cpp32
-rw-r--r--src/gui/widgets/qabstractscrollarea.h1
-rw-r--r--src/gui/widgets/qabstractscrollarea_p.h4
-rw-r--r--src/gui/widgets/qtextedit.cpp24
-rw-r--r--src/gui/widgets/qtextedit.h1
-rw-r--r--src/gui/widgets/qtextedit_p.h4
7 files changed, 40 insertions, 29 deletions
diff --git a/src/gui/kernel/qwidget_win.cpp b/src/gui/kernel/qwidget_win.cpp
index 6647f3f..d8bee55 100644
--- a/src/gui/kernel/qwidget_win.cpp
+++ b/src/gui/kernel/qwidget_win.cpp
@@ -2056,6 +2056,8 @@ void QWidgetPrivate::registerTouchWindow()
void QWidgetPrivate::winSetupGestures()
{
Q_Q(QWidget);
+ if (!q)
+ return;
QApplicationPrivate *qAppPriv = getQApplicationPrivateInternal();
bool needh = false;
bool needv = false;
@@ -2097,6 +2099,7 @@ void QWidgetPrivate::winSetupGestures()
gc[1].dwWant = GC_ZOOM;
gc[1].dwBlock = 0;
}
+ Q_ASSERT(winid);
qAppPriv->SetGestureConfig(winid, 0, sizeof(gc)/sizeof(gc[0]), gc, sizeof(gc[0]));
}
}
diff --git a/src/gui/widgets/qabstractscrollarea.cpp b/src/gui/widgets/qabstractscrollarea.cpp
index e803afc..f6c1892 100644
--- a/src/gui/widgets/qabstractscrollarea.cpp
+++ b/src/gui/widgets/qabstractscrollarea.cpp
@@ -159,7 +159,7 @@ QT_BEGIN_NAMESPACE
QAbstractScrollAreaPrivate::QAbstractScrollAreaPrivate()
:hbar(0), vbar(0), vbarpolicy(Qt::ScrollBarAsNeeded), hbarpolicy(Qt::ScrollBarAsNeeded),
viewport(0), cornerWidget(0), left(0), top(0), right(0), bottom(0),
- xoffset(0), yoffset(0), viewportFilter(0)
+ xoffset(0), yoffset(0), viewportFilter(0), panGesture(0)
#ifdef Q_WS_WIN
, singleFingerPanEnabled(false)
#endif
@@ -294,7 +294,18 @@ void QAbstractScrollAreaPrivate::init()
q->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
q->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
layoutChildren();
+
+ panGesture = new QPanGesture(q);
+ QObject::connect(panGesture, SIGNAL(triggered()), q, SLOT(_q_gestureTriggered()));
+}
+
+#ifdef Q_WS_WIN
+void QAbstractScrollAreaPrivate::setSingleFingerPanEnabled(bool on)
+{
+ singleFingerPanEnabled = on;
+ winSetupGestures();
}
+#endif // Q_WS_WIN
void QAbstractScrollAreaPrivate::layoutChildren()
{
@@ -1310,6 +1321,25 @@ void QAbstractScrollArea::setupViewport(QWidget *viewport)
Q_UNUSED(viewport);
}
+void QAbstractScrollAreaPrivate::_q_gestureTriggered()
+{
+ Q_Q(QAbstractScrollArea);
+ QPanGesture *g = qobject_cast<QPanGesture*>(q->sender());
+ if (!g)
+ return;
+ QScrollBar *hBar = q->horizontalScrollBar();
+ QScrollBar *vBar = q->verticalScrollBar();
+ QSize delta = g->lastOffset();
+ if (!delta.isNull()) {
+ if (QApplication::isRightToLeft())
+ delta.rwidth() *= -1;
+ int newX = hBar->value() - delta.width();
+ int newY = vBar->value() - delta.height();
+ hbar->setValue(newX);
+ vbar->setValue(newY);
+ }
+}
+
QT_END_NAMESPACE
#include "moc_qabstractscrollarea.cpp"
diff --git a/src/gui/widgets/qabstractscrollarea.h b/src/gui/widgets/qabstractscrollarea.h
index c7441c1..9178629 100644
--- a/src/gui/widgets/qabstractscrollarea.h
+++ b/src/gui/widgets/qabstractscrollarea.h
@@ -128,6 +128,7 @@ private:
Q_PRIVATE_SLOT(d_func(), void _q_hslide(int))
Q_PRIVATE_SLOT(d_func(), void _q_vslide(int))
Q_PRIVATE_SLOT(d_func(), void _q_showOrHideScrollBars())
+ Q_PRIVATE_SLOT(d_func(), void _q_gestureTriggered())
friend class QStyleSheetStyle;
friend class QWidgetPrivate;
diff --git a/src/gui/widgets/qabstractscrollarea_p.h b/src/gui/widgets/qabstractscrollarea_p.h
index 9a6b923..8011ed5 100644
--- a/src/gui/widgets/qabstractscrollarea_p.h
+++ b/src/gui/widgets/qabstractscrollarea_p.h
@@ -60,6 +60,7 @@ QT_BEGIN_NAMESPACE
#ifndef QT_NO_SCROLLAREA
+class QPanGesture;
class QScrollBar;
class QAbstractScrollAreaScrollBarContainer;
class Q_AUTOTEST_EXPORT QAbstractScrollAreaPrivate: public QFramePrivate
@@ -100,8 +101,11 @@ public:
{ return q_func()->viewportEvent(event); }
QObject *viewportFilter;
+ virtual void _q_gestureTriggered();
+ QPanGesture *panGesture;
#ifdef Q_WS_WIN
bool singleFingerPanEnabled;
+ void setSingleFingerPanEnabled(bool on = true);
#endif
};
diff --git a/src/gui/widgets/qtextedit.cpp b/src/gui/widgets/qtextedit.cpp
index c095f5c..0a41d74 100644
--- a/src/gui/widgets/qtextedit.cpp
+++ b/src/gui/widgets/qtextedit.cpp
@@ -114,7 +114,7 @@ QTextEditPrivate::QTextEditPrivate()
showCursorOnInitialShow = true;
inDrag = false;
#ifdef Q_WS_WIN
- singleFingerPanEnabled = true;
+ setSingleFingerPanEnabled(true);
#endif
}
@@ -183,8 +183,6 @@ void QTextEditPrivate::init(const QString &html)
#ifndef QT_NO_CURSOR
viewport->setCursor(Qt::IBeamCursor);
#endif
- panGesture = new QPanGesture(q);
- QObject::connect(panGesture, SIGNAL(triggered()), q, SLOT(_q_gestureTriggered()));
}
void QTextEditPrivate::_q_repaintContents(const QRectF &contentsRect)
@@ -2617,26 +2615,6 @@ void QTextEdit::ensureCursorVisible()
d->control->ensureCursorVisible();
}
-void QTextEditPrivate::_q_gestureTriggered()
-{
- Q_Q(QTextEdit);
- QPanGesture *g = qobject_cast<QPanGesture*>(q->sender());
- if (!g)
- return;
- QScrollBar *hBar = q->horizontalScrollBar();
- QScrollBar *vBar = q->verticalScrollBar();
- QSize delta = g->lastOffset();
- if (!delta.isNull()) {
- if (QApplication::isRightToLeft())
- delta.rwidth() *= -1;
- int newX = hBar->value() - delta.width();
- int newY = vBar->value() - delta.height();
- hbar->setValue(newX);
- vbar->setValue(newY);
- }
-}
-
-
/*!
\enum QTextEdit::KeyboardAction
diff --git a/src/gui/widgets/qtextedit.h b/src/gui/widgets/qtextedit.h
index 9e10e07..617822a 100644
--- a/src/gui/widgets/qtextedit.h
+++ b/src/gui/widgets/qtextedit.h
@@ -414,7 +414,6 @@ private:
Q_PRIVATE_SLOT(d_func(), void _q_currentCharFormatChanged(const QTextCharFormat &))
Q_PRIVATE_SLOT(d_func(), void _q_adjustScrollbars())
Q_PRIVATE_SLOT(d_func(), void _q_ensureVisible(const QRectF &))
- Q_PRIVATE_SLOT(d_func(), void _q_gestureTriggered())
friend class QTextEditControl;
friend class QTextDocument;
friend class QTextControl;
diff --git a/src/gui/widgets/qtextedit_p.h b/src/gui/widgets/qtextedit_p.h
index 249331e..3d14af6 100644
--- a/src/gui/widgets/qtextedit_p.h
+++ b/src/gui/widgets/qtextedit_p.h
@@ -70,7 +70,6 @@ QT_BEGIN_NAMESPACE
#ifndef QT_NO_TEXTEDIT
class QMimeData;
-class QPanGesture;
class QTextEditPrivate : public QAbstractScrollAreaPrivate
{
Q_DECLARE_PUBLIC(QTextEdit)
@@ -129,9 +128,6 @@ public:
QString anchorToScrollToWhenVisible;
- void _q_gestureTriggered();
- QPanGesture *panGesture;
-
#ifdef QT_KEYPAD_NAVIGATION
QBasicTimer deleteAllTimer;
#endif