Showing success and error messages.
authorPhilipp Spitzer <philipp@spitzer.priv.at>
Wed, 21 Jun 2017 21:35:03 +0000 (23:35 +0200)
committerPhilipp Spitzer <philipp@spitzer.priv.at>
Wed, 21 Jun 2017 21:35:03 +0000 (23:35 +0200)
qtapp/barcode2cash/mainwindow.cpp
qtapp/barcode2cash/mainwindow.h

index b7f00c25a6ad5895cb01a87628887d23e45af7e2..fdc6847109b725be78d939d5b864fbd775ead56f 100644 (file)
@@ -24,6 +24,8 @@ MainWindow::MainWindow(QWidget *parent) :
         viewfinder->show();
         imageCapture = new QCameraImageCapture(camera);
         connect(imageCapture, SIGNAL(readyForCaptureChanged(bool)), SLOT(updateCameraInfo()));
+        connect(imageCapture, SIGNAL(imageSaved(int,QString)), SLOT(showCaptureSuccess(int,QString)));
+        connect(imageCapture, SIGNAL(error(int,QCameraImageCapture::Error,QString)), SLOT(showCaptureError(int,QCameraImageCapture::Error,QString)));
         updateCameraInfo();
         connect(ui->pbCapture, SIGNAL(clicked()), SLOT(capture()));
         camera->start();
@@ -55,3 +57,13 @@ void MainWindow::capture() {
     imageCapture->capture("test.jpg");
     camera->unlock();
 }
+
+
+void MainWindow::showCaptureSuccess(int, QString fileName) {
+    ui->statusBar->showMessage(tr("Image captured and saved as '%1'.").arg(fileName));
+}
+
+
+void MainWindow::showCaptureError(int, QCameraImageCapture::Error error, QString errorString) {
+    ui->statusBar->showMessage(tr("Error when capturing image (error id %2): %1.").arg(errorString, error));
+}
index afe03a050cf58aa11f0cd6022035689f1a0c0d1c..4344d1ebf65a7fe27155e57cd2c6e19c1aae0dff 100644 (file)
@@ -29,6 +29,9 @@ private:
 public slots:
     void updateCameraInfo();
     void capture();
+    void showCaptureSuccess(int id, QString fileName);
+    void showCaptureError(int id, QCameraImageCapture::Error error, QString errorString);
+
 };
 
 #endif // MAINWINDOW_H