summaryrefslogtreecommitdiff
path: root/src/qcam/main_window.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/qcam/main_window.cpp')
-rw-r--r--src/qcam/main_window.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp
index f76890e7..29eaba84 100644
--- a/src/qcam/main_window.cpp
+++ b/src/qcam/main_window.cpp
@@ -12,7 +12,10 @@
#include <QComboBox>
#include <QCoreApplication>
+#include <QFileDialog>
#include <QIcon>
+#include <QImage>
+#include <QImageWriter>
#include <QInputDialog>
#include <QTimer>
#include <QToolBar>
@@ -88,6 +91,9 @@ int MainWindow::createToolbars()
action = toolbar_->addAction(QIcon(":stop-circle.svg"), "stop");
connect(action, &QAction::triggered, this, &MainWindow::stopCapture);
+ action = toolbar_->addAction(QIcon(":save.svg"), "saveAs");
+ connect(action, &QAction::triggered, this, &MainWindow::saveImageAs);
+
return 0;
}
@@ -339,6 +345,22 @@ void MainWindow::stopCapture()
setWindowTitle(title_);
}
+void MainWindow::saveImageAs()
+{
+ QImage image = viewfinder_->getCurrentImage();
+
+ QString filename = QFileDialog::getSaveFileName(this, "Save Image", "",
+ "Image Files (*.png *.jpg *.jpeg)");
+
+ std::cout << "Save image to " << filename.toStdString() << std::endl;
+
+ if (filename.isEmpty())
+ return;
+
+ QImageWriter writer(filename);
+ writer.write(image);
+}
+
void MainWindow::requestComplete(Request *request)
{
if (request->status() == Request::RequestCancelled)