From f92fb71b0ea8390f57a135718e4238876aef4036 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=A4rkl?= Date: Sat, 18 Aug 2018 21:28:04 +0200 Subject: [PATCH] Make af from DisassemblyContextMenu more meaningful --- src/dialogs/RenameDialog.cpp | 5 +++++ src/dialogs/RenameDialog.h | 2 ++ src/menus/DisassemblyContextMenu.cpp | 25 +++++++++++++++++-------- src/menus/DisassemblyContextMenu.h | 6 ++++-- 4 files changed, 28 insertions(+), 10 deletions(-) diff --git a/src/dialogs/RenameDialog.cpp b/src/dialogs/RenameDialog.cpp index f1cedc9a..e32f19e7 100644 --- a/src/dialogs/RenameDialog.cpp +++ b/src/dialogs/RenameDialog.cpp @@ -31,3 +31,8 @@ QString RenameDialog::getName() const { return ui->nameEdit->text(); } + +void RenameDialog::setPlaceholderText(const QString &text) +{ + ui->nameEdit->setPlaceholderText(text); +} \ No newline at end of file diff --git a/src/dialogs/RenameDialog.h b/src/dialogs/RenameDialog.h index dc787a1c..2ba5bb94 100644 --- a/src/dialogs/RenameDialog.h +++ b/src/dialogs/RenameDialog.h @@ -19,6 +19,8 @@ public: void setName(QString fcnName); QString getName() const; + void setPlaceholderText(const QString &text); + private slots: void on_buttonBox_accepted(); diff --git a/src/menus/DisassemblyContextMenu.cpp b/src/menus/DisassemblyContextMenu.cpp index d9b19509..9d30fc94 100644 --- a/src/menus/DisassemblyContextMenu.cpp +++ b/src/menus/DisassemblyContextMenu.cpp @@ -33,10 +33,6 @@ DisassemblyContextMenu::DisassemblyContextMenu(QWidget *parent) SLOT(on_actionAddFlag_triggered()), getAddFlagSequence()); addAction(&actionAddFlag); - initAction(&actionCreateFunction, tr("Create Function"), - SLOT(on_actionCreateFunction_triggered())); - addAction(&actionCreateFunction); - initAction(&actionRename, tr("Rename"), SLOT(on_actionRename_triggered()), getRenameSequence()); addAction(&actionRename); @@ -54,6 +50,8 @@ DisassemblyContextMenu::DisassemblyContextMenu(QWidget *parent) initAction(&actionDeleteFunction, tr("Undefine function"), SLOT(on_actionDeleteFunction_triggered())); addAction(&actionDeleteFunction); + addAnalyzeMenu(); + addSetBaseMenu(); addSetBitsMenu(); @@ -92,6 +90,16 @@ DisassemblyContextMenu::~DisassemblyContextMenu() } } +void DisassemblyContextMenu::addAnalyzeMenu() +{ + analyzeMenu = addMenu(tr("Analyze...")); + + initAction(&actionAnalyzeFunction, tr("Create Function")); + analyzeMenu->addAction(&actionAnalyzeFunction); + connect(&actionAnalyzeFunction, &QAction::triggered, this, + &DisassemblyContextMenu::on_actionAnalyzeFunction_triggered); +} + void DisassemblyContextMenu::addSetBaseMenu() { setBaseMenu = addMenu(tr("Set Immediate Base to...")); @@ -228,7 +236,7 @@ void DisassemblyContextMenu::aboutToShowSlot() setBaseMenu->menuAction()->setVisible(immBase); setBitsMenu->menuAction()->setVisible(true); - actionCreateFunction.setVisible(true); + actionAnalyzeFunction.setVisible(true); QString comment = Core()->cmd("CC." + RAddressString(offset)); if (comment.isNull() || comment.isEmpty()) { @@ -251,7 +259,7 @@ void DisassemblyContextMenu::aboutToShowSlot() actionDeleteFunction.setVisible(fcn ? true : false); if (fcn) { - actionCreateFunction.setVisible(false); + actionAnalyzeFunction.setVisible(false); actionRename.setVisible(true); actionRename.setText(tr("Rename function \"%1\"").arg(fcn->name)); } else if (f) { @@ -457,10 +465,11 @@ void DisassemblyContextMenu::on_actionAddComment_triggered() } } -void DisassemblyContextMenu::on_actionCreateFunction_triggered() +void DisassemblyContextMenu::on_actionAnalyzeFunction_triggered() { RenameDialog *dialog = new RenameDialog(this); - dialog->setWindowTitle(tr("Add function at %1").arg(RAddressString(offset))); + dialog->setWindowTitle(tr("Analyze function at %1").arg(RAddressString(offset))); + dialog->setPlaceholderText(tr("Auto")); if (dialog->exec()) { QString function_name = dialog->getName(); Core()->createFunctionAt(offset, function_name); diff --git a/src/menus/DisassemblyContextMenu.h b/src/menus/DisassemblyContextMenu.h index 7bf92bb6..7abdaf10 100644 --- a/src/menus/DisassemblyContextMenu.h +++ b/src/menus/DisassemblyContextMenu.h @@ -32,7 +32,7 @@ private slots: void on_actionCopy_triggered(); void on_actionCopyAddr_triggered(); void on_actionAddComment_triggered(); - void on_actionCreateFunction_triggered(); + void on_actionAnalyzeFunction_triggered(); void on_actionAddFlag_triggered(); void on_actionRename_triggered(); void on_actionRenameUsedHere_triggered(); @@ -82,7 +82,8 @@ private: QAction actionAddComment; QAction actionAddFlag; - QAction actionCreateFunction; + QMenu *analyzeMenu; + QAction actionAnalyzeFunction; QAction actionRename; QAction actionRenameUsedHere; QAction actionXRefs; @@ -132,6 +133,7 @@ private: void setToData(int size, int repeat = 1); void setBits(int bits); + void addAnalyzeMenu(); void addSetBaseMenu(); void addSetBitsMenu(); void addSetToDataMenu();