From 7fa2b9bf6130f27e4a24d311316c4433294363fd Mon Sep 17 00:00:00 2001 From: 0xcpy <36159262+0xcpy@users.noreply.github.com> Date: Wed, 14 Feb 2018 10:33:34 +0100 Subject: [PATCH] Added export graph as dot (#330) --- src/widgets/DisassemblerGraphView.cpp | 21 +++++++++++++++++++++ src/widgets/DisassemblerGraphView.h | 4 ++++ 2 files changed, 25 insertions(+) diff --git a/src/widgets/DisassemblerGraphView.cpp b/src/widgets/DisassemblerGraphView.cpp index 88081502..a2b287fa 100644 --- a/src/widgets/DisassemblerGraphView.cpp +++ b/src/widgets/DisassemblerGraphView.cpp @@ -8,6 +8,8 @@ #include #include #include +#include +#include #include "cutter.h" #include "utils/Colors.h" @@ -90,6 +92,12 @@ DisassemblerGraphView::DisassemblerGraphView(QWidget *parent) shortcuts.append(shortcut_next_instr_arrow); shortcuts.append(shortcut_prev_instr_arrow); + //Export Graph menu + mMenu->addSeparator(); + actionExportGraph.setText(tr("Export Graph")); + mMenu->addAction(&actionExportGraph); + connect(&actionExportGraph, SIGNAL(triggered(bool)), this, SLOT(on_actionExportGraph_triggered())); + initFont(); colorsUpdatedSlot(); } @@ -710,3 +718,16 @@ void DisassemblerGraphView::blockTransitionedTo(GraphView::GraphBlock *to) } seek(to->entry); } + +void DisassemblerGraphView::on_actionExportGraph_triggered() +{ + QString fileName = QFileDialog::getSaveFileName(this, + tr("Export Graph"), "", tr("Dot file (*.dot)")); + QFile file(fileName); + if (!file.open(QIODevice::WriteOnly | QIODevice::Text)){ + qWarning() << "Can't open file"; + return; + } + QTextStream fileOut(&file); + fileOut << Core()->cmd("ag -"); +} diff --git a/src/widgets/DisassemblerGraphView.h b/src/widgets/DisassemblerGraphView.h index 959c2768..1e42e0a0 100644 --- a/src/widgets/DisassemblerGraphView.h +++ b/src/widgets/DisassemblerGraphView.h @@ -169,6 +169,8 @@ public slots: private slots: void seekPrev(); + void on_actionExportGraph_triggered(); + private: bool first_draw = true; bool transition_dont_seek = false; @@ -216,6 +218,8 @@ private: QColor mCipColor; QColor mBreakpointColor; QColor mDisabledBreakpointColor; + + QAction actionExportGraph; }; #endif // DISASSEMBLERGRAPHVIEW_H