GUI: Comments and labels in graph view (#1229)
This commit is contained in:
parent
3a7726015f
commit
afabd01f77
|
|
@ -1488,6 +1488,8 @@ void DisassemblerGraphView::setupContextMenu()
|
|||
});
|
||||
mMenuBuilder->addSeparator();
|
||||
|
||||
mMenuBuilder->addAction(mToggleOverview = makeShortcutAction(DIcon("comment.png"), tr("&Comment"), SLOT(setCommentSlot()), "ActionGraphComment"));
|
||||
mMenuBuilder->addAction(mToggleOverview = makeShortcutAction(DIcon("label.png"), tr("&Label"), SLOT(setLabelSlot()), "ActionGraphLabel"));
|
||||
mMenuBuilder->addAction(mToggleOverview = makeShortcutAction(tr("&Save as image"), SLOT(saveImageSlot()), "ActionGraphSaveImage"));
|
||||
mMenuBuilder->addAction(mToggleOverview = makeShortcutAction(DIcon("graph.png"), tr("&Overview"), SLOT(toggleOverviewSlot()), "ActionGraphToggleOverview"));
|
||||
mMenuBuilder->addAction(mToggleSyncOrigin = makeShortcutAction(DIcon("lock.png"), tr("&Sync with origin"), SLOT(toggleSyncOriginSlot()), "ActionGraphSyncOrigin"));
|
||||
|
|
@ -1623,3 +1625,50 @@ void DisassemblerGraphView::saveImageSlot()
|
|||
saveGraph = true;
|
||||
this->viewport()->update();
|
||||
}
|
||||
|
||||
void DisassemblerGraphView::setCommentSlot()
|
||||
{
|
||||
duint wVA = this->get_cursor_pos();
|
||||
LineEditDialog mLineEdit(this);
|
||||
QString addr_text = ToPtrString(wVA);
|
||||
char comment_text[MAX_COMMENT_SIZE] = "";
|
||||
|
||||
if(DbgGetCommentAt((duint)wVA, comment_text))
|
||||
{
|
||||
if(comment_text[0] == '\1') //automatic comment
|
||||
mLineEdit.setText(QString(comment_text + 1));
|
||||
else
|
||||
mLineEdit.setText(QString(comment_text));
|
||||
}
|
||||
|
||||
mLineEdit.setWindowTitle(tr("Add comment at ") + addr_text);
|
||||
|
||||
if(mLineEdit.exec() != QDialog::Accepted)
|
||||
return;
|
||||
|
||||
if(!DbgSetCommentAt(wVA, mLineEdit.editText.replace('\r', "").replace('\n', "").toUtf8().constData()))
|
||||
SimpleErrorBox(this, tr("Error!"), tr("DbgSetCommentAt failed!"));
|
||||
|
||||
this->refreshSlot();
|
||||
}
|
||||
|
||||
void DisassemblerGraphView::setLabelSlot()
|
||||
{
|
||||
duint wVA = this->get_cursor_pos();
|
||||
LineEditDialog mLineEdit(this);
|
||||
QString addr_text = ToPtrString(wVA);
|
||||
char label_text[MAX_COMMENT_SIZE] = "";
|
||||
|
||||
if(DbgGetLabelAt((duint)wVA, SEG_DEFAULT, label_text))
|
||||
mLineEdit.setText(QString(label_text));
|
||||
|
||||
mLineEdit.setWindowTitle(tr("Add label at ") + addr_text);
|
||||
|
||||
if(mLineEdit.exec() != QDialog::Accepted)
|
||||
return;
|
||||
|
||||
if(!DbgSetLabelAt(wVA, mLineEdit.editText.toUtf8().constData()))
|
||||
SimpleErrorBox(this, tr("Error!"), tr("DbgSetLabelAt failed!"));
|
||||
|
||||
this->refreshSlot();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
#include <algorithm>
|
||||
#include <QMutex>
|
||||
#include "Bridge.h"
|
||||
#include "LineEditDialog.h"
|
||||
#include "RichTextPainter.h"
|
||||
#include "QBeaEngine.h"
|
||||
|
||||
|
|
@ -272,6 +273,8 @@ public slots:
|
|||
void toggleSyncOriginSlot();
|
||||
void refreshSlot();
|
||||
void saveImageSlot();
|
||||
void setCommentSlot();
|
||||
void setLabelSlot();
|
||||
|
||||
private:
|
||||
QString status;
|
||||
|
|
|
|||
|
|
@ -484,6 +484,8 @@ Configuration::Configuration() : QObject(), noMoreMsgbox(false)
|
|||
defaultShortcuts.insert("ActionRefresh", Shortcut(tr("Actions -> Refresh"), "F5"));
|
||||
defaultShortcuts.insert("ActionGraph", Shortcut(tr("Actions -> Graph"), "G"));
|
||||
defaultShortcuts.insert("ActionGraphFollowDisassembler", Shortcut(tr("Actions -> Graph -> Follow in disassembler"), "Shift+Return"));
|
||||
defaultShortcuts.insert("ActionGraphComment", Shortcut(tr("Actions -> Graph -> Comment"), ";"));
|
||||
defaultShortcuts.insert("ActionGraphLabel", Shortcut(tr("Actions -> Graph -> Label"), ":"));
|
||||
defaultShortcuts.insert("ActionGraphSaveImage", Shortcut(tr("Actions -> Graph -> Save as image"), "I"));
|
||||
defaultShortcuts.insert("ActionGraphToggleOverview", Shortcut(tr("Actions -> Graph -> Toggle overview"), "O"));
|
||||
defaultShortcuts.insert("ActionGraphRefresh", Shortcut(tr("Actions -> Graph -> Refresh"), "R"));
|
||||
|
|
|
|||
Loading…
Reference in New Issue