diff options
author | Gabriel de Dietrich <gabriel.dedietrich@digia.com> | 2012-11-14 10:52:16 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2012-11-14 14:18:31 +0100 |
commit | 9346cb955230b3fbca8062a2fe8c912713011ce4 (patch) | |
tree | 01acf41bf9d1a60d553c515c34227e31a39e50df /src | |
parent | 85ff27d9ec485e87936c60c3e49b2e26d0b3946a (diff) |
Widgets: Stop cursor blink timer when QLineEdit is read-only
This prevents unnecessary updates, since the cursor is not visible.
Change-Id: Iec54ed338a0cb526a03cd611de4d823e26f3d804
Reviewed-by: Jan Arve Sæther <jan-arve.saether@digia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/widgets/widgets/qwidgetlinecontrol.cpp | 20 | ||||
-rw-r--r-- | src/widgets/widgets/qwidgetlinecontrol_p.h | 3 |
2 files changed, 11 insertions, 12 deletions
diff --git a/src/widgets/widgets/qwidgetlinecontrol.cpp b/src/widgets/widgets/qwidgetlinecontrol.cpp index bed8296989..a44ac12fa4 100644 --- a/src/widgets/widgets/qwidgetlinecontrol.cpp +++ b/src/widgets/widgets/qwidgetlinecontrol.cpp @@ -1456,6 +1456,15 @@ void QWidgetLineControl::complete(int key) } #endif +void QWidgetLineControl::setReadOnly(bool enable) +{ + m_readOnly = enable; + if (enable) + setCursorBlinkPeriod(0); + else + setCursorBlinkPeriod(QApplication::cursorFlashTime()); +} + void QWidgetLineControl::setCursorBlinkPeriod(int msec) { if (msec == m_blinkPeriod) @@ -1463,7 +1472,7 @@ void QWidgetLineControl::setCursorBlinkPeriod(int msec) if (m_blinkTimer) { killTimer(m_blinkTimer); } - if (msec) { + if (msec && !m_readOnly) { m_blinkTimer = startTimer(msec / 2); m_blinkStatus = 1; } else { @@ -1474,15 +1483,6 @@ void QWidgetLineControl::setCursorBlinkPeriod(int msec) m_blinkPeriod = msec; } -void QWidgetLineControl::resetCursorBlinkTimer() -{ - if (m_blinkPeriod == 0 || m_blinkTimer == 0) - return; - killTimer(m_blinkTimer); - m_blinkTimer = startTimer(m_blinkPeriod / 2); - m_blinkStatus = 1; -} - void QWidgetLineControl::timerEvent(QTimerEvent *event) { if (event->timerId() == m_blinkTimer) { diff --git a/src/widgets/widgets/qwidgetlinecontrol_p.h b/src/widgets/widgets/qwidgetlinecontrol_p.h index 185bc117b6..d88d75c651 100644 --- a/src/widgets/widgets/qwidgetlinecontrol_p.h +++ b/src/widgets/widgets/qwidgetlinecontrol_p.h @@ -213,7 +213,7 @@ public: } bool isReadOnly() const { return m_readOnly; } - void setReadOnly(bool enable) { m_readOnly = enable; } + void setReadOnly(bool enable); QString text() const { @@ -338,7 +338,6 @@ public: int cursorBlinkPeriod() const { return m_blinkPeriod; } void setCursorBlinkPeriod(int msec); - void resetCursorBlinkTimer(); bool cursorBlinkStatus() const { return m_blinkStatus; } |