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
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);
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;
{
// scope for TempConfig
TempConfig tempConfig;
tempConfig
.set("asm.arch", arch)
@ -261,30 +273,16 @@ void HexdumpWidget::updateParseWindow(RVA start_address, int size)
default:
ui->hexDisasTextEdit->setPlainText("");
}
}
} else {
// 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();
}
}
void HexdumpWidget::on_parseTypeComboBox_currentTextChanged(const QString &)
{
if (ui->parseTypeComboBox->currentIndex() == 0) {

View File

@ -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);

View File

@ -521,156 +521,6 @@
</item>
</layout>
</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>
<customwidgets>
<customwidget>