From c9e6d0a69a393479928aa2c8933666fea2e59c12 Mon Sep 17 00:00:00 2001 From: Tarbos Date: Tue, 15 Dec 2020 18:38:06 +0100 Subject: [PATCH] fix blinking cursor (#336607) ; inverts cursor color --- gui/abstractbytearraycolumnrenderer_p.cpp | 2 ++ gui/abstractbytearrayview_p.cpp | 24 +++++++++++++++-------- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/gui/abstractbytearraycolumnrenderer_p.cpp b/gui/abstractbytearraycolumnrenderer_p.cpp index bb6246464..e3ed475bf 100644 --- a/gui/abstractbytearraycolumnrenderer_p.cpp +++ b/gui/abstractbytearraycolumnrenderer_p.cpp @@ -716,6 +716,8 @@ void AbstractByteArrayColumnRendererPrivate::renderCursor(QPainter* painter, Add mByteTypeColored ? foregroundRoleForChar(byteChar) : KColorScheme::NormalText; const QBrush brush = colorScheme.foreground(foregroundRole); painter->fillRect(0, 0, mByteWidth, q->lineHeight(), brush); + const QColor& charColor = colorScheme.background(KColorScheme::NormalBackground).color(); + renderByteText(painter, byte, byteChar, charColor); } bool AbstractByteArrayColumnRendererPrivate::getNextSelectedAddressRange(AddressRange* _selection, unsigned int* _flag, diff --git a/gui/abstractbytearrayview_p.cpp b/gui/abstractbytearrayview_p.cpp index eacd39a1e..2f4d3a8bc 100644 --- a/gui/abstractbytearrayview_p.cpp +++ b/gui/abstractbytearrayview_p.cpp @@ -195,10 +195,14 @@ void AbstractByteArrayViewPrivate::init() setWheelController(mZoomWheelController); - mCursorBlinkTimer = new QTimer(q); - - QObject::connect(mCursorBlinkTimer, &QTimer::timeout, - q, [&]() { blinkCursor(); }); + if (QApplication::cursorFlashTime() > 0) { + mCursorBlinkTimer = new QTimer(q); + QObject::connect(mCursorBlinkTimer, &QTimer::timeout, + q, [&]() { blinkCursor(); }); + } else { + mCursorBlinkTimer = nullptr; + QObject::connect(q, &AbstractByteArrayView::cursorPositionChanged, q, [&]() { updateCursors();}); + } q->setAcceptDrops(true); } @@ -1005,12 +1009,16 @@ void AbstractByteArrayViewPrivate::startCursor() updateCursors(); - mCursorBlinkTimer->start(QApplication::cursorFlashTime() / 2); + if (mCursorBlinkTimer != nullptr) { + mCursorBlinkTimer->start(QApplication::cursorFlashTime() / 2); + } } -void AbstractByteArrayViewPrivate::stopCursor() + void AbstractByteArrayViewPrivate::stopCursor() { - mCursorBlinkTimer->stop(); + if (mCursorBlinkTimer != nullptr) { + mCursorBlinkTimer->stop(); + } pauseCursor(); } @@ -1019,7 +1027,7 @@ void AbstractByteArrayViewPrivate::unpauseCursor() { mCursorPaused = false; - if (mCursorBlinkTimer->isActive()) { + if (mCursorBlinkTimer != nullptr && mCursorBlinkTimer->isActive()) { updateCursors(); } }