diff main/MainWindow.cpp @ 2442:b3330c31ea0e spectrogram-export

Add layer export of selected region as well as whole layer
author Chris Cannam
date Wed, 08 Jan 2020 15:41:46 +0000
parents d811380516f6
children 0075f5b8f76c
line wrap: on
line diff
--- a/main/MainWindow.cpp	Wed Jan 08 15:40:58 2020 +0000
+++ b/main/MainWindow.cpp	Wed Jan 08 15:41:46 2020 +0000
@@ -3020,9 +3020,29 @@
 
     if (path == "") return;
 
+    MultiSelection ms = m_viewManager->getSelection();
+    MultiSelection *selectionToWrite = nullptr;
+
+    if (!ms.getSelections().empty()) {
+
+        QStringList items;
+        items << tr("Export the content of the selected area")
+              << tr("Export the whole layer");
+        
+        bool ok = false;
+        QString item = ListInputDialog::getItem
+            (this, tr("Select region to export"),
+             tr("Which region of the layer do you want to export?"),
+             items, 0, &ok);
+        
+        if (!ok || item.isEmpty()) return;
+        
+        if (item == items[0]) selectionToWrite = &ms;
+    }
+    
     QString error;
 
-    if (!exportLayerTo(layer, pane, path, error)) {
+    if (!exportLayerTo(layer, pane, selectionToWrite, path, error)) {
         QMessageBox::critical(this, tr("Failed to write file"), error);
     } else {
         m_recentFiles.addFile(path);