From cfc5f78c92c15e44ffba03ae2bb31129b81b85b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=A4rkl?= Date: Sun, 19 Nov 2017 15:09:48 +0100 Subject: [PATCH] Add/remove lines on Hexdump resize --- src/widgets/HexdumpWidget.cpp | 45 ++++++++--------------------------- src/widgets/HexdumpWidget.h | 2 +- 2 files changed, 11 insertions(+), 36 deletions(-) diff --git a/src/widgets/HexdumpWidget.cpp b/src/widgets/HexdumpWidget.cpp index 43e1260e..2261b2eb 100644 --- a/src/widgets/HexdumpWidget.cpp +++ b/src/widgets/HexdumpWidget.cpp @@ -151,13 +151,16 @@ void HexdumpWidget::connectScroll(bool disconnect) { if (disconnect) { - this->disconnect(ui->hexASCIIText->verticalScrollBar(), &QScrollBar::valueChanged, this, &HexdumpWidget::hexScrolled); - this->disconnect(ui->hexASCIIText, &QPlainTextEdit::cursorPositionChanged, this, &HexdumpWidget::hexScrolled); + this->disconnect(ui->hexASCIIText->verticalScrollBar(), &QScrollBar::valueChanged, this, + &HexdumpWidget::adjustHexdumpLines); + this->disconnect(ui->hexASCIIText, &QPlainTextEdit::cursorPositionChanged, this, + &HexdumpWidget::adjustHexdumpLines); } else { - connect(ui->hexASCIIText->verticalScrollBar(), &QScrollBar::valueChanged, this, &HexdumpWidget::hexScrolled); - connect(ui->hexASCIIText, &QPlainTextEdit::cursorPositionChanged, this, &HexdumpWidget::hexScrolled); + connect(ui->hexASCIIText->verticalScrollBar(), &QScrollBar::valueChanged, this, + &HexdumpWidget::adjustHexdumpLines); + connect(ui->hexASCIIText, &QPlainTextEdit::cursorPositionChanged, this, &HexdumpWidget::adjustHexdumpLines); } } @@ -481,7 +484,7 @@ void HexdumpWidget::resizeHexdump() //this->hexASCIIText->setMinimumWidth(this->hexASCIIText->document()->size().width()); } -void HexdumpWidget::hexScrolled() +void HexdumpWidget::adjustHexdumpLines() { QScrollBar *sb = ui->hexASCIIText->verticalScrollBar(); int topMargin = sb->value() - sb->minimum(); @@ -839,37 +842,9 @@ void HexdumpWidget::on_memSideToolButton_clicked() void HexdumpWidget::resizeEvent(QResizeEvent *event) { - // FIXME - /* - if (main->responsive && isVisible()) - { - if (event->size().width() <= 1150) - { - ui->frame_3->setVisible(false); - ui->memPreviewTab->setVisible(false); - ui->previewToolButton_2->setChecked(false); - if (event->size().width() <= 950) - { - ui->memSideTabWidget_2->hide(); - ui->hexSideTab_2->hide(); - ui->memSideToolButton->setChecked(true); - } - else - { - ui->memSideTabWidget_2->show(); - ui->hexSideTab_2->show(); - ui->memSideToolButton->setChecked(false); - } - } - else - { - ui->frame_3->setVisible(true); - ui->memPreviewTab->setVisible(true); - ui->previewToolButton_2->setChecked(true); - } - } - */ QDockWidget::resizeEvent(event); + + adjustHexdumpLines(); } void HexdumpWidget::wheelEvent(QWheelEvent* event) diff --git a/src/widgets/HexdumpWidget.h b/src/widgets/HexdumpWidget.h index 4e7da352..284289e2 100644 --- a/src/widgets/HexdumpWidget.h +++ b/src/widgets/HexdumpWidget.h @@ -103,7 +103,7 @@ private slots: void on_action64columns_triggered(); void resizeHexdump(); - void hexScrolled(); + void adjustHexdumpLines(); void on_codeCombo_2_currentTextChanged(const QString &arg1); void on_hexSideTab_2_currentChanged(int index);