diff main/MainWindow.cpp @ 1911:2160976df436 import-audio-data

Use progress dialog when importing audio data
author Chris Cannam
date Fri, 29 Jun 2018 13:57:29 +0100
parents dc275d7d9aa6
children a28cab68eac6
line wrap: on
line diff
--- a/main/MainWindow.cpp	Thu Jun 28 15:45:13 2018 +0100
+++ b/main/MainWindow.cpp	Fri Jun 29 13:57:29 2018 +0100
@@ -2901,13 +2901,23 @@
     format.setTimeUnits(CSVFormat::TimeAudioFrames);
 
     FileOpenStatus status = FileOpenSucceeded;
+
+    ProgressDialog *dialog = new ProgressDialog(tr("Importing audio data..."),
+                                                true, 0, this,
+                                                Qt::ApplicationModal);
     
     WaveFileModel *model = qobject_cast<WaveFileModel *>
         (DataFileReaderFactory::loadCSV
          (path, format,
-          getMainModel() ? getMainModel()->getSampleRate() : rate));
-
-    if (!model || !model->isOK()) {
+          getMainModel() ? getMainModel()->getSampleRate() : rate,
+          dialog));
+
+    if (dialog->wasCancelled()) {
+
+        delete model;
+        status = FileOpenCancelled;
+
+    } else if (!model || !model->isOK()) {
 
         delete model;
         status = FileOpenFailed;
@@ -2921,6 +2931,8 @@
                                      false);
     }
 
+    delete dialog;
+    
     if (status == FileOpenFailed) {
         emit hideSplash();
         QMessageBox::critical(this, tr("Failed to open file"),