diff options
Diffstat (limited to 'src/gui/widgets/qtextedit.cpp')
-rw-r--r-- | src/gui/widgets/qtextedit.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/gui/widgets/qtextedit.cpp b/src/gui/widgets/qtextedit.cpp index 3bac94b..2de661a 100644 --- a/src/gui/widgets/qtextedit.cpp +++ b/src/gui/widgets/qtextedit.cpp @@ -67,6 +67,8 @@ #include <qtexttable.h> #include <qvariant.h> +#include <qstandardgestures.h> + #include <qinputcontext.h> #endif @@ -116,6 +118,9 @@ QTextEditPrivate::QTextEditPrivate() preferRichText = false; showCursorOnInitialShow = true; inDrag = false; +#ifdef Q_WS_WIN + singleFingerPanEnabled = true; +#endif } void QTextEditPrivate::createAutoBulletList() @@ -183,6 +188,8 @@ 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) @@ -2624,6 +2631,25 @@ 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(); + QPoint delta = g->pos() - (g->lastPos().isNull() ? g->pos() : g->lastPos()); + if (!delta.isNull()) { + if (QApplication::isRightToLeft()) + delta.rx() *= -1; + int newX = hBar->value() - delta.x(); + int newY = vBar->value() - delta.y(); + hbar->setValue(newX); + vbar->setValue(newY); + } +} + /*! \enum QTextEdit::KeyboardAction |