Skip to content

Commit

Permalink
fix blinking cursor (#336607) ; inverts cursor color
Browse files Browse the repository at this point in the history
  • Loading branch information
kermitfrog committed Dec 15, 2020
1 parent 325be48 commit c9e6d0a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
2 changes: 2 additions & 0 deletions gui/abstractbytearraycolumnrenderer_p.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
24 changes: 16 additions & 8 deletions gui/abstractbytearrayview_p.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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();
}
Expand All @@ -1019,7 +1027,7 @@ void AbstractByteArrayViewPrivate::unpauseCursor()
{
mCursorPaused = false;

if (mCursorBlinkTimer->isActive()) {
if (mCursorBlinkTimer != nullptr && mCursorBlinkTimer->isActive()) {
updateCursors();
}
}
Expand Down

0 comments on commit c9e6d0a

Please sign in to comment.