diff options
author | Lars Knoll <lars.knoll@nokia.com> | 2011-08-31 10:47:09 +0200 |
---|---|---|
committer | Samuel Rødal <samuel.rodal@nokia.com> | 2011-08-31 11:47:21 +0200 |
commit | 94355ca15a4d451f4a4b858240e2c1a96e26537b (patch) | |
tree | 6b9209c03a86575a45c92e62a990c60528c02195 /src/gui/text | |
parent | 3795e2c7bec9eb50a04d139e45ecc809c4aa37f6 (diff) |
Add a QStyleHints class to QtGui
This class encapsulates platform specific style hints
like doubleClickInterval or cursorFlashTime.
Change-Id: I0d88c47a59d564d8d346642184e5b14e1864cf40
Reviewed-on: http://codereview.qt.nokia.com/3927
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
Diffstat (limited to 'src/gui/text')
-rw-r--r-- | src/gui/text/qlinecontrol.cpp | 10 | ||||
-rw-r--r-- | src/gui/text/qtextcontrol.cpp | 15 |
2 files changed, 11 insertions, 14 deletions
diff --git a/src/gui/text/qlinecontrol.cpp b/src/gui/text/qlinecontrol.cpp index 36c064ee40..6f9d9402ee 100644 --- a/src/gui/text/qlinecontrol.cpp +++ b/src/gui/text/qlinecontrol.cpp @@ -56,12 +56,11 @@ #include "qlist.h" #endif #include "qguiapplication.h" +#include "qstylehints.h" QT_BEGIN_NAMESPACE -// ### these should come from the application -const int startDragDistance = 10; -const int cursorFlashTime = 2000; +// ### these should come from QStyleHints const int textCursorWidth = 1; const bool fullWidthSelection = true; @@ -1394,8 +1393,7 @@ void QLineControl::processMouseEvent(QMouseEvent* ev) switch (ev->type()) { case QEvent::MouseButtonPress:{ if (m_tripleClickTimer - && (ev->pos() - m_tripleClick).manhattanLength() - < startDragDistance) { + && (ev->pos() - m_tripleClick).manhattanLength() < qApp->styleHints()->startDragDistance()) { selectAll(); return; } @@ -1412,7 +1410,7 @@ void QLineControl::processMouseEvent(QMouseEvent* ev) selectWordAtPos(xToPos(ev->pos().x())); if (m_tripleClickTimer) killTimer(m_tripleClickTimer); - m_tripleClickTimer = startTimer(QGuiApplication::doubleClickInterval()); + m_tripleClickTimer = startTimer(qApp->styleHints()->mouseDoubleClickInterval()); m_tripleClick = ev->pos(); } break; diff --git a/src/gui/text/qtextcontrol.cpp b/src/gui/text/qtextcontrol.cpp index 9ca6a24ce7..f7ea2fa34a 100644 --- a/src/gui/text/qtextcontrol.cpp +++ b/src/gui/text/qtextcontrol.cpp @@ -70,10 +70,9 @@ #include <qtexttable.h> #include <qvariant.h> #include <qurl.h> +#include <qstylehints.h> -// ### these should come from the application -const int startDragDistance = 10; -const int cursorFlashTime = 2000; +// ### these should come from QStyleHints const int textCursorWidth = 1; const bool fullWidthSelection = true; @@ -635,8 +634,8 @@ void QTextControlPrivate::setBlinkingCursorEnabled(bool enable) { Q_Q(QTextControl); - if (enable && cursorFlashTime > 0) - cursorBlinkTimer.start(cursorFlashTime / 2, q); + if (enable && qApp->styleHints()->cursorFlashTime() > 0) + cursorBlinkTimer.start(qApp->styleHints()->cursorFlashTime() / 2, q); else cursorBlinkTimer.stop(); @@ -1452,7 +1451,7 @@ void QTextControlPrivate::mousePressEvent(QEvent *e, Qt::MouseButton button, con #endif if (trippleClickTimer.isActive() - && ((pos - trippleClickPoint).toPoint().manhattanLength() < startDragDistance)) { + && ((pos - trippleClickPoint).toPoint().manhattanLength() < qApp->styleHints()->startDragDistance())) { cursor.movePosition(QTextCursor::StartOfBlock); cursor.movePosition(QTextCursor::EndOfBlock, QTextCursor::KeepAnchor); @@ -1550,7 +1549,7 @@ void QTextControlPrivate::mouseMoveEvent(QEvent *e, Qt::MouseButton button, cons const int oldCursorPos = cursor.position(); if (mightStartDrag) { - if ((mousePos.toPoint() - dragStartPos).manhattanLength() > startDragDistance) + if ((mousePos.toPoint() - dragStartPos).manhattanLength() > qApp->styleHints()->startDragDistance()) startDrag(); return; } @@ -1697,7 +1696,7 @@ void QTextControlPrivate::mouseDoubleClickEvent(QEvent *e, Qt::MouseButton butto selectedWordOnDoubleClick = cursor; trippleClickPoint = pos; - trippleClickTimer.start(QGuiApplication::doubleClickInterval(), q); + trippleClickTimer.start(qApp->styleHints()->mouseDoubleClickInterval(), q); if (doEmit) { selectionChanged(); #ifndef QT_NO_CLIPBOARD |