Respecting correct text interaction flags when setting text cursor.

Currently the text cursor is hidden when a cursor was set using
setTextCursor on a widget with a widget text control and the interaction
flag TextSelectableByKeyboard. The documentation indicates that this is
incorrect behavior.

Change-Id: I624a470617f15d09f5772213016e552a5149424c
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>
This commit is contained in:
David Schulz 2015-04-23 14:22:53 +02:00
parent ea92ee8e15
commit 59840faacf

View File

@ -883,7 +883,8 @@ void QWidgetTextControl::setTextCursor(const QTextCursor &cursor)
const bool posChanged = cursor.position() != d->cursor.position();
const QTextCursor oldSelection = d->cursor;
d->cursor = cursor;
d->cursorOn = d->hasFocus && (d->interactionFlags & Qt::TextEditable);
d->cursorOn = d->hasFocus
&& (d->interactionFlags & (Qt::TextSelectableByKeyboard | Qt::TextEditable));
d->_q_updateCurrentCharFormatAndSelection();
ensureCursorVisible();
d->repaintOldAndNewSelection(oldSelection);
@ -2138,7 +2139,7 @@ void QWidgetTextControlPrivate::focusEvent(QFocusEvent *e)
#ifdef QT_KEYPAD_NAVIGATION
if (!QApplication::keypadNavigationEnabled() || (hasEditFocus && (e->reason() == Qt::PopupFocusReason))) {
#endif
cursorOn = (interactionFlags & Qt::TextSelectableByKeyboard);
cursorOn = (interactionFlags & (Qt::TextSelectableByKeyboard | Qt::TextEditable));
if (interactionFlags & Qt::TextEditable) {
setBlinkingCursorEnabled(true);
}