diff options
Diffstat (limited to 'src/quick/items/qquicktextinput.cpp')
-rw-r--r-- | src/quick/items/qquicktextinput.cpp | 63 |
1 files changed, 36 insertions, 27 deletions
diff --git a/src/quick/items/qquicktextinput.cpp b/src/quick/items/qquicktextinput.cpp index f9de3d25e7..52f991b475 100644 --- a/src/quick/items/qquicktextinput.cpp +++ b/src/quick/items/qquicktextinput.cpp @@ -153,6 +153,8 @@ void QQuickTextInput::setText(const QString &s) not require advanced features such as transformation of the text. Using such features in combination with the NativeRendering render type will lend poor and sometimes pixelated results. + + On HighDpi "retina" displays this property is ignored and QtRendering is always used. */ QQuickTextInput::RenderType QQuickTextInput::renderType() const { @@ -1836,7 +1838,7 @@ QSGNode *QQuickTextInput::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData } } } else { - node->setUseNativeRenderer(d->renderType == QQuickTextInput::NativeRendering); + node->setUseNativeRenderer(d->renderType == NativeRendering && d->window->devicePixelRatio() <= 1); node->deleteContent(); node->setMatrix(QMatrix4x4()); @@ -1910,7 +1912,7 @@ QVariant QQuickTextInput::inputMethodQuery(Qt::InputMethodQuery property) const else return QVariant(d->selectionStart()); default: - return QVariant(); + return QQuickItem::inputMethodQuery(property); } } #endif // QT_NO_IM @@ -2477,40 +2479,47 @@ void QQuickTextInput::moveCursorSelection(int pos, SelectionMode mode) void QQuickTextInput::focusInEvent(QFocusEvent *event) { - Q_D(const QQuickTextInput); -#ifndef QT_NO_IM - if (d->focusOnPress && !d->m_readOnly) - qGuiApp->inputMethod()->show(); -#endif + Q_D(QQuickTextInput); + d->handleFocusEvent(event); QQuickImplicitSizeItem::focusInEvent(event); } -void QQuickTextInput::itemChange(ItemChange change, const ItemChangeData &value) +void QQuickTextInputPrivate::handleFocusEvent(QFocusEvent *event) { - Q_D(QQuickTextInput); - if (change == ItemActiveFocusHasChanged) { - bool hasFocus = value.boolValue; - setCursorVisible(hasFocus); - if (!hasFocus && (d->m_passwordEchoEditing || d->m_passwordEchoTimer.isActive())) { - d->updatePasswordEchoEditing(false);//QQuickTextInputPrivate sets it on key events, but doesn't deal with focus events - } - - if (!hasFocus) { - if (!d->persistentSelection) - d->deselect(); + Q_Q(QQuickTextInput); + bool focus = event->gotFocus(); + q->setCursorVisible(focus); + if (focus) { + q->q_updateAlignment(); #ifndef QT_NO_IM - disconnect(qApp->inputMethod(), SIGNAL(inputDirectionChanged(Qt::LayoutDirection)), - this, SLOT(q_updateAlignment())); + if (focusOnPress && !m_readOnly) + qGuiApp->inputMethod()->show(); + q->connect(qApp->inputMethod(), SIGNAL(inputDirectionChanged(Qt::LayoutDirection)), + q, SLOT(q_updateAlignment())); #endif - } else { - q_updateAlignment(); + } else { + if ((m_passwordEchoEditing || m_passwordEchoTimer.isActive())) { + updatePasswordEchoEditing(false);//QQuickTextInputPrivate sets it on key events, but doesn't deal with focus events + } + + if (event->reason() != Qt::ActiveWindowFocusReason + && event->reason() != Qt::PopupFocusReason + && hasSelectedText() + && !persistentSelection) + deselect(); + #ifndef QT_NO_IM - connect(qApp->inputMethod(), SIGNAL(inputDirectionChanged(Qt::LayoutDirection)), - this, SLOT(q_updateAlignment())); + q->disconnect(qApp->inputMethod(), SIGNAL(inputDirectionChanged(Qt::LayoutDirection)), + q, SLOT(q_updateAlignment())); #endif - } } - QQuickItem::itemChange(change, value); +} + +void QQuickTextInput::focusOutEvent(QFocusEvent *event) +{ + Q_D(QQuickTextInput); + d->handleFocusEvent(event); + QQuickImplicitSizeItem::focusOutEvent(event); } #ifndef QT_NO_IM |