Update hex side panel only when visible. (#1578)

Fixes #1528
This commit is contained in:
karliss 2019-05-23 13:44:28 +03:00 committed by Florian Märkl
parent 1e4f933733
commit 75146d63f9
3 changed files with 29 additions and 182 deletions

View File

@ -49,13 +49,11 @@ HexdumpWidget::HexdumpWidget(MainWindow *main, QAction *action) :
ui->openSideViewB->hide(); // hide button at startup since side view is visible ui->openSideViewB->hide(); // hide button at startup since side view is visible
connect(closeButton, &QToolButton::clicked, this, [this] { connect(closeButton, &QToolButton::clicked, this, [this] {
ui->hexSideTab_2->hide(); showSidePanel(false);
ui->openSideViewB->show();
}); });
connect(ui->openSideViewB, &QToolButton::clicked, this, [this] { connect(ui->openSideViewB, &QToolButton::clicked, this, [this] {
ui->hexSideTab_2->show(); showSidePanel(true);
ui->openSideViewB->hide();
}); });
ui->bytesMD5->setPlaceholderText("Select bytes to display information"); 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->hexTextView, &HexWidget::selectionChanged, this, &HexdumpWidget::selectionChanged);
connect(ui->hexSideTab_2, &QTabWidget::currentChanged, this, &HexdumpWidget::refreshSelectionInfo);
initParsing(); initParsing();
selectHexPreview(); selectHexPreview();
@ -208,19 +207,32 @@ void HexdumpWidget::clearParseWindow()
ui->bytesSHA1->setText(""); 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) void HexdumpWidget::updateParseWindow(RVA start_address, int size)
{ {
if (!ui->hexSideTab_2->isVisible()) {
return;
}
QString address = RAddressString(start_address); QString address = RAddressString(start_address);
QString argument = QString("%1@" + address).arg(size); 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 // 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 tempConfig;
tempConfig tempConfig
.set("asm.arch", arch) .set("asm.arch", arch)
@ -261,30 +273,16 @@ void HexdumpWidget::updateParseWindow(RVA start_address, int size)
default: default:
ui->hexDisasTextEdit->setPlainText(""); 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 { } 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 &) void HexdumpWidget::on_parseTypeComboBox_currentTextChanged(const QString &)
{ {
if (ui->parseTypeComboBox->currentIndex() == 0) { if (ui->parseTypeComboBox->currentIndex() == 0) {

View File

@ -57,6 +57,7 @@ private:
void refreshSelectionInfo(); void refreshSelectionInfo();
void updateParseWindow(RVA start_address, int size); void updateParseWindow(RVA start_address, int size);
void clearParseWindow(); void clearParseWindow();
void showSidePanel(bool show);
QAction syncAction; QAction syncAction;
CutterSeekable *seekable; CutterSeekable *seekable;
@ -64,8 +65,6 @@ private:
private slots: private slots:
void onSeekChanged(RVA addr); void onSeekChanged(RVA addr);
void on_actionHideHexdump_side_panel_triggered();
void selectionChanged(HexWidget::Selection selection); void selectionChanged(HexWidget::Selection selection);
void on_parseArchComboBox_currentTextChanged(const QString &arg1); void on_parseArchComboBox_currentTextChanged(const QString &arg1);

View File

@ -521,156 +521,6 @@
</item> </item>
</layout> </layout>
</widget> </widget>
<action name="actionHideHexdump_side_panel">
<property name="text">
<string>Hexdump side panel</string>
</property>
<property name="toolTip">
<string>Hexdump side panel</string>
</property>
</action>
<action name="actionFunctionsUndefine">
<property name="text">
<string>Undefine</string>
</property>
<property name="toolTip">
<string>Undefine</string>
</property>
</action>
<action name="actionDisasCopy_All">
<property name="text">
<string>Copy all</string>
</property>
<property name="toolTip">
<string>Copy all</string>
</property>
</action>
<action name="actionDisasCopy_Bytes">
<property name="text">
<string>Copy bytes</string>
</property>
<property name="toolTip">
<string>Copy bytes</string>
</property>
</action>
<action name="actionDisasCopy_Disasm">
<property name="text">
<string>Copy disasm</string>
</property>
<property name="toolTip">
<string>Copy disasm</string>
</property>
</action>
<action name="actionHexCopy_Hexpair">
<property name="text">
<string>Copy Hexpair</string>
</property>
<property name="toolTip">
<string>Copy Hexpair</string>
</property>
</action>
<action name="actionHexCopy_ASCII">
<property name="text">
<string>Copy ASCII</string>
</property>
<property name="toolTip">
<string>Copy ASCII</string>
</property>
</action>
<action name="actionHexCopy_Text">
<property name="text">
<string>Copy Text</string>
</property>
<property name="toolTip">
<string>Copy Text</string>
</property>
</action>
<action name="actionHexEdit">
<property name="text">
<string>Edit</string>
</property>
<property name="toolTip">
<string>Edit</string>
</property>
</action>
<action name="actionHexPaste">
<property name="text">
<string>Paste</string>
</property>
<property name="toolTip">
<string>Paste</string>
</property>
</action>
<action name="actionHexInsert_Hex">
<property name="text">
<string>Insert Hex</string>
</property>
<property name="toolTip">
<string>Insert Hex</string>
</property>
</action>
<action name="actionHexInsert_String">
<property name="text">
<string>Insert String</string>
</property>
<property name="toolTip">
<string>Insert String</string>
</property>
</action>
<action name="actionFormatHex">
<property name="text">
<string>Hex</string>
</property>
</action>
<action name="actionFormatOctal">
<property name="text">
<string>Octal</string>
</property>
</action>
<action name="actionFormatHalfWord">
<property name="text">
<string>Half-word</string>
</property>
</action>
<action name="actionFormatWord">
<property name="text">
<string>Word</string>
</property>
</action>
<action name="actionFormatQuadWord">
<property name="text">
<string>Quad-word</string>
</property>
</action>
<action name="actionFormatEmoji">
<property name="text">
<string>Emoji</string>
</property>
</action>
<action name="actionFormatSignedInt1">
<property name="text">
<string>1 byte</string>
</property>
<property name="toolTip">
<string>1 byte</string>
</property>
</action>
<action name="actionFormatSignedInt2">
<property name="text">
<string>2 bytes</string>
</property>
<property name="toolTip">
<string>2 bytes</string>
</property>
</action>
<action name="actionFormatSignedInt4">
<property name="text">
<string>4 bytes</string>
</property>
<property name="toolTip">
<string>4 bytes</string>
</property>
</action>
</widget> </widget>
<customwidgets> <customwidgets>
<customwidget> <customwidget>