From 75146d63f9ada9c82c8c39b99d3a55d52d6b9445 Mon Sep 17 00:00:00 2001 From: karliss Date: Thu, 23 May 2019 13:44:28 +0300 Subject: [PATCH] Update hex side panel only when visible. (#1578) Fixes #1528 --- src/widgets/HexdumpWidget.cpp | 58 +++++++------ src/widgets/HexdumpWidget.h | 3 +- src/widgets/HexdumpWidget.ui | 150 ---------------------------------- 3 files changed, 29 insertions(+), 182 deletions(-) diff --git a/src/widgets/HexdumpWidget.cpp b/src/widgets/HexdumpWidget.cpp index eb3042ff..2b142462 100644 --- a/src/widgets/HexdumpWidget.cpp +++ b/src/widgets/HexdumpWidget.cpp @@ -49,13 +49,11 @@ HexdumpWidget::HexdumpWidget(MainWindow *main, QAction *action) : ui->openSideViewB->hide(); // hide button at startup since side view is visible connect(closeButton, &QToolButton::clicked, this, [this] { - ui->hexSideTab_2->hide(); - ui->openSideViewB->show(); + showSidePanel(false); }); connect(ui->openSideViewB, &QToolButton::clicked, this, [this] { - ui->hexSideTab_2->show(); - ui->openSideViewB->hide(); + showSidePanel(true); }); ui->bytesMD5->setPlaceholderText("Select bytes to display information"); @@ -106,6 +104,7 @@ HexdumpWidget::HexdumpWidget(MainWindow *main, QAction *action) : } }); connect(ui->hexTextView, &HexWidget::selectionChanged, this, &HexdumpWidget::selectionChanged); + connect(ui->hexSideTab_2, &QTabWidget::currentChanged, this, &HexdumpWidget::refreshSelectionInfo); initParsing(); selectHexPreview(); @@ -208,19 +207,32 @@ void HexdumpWidget::clearParseWindow() ui->bytesSHA1->setText(""); } +void HexdumpWidget::showSidePanel(bool show) +{ + ui->hexSideTab_2->setVisible(show); + ui->openSideViewB->setHidden(show); + if (show) { + refreshSelectionInfo(); + } +} + void HexdumpWidget::updateParseWindow(RVA start_address, int size) { + if (!ui->hexSideTab_2->isVisible()) { + return; + } QString address = RAddressString(start_address); - QString argument = QString("%1@" + address).arg(size); - // Get selected combos - QString arch = ui->parseArchComboBox->currentText(); - QString bits = ui->parseBitsComboBox->currentText(); - bool bigEndian = ui->parseEndianComboBox->currentIndex() == 1; - { + if (ui->hexSideTab_2->currentIndex() == 0) { // scope for TempConfig + + // Get selected combos + QString arch = ui->parseArchComboBox->currentText(); + QString bits = ui->parseBitsComboBox->currentText(); + bool bigEndian = ui->parseEndianComboBox->currentIndex() == 1; + TempConfig tempConfig; tempConfig .set("asm.arch", arch) @@ -261,30 +273,16 @@ void HexdumpWidget::updateParseWindow(RVA start_address, int size) default: ui->hexDisasTextEdit->setPlainText(""); } - } - - // Fill the information tab hashes and entropy - ui->bytesMD5->setText(Core()->cmd("ph md5 " + argument).trimmed()); - ui->bytesSHA1->setText(Core()->cmd("ph sha1 " + argument).trimmed()); - ui->bytesEntropy->setText(Core()->cmd("ph entropy " + argument).trimmed()); - ui->bytesMD5->setCursorPosition(0); - ui->bytesSHA1->setCursorPosition(0); -} - -/* - * Actions callback functions - */ - -void HexdumpWidget::on_actionHideHexdump_side_panel_triggered() -{ - if (ui->hexSideTab_2->isVisible()) { - ui->hexSideTab_2->hide(); } else { - ui->hexSideTab_2->show(); + // Fill the information tab hashes and entropy + ui->bytesMD5->setText(Core()->cmd("ph md5 " + argument).trimmed()); + ui->bytesSHA1->setText(Core()->cmd("ph sha1 " + argument).trimmed()); + ui->bytesEntropy->setText(Core()->cmd("ph entropy " + argument).trimmed()); + ui->bytesMD5->setCursorPosition(0); + ui->bytesSHA1->setCursorPosition(0); } } - void HexdumpWidget::on_parseTypeComboBox_currentTextChanged(const QString &) { if (ui->parseTypeComboBox->currentIndex() == 0) { diff --git a/src/widgets/HexdumpWidget.h b/src/widgets/HexdumpWidget.h index 939f3e1a..c0575fdc 100644 --- a/src/widgets/HexdumpWidget.h +++ b/src/widgets/HexdumpWidget.h @@ -57,6 +57,7 @@ private: void refreshSelectionInfo(); void updateParseWindow(RVA start_address, int size); void clearParseWindow(); + void showSidePanel(bool show); QAction syncAction; CutterSeekable *seekable; @@ -64,8 +65,6 @@ private: private slots: void onSeekChanged(RVA addr); - void on_actionHideHexdump_side_panel_triggered(); - void selectionChanged(HexWidget::Selection selection); void on_parseArchComboBox_currentTextChanged(const QString &arg1); diff --git a/src/widgets/HexdumpWidget.ui b/src/widgets/HexdumpWidget.ui index cd54b900..c1e26ddf 100644 --- a/src/widgets/HexdumpWidget.ui +++ b/src/widgets/HexdumpWidget.ui @@ -521,156 +521,6 @@ - - - Hexdump side panel - - - Hexdump side panel - - - - - Undefine - - - Undefine - - - - - Copy all - - - Copy all - - - - - Copy bytes - - - Copy bytes - - - - - Copy disasm - - - Copy disasm - - - - - Copy Hexpair - - - Copy Hexpair - - - - - Copy ASCII - - - Copy ASCII - - - - - Copy Text - - - Copy Text - - - - - Edit - - - Edit - - - - - Paste - - - Paste - - - - - Insert Hex - - - Insert Hex - - - - - Insert String - - - Insert String - - - - - Hex - - - - - Octal - - - - - Half-word - - - - - Word - - - - - Quad-word - - - - - Emoji - - - - - 1 byte - - - 1 byte - - - - - 2 bytes - - - 2 bytes - - - - - 4 bytes - - - 4 bytes - -