QWidgetTextControl: ensure we listen for changes to cursorFlashTimeChanged
Change3cdc02d
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, after3cdc02d
, 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 <jan-arve.saether@theqtcompany.com>
This commit is contained in:
parent
f643f6504b
commit
c906d7abb8
@ -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());
|
||||
|
@ -177,7 +177,6 @@ public:
|
||||
|
||||
QTextDocument *doc;
|
||||
bool cursorOn;
|
||||
bool blinkingEnabled;
|
||||
bool cursorVisible;
|
||||
QTextCursor cursor;
|
||||
bool cursorIsFocusIndicator;
|
||||
|
Loading…
Reference in New Issue
Block a user