diff options
author | zackr <zack@kde.org> | 2014-07-10 15:12:14 -0400 |
---|---|---|
committer | zackr <zack@kde.org> | 2014-07-10 15:12:14 -0400 |
commit | aebf432f334ec0b48eb358569b9dfbfbead48017 (patch) | |
tree | 751100cdf590fbc309cf285116c0c1309be114f7 /gui | |
parent | 324b5ba6377fc05580299d736aa2ac99ae3f057c (diff) | |
parent | b86e993a82d3a68b9ae846515b714cdab3b9154b (diff) |
Merge pull request #282 from urkle/fix_image_save
fix saving image via right click menu in state inspector
Diffstat (limited to 'gui')
-rw-r--r-- | gui/mainwindow.cpp | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index 8f0ed404..b409692c 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -21,6 +21,7 @@ #include "ui_profilereplaydialog.h" #include "vertexdatainterpreter.h" #include "trace_profiler.hpp" +#include "image/image.hpp" #include <QAction> #include <QApplication> @@ -1272,7 +1273,20 @@ void MainWindow::saveSelectedSurface() } QVariant var = item->data(0, Qt::UserRole); + if (!var.isValid()) { + return; + } + QImage img = var.value<QImage>(); + if (img.isNull()) { + image::Image *traceImage = ApiSurface::imageFromBase64(var.value<QByteArray>()); + img = ApiSurface::qimageFromRawImage(traceImage); + delete traceImage; + } + if (img.isNull()) { + statusBar()->showMessage( "Failed to save image", 5000); + return; + } QString imageIndex; if (selectedCall()) { @@ -1313,8 +1327,11 @@ void MainWindow::saveSelectedSurface() .arg(parentIndex) .arg(childIndex); //qDebug()<<"save "<<fileName; - img.save(fileName, "PNG"); - statusBar()->showMessage( tr("Saved '%1'").arg(fileName), 5000); + if (img.save(fileName, "PNG")) { + statusBar()->showMessage( tr("Saved '%1'").arg(fileName), 5000); + } else { + statusBar()->showMessage( tr("Failed to save '%1'").arg(fileName), 5000); + } } void MainWindow::exportBufferData() |