From 1f6a29b4581e1c49468cdf7547580f609043ed0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=A4rkl?= Date: Sun, 19 Nov 2017 15:05:47 +0100 Subject: [PATCH] Fix Hexdump initial scroll --- src/widgets/HexdumpWidget.cpp | 24 ++++++++++++++++++------ src/widgets/HexdumpWidget.ui | 2 +- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/widgets/HexdumpWidget.cpp b/src/widgets/HexdumpWidget.cpp index 0230730a..43e1260e 100644 --- a/src/widgets/HexdumpWidget.cpp +++ b/src/widgets/HexdumpWidget.cpp @@ -284,16 +284,28 @@ void HexdumpWidget::refresh(RVA addr) ui->hexASCIIText->setPlainText(hexdump[2]); resizeHexdump(); - // Move cursor to desired address + + int seekLine = static_cast((addr - topOffset) / cols); + + // Move cursors to desired address QTextCursor cur = ui->hexOffsetText->textCursor(); cur.movePosition(QTextCursor::Start); - cur.movePosition(QTextCursor::Down, QTextCursor::MoveAnchor, linesMarginDefault); + cur.movePosition(QTextCursor::Down, QTextCursor::MoveAnchor, seekLine); ui->hexOffsetText->setTextCursor(cur); - int scroll = static_cast((addr - topOffset) / cols); - ui->hexOffsetText->verticalScrollBar()->setValue(scroll); - ui->hexHexText->verticalScrollBar()->setValue(scroll); - ui->hexASCIIText->verticalScrollBar()->setValue(scroll); + cur = ui->hexHexText->textCursor(); + cur.movePosition(QTextCursor::Start); + cur.movePosition(QTextCursor::Down, QTextCursor::MoveAnchor, seekLine); + ui->hexHexText->setTextCursor(cur); + + cur = ui->hexASCIIText->textCursor(); + cur.movePosition(QTextCursor::Start); + cur.movePosition(QTextCursor::Down, QTextCursor::MoveAnchor, seekLine); + ui->hexASCIIText->setTextCursor(cur); + + ui->hexOffsetText->verticalScrollBar()->setValue(seekLine); + ui->hexHexText->verticalScrollBar()->setValue(seekLine); + ui->hexASCIIText->verticalScrollBar()->setValue(seekLine); connectScroll(false); } diff --git a/src/widgets/HexdumpWidget.ui b/src/widgets/HexdumpWidget.ui index 8d916078..e91b441f 100644 --- a/src/widgets/HexdumpWidget.ui +++ b/src/widgets/HexdumpWidget.ui @@ -334,7 +334,7 @@ QToolTip { 0 - Qt::ScrollBarAlwaysOn + Qt::ScrollBarAlwaysOff Qt::ScrollBarAlwaysOff