Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix blinking cursor (#336607) ; inverts cursor color #1

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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