Added export graph as dot (#330)

This commit is contained in:
0xcpy 2018-02-14 10:33:34 +01:00 committed by xarkes
parent 16ebe024a3
commit 7fa2b9bf61
2 changed files with 25 additions and 0 deletions

View File

@ -8,6 +8,8 @@
#include <QShortcut>
#include <QToolTip>
#include <QTextDocument>
#include <QFileDialog>
#include <QFile>
#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 -");
}

View File

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