diff --git a/radare2 b/radare2 index f82b2898..b5044de5 160000 --- a/radare2 +++ b/radare2 @@ -1 +1 @@ -Subproject commit f82b289822825e4c7403734f3b95dfd7f5e4f725 +Subproject commit b5044de59bf36a2ba6deb19100b57aa40592e829 diff --git a/src/widgets/DisassemblerGraphView.cpp b/src/widgets/DisassemblerGraphView.cpp index 30d6f091..0579c302 100644 --- a/src/widgets/DisassemblerGraphView.cpp +++ b/src/widgets/DisassemblerGraphView.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include "Cutter.h" #include "utils/Colors.h" @@ -821,8 +822,36 @@ void DisassemblerGraphView::blockTransitionedTo(GraphView::GraphBlock *to) void DisassemblerGraphView::on_actionExportGraph_triggered() { - QString fileName = QFileDialog::getSaveFileName(this, - tr("Export Graph"), "", tr("Dot file (*.dot)")); + QStringList filters; + filters.append(tr("Graphiz dot (*.dot)")); + if (!QStandardPaths::findExecutable("dot").isEmpty() + || !QStandardPaths::findExecutable("xdot").isEmpty()) { + filters.append(tr("GIF (*.gif)")); + filters.append(tr("PNG (*.png)")); + filters.append(tr("JPEG (*.jpg)")); + filters.append(tr("PostScript (*.ps)")); + filters.append(tr("SVG (*.svg)")); + filters.append(tr("JSON (*.json)")); + } + + QFileDialog dialog(this, tr("Export Graph")); + dialog.setAcceptMode(QFileDialog::AcceptSave); + dialog.setFileMode(QFileDialog::AnyFile); + dialog.setNameFilters(filters); + dialog.selectFile("graph"); + dialog.setDefaultSuffix("dot"); + if (!dialog.exec()) + return; + int startIdx = dialog.selectedNameFilter().lastIndexOf("*.") + 2; + int count = dialog.selectedNameFilter().length() - startIdx - 1; + QString format = dialog.selectedNameFilter().mid(startIdx, count); + QString fileName = dialog.selectedFiles()[0]; + if (format != "dot") { + TempConfig tempConfig; + tempConfig.set("graph.gv.format", format); + qWarning() << Core()->cmd(QString("agfw \"%1\" @ $FB").arg(fileName)); + return; + } QFile file(fileName); if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) { qWarning() << "Can't open file";