From c906d7abb84e60d2d4b66edce712cb32b3ce4470 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Mon, 9 May 2016 12:36:37 +0200 Subject: QWidgetTextControl: ensure we listen for changes to cursorFlashTimeChanged MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change 3cdc02d actually "reverted" the behavior of listening for cursorFlashTimeChanged. The reason is that we sat "blinkingEnabled" directly to true in the constructor instead of calling "setCursorBlinking", which was responsible for setting up the connection. And as it turns out, after 3cdc02d, nobody is actually calling "setBlinkingCursorEnabled" anymore. From the widgets point of view, it should always blink when visible (unless QPA sets cursorFlashTime to zero). So we can remove the whole function, and set up the connection in "setVisible" instead. Change-Id: I577a5fbbbd9c56331ac7f8bb38567a684ca8c1df Reviewed-by: Jan Arve Sæther --- src/widgets/widgets/qwidgettextcontrol.cpp | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) (limited to 'src/widgets/widgets/qwidgettextcontrol.cpp') diff --git a/src/widgets/widgets/qwidgettextcontrol.cpp b/src/widgets/widgets/qwidgettextcontrol.cpp index 52eb4e4078..77b5a4830b 100644 --- a/src/widgets/widgets/qwidgettextcontrol.cpp +++ b/src/widgets/widgets/qwidgettextcontrol.cpp @@ -112,7 +112,7 @@ static QTextLine currentTextLine(const QTextCursor &cursor) } QWidgetTextControlPrivate::QWidgetTextControlPrivate() - : doc(0), cursorOn(false), blinkingEnabled(true), cursorVisible(false), cursorIsFocusIndicator(false), + : doc(0), cursorOn(false), cursorVisible(false), cursorIsFocusIndicator(false), #ifndef Q_OS_ANDROID interactionFlags(Qt::TextEditorInteraction), #else @@ -691,29 +691,18 @@ void QWidgetTextControlPrivate::setCursorVisible(bool visible) return; cursorVisible = visible; - updateCursorBlinking(); -} - -void QWidgetTextControlPrivate::setBlinkingCursorEnabled(bool enable) -{ - if (blinkingEnabled == enable) - return; - - blinkingEnabled = enable; - if (enable) + if (cursorVisible) connect(qApp->styleHints(), &QStyleHints::cursorFlashTimeChanged, this, &QWidgetTextControlPrivate::updateCursorBlinking); else disconnect(qApp->styleHints(), &QStyleHints::cursorFlashTimeChanged, this, &QWidgetTextControlPrivate::updateCursorBlinking); - - updateCursorBlinking(); } void QWidgetTextControlPrivate::updateCursorBlinking() { cursorBlinkTimer.stop(); - if (cursorVisible && blinkingEnabled) { + if (cursorVisible) { int flashTime = QGuiApplication::styleHints()->cursorFlashTime(); if (flashTime >= 2) cursorBlinkTimer.start(flashTime / 2, q_func()); -- cgit v1.2.3