mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-19 03:16:10 +00:00
Export graph as SVG, PDF, PNG... Fix #242
Export graph as SVG, PDF, PNG... Fix #242
This commit is contained in:
parent
ec2807a897
commit
c6787fd58d
2
radare2
2
radare2
@ -1 +1 @@
|
||||
Subproject commit f82b289822825e4c7403734f3b95dfd7f5e4f725
|
||||
Subproject commit b5044de59bf36a2ba6deb19100b57aa40592e829
|
@ -12,6 +12,7 @@
|
||||
#include <QFile>
|
||||
#include <QVBoxLayout>
|
||||
#include <QRegularExpression>
|
||||
#include <QStandardPaths>
|
||||
|
||||
#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";
|
||||
|
Loading…
Reference in New Issue
Block a user