diff main/MainWindow.cpp @ 637:f45af8d8091e imaf_enc

Merge from default branch
author Chris Cannam
date Mon, 04 Nov 2013 17:47:53 +0000
parents 767789a78984 2484381b53a1
children bfd68cc71a25
line wrap: on
line diff
--- a/main/MainWindow.cpp	Mon Nov 04 17:17:09 2013 +0000
+++ b/main/MainWindow.cpp	Mon Nov 04 17:47:53 2013 +0000
@@ -393,6 +393,11 @@
 void
 MainWindow::goFullScreen()
 {
+    if (m_viewManager->getZoomWheelsEnabled()) {
+        // The wheels seem to end up in the wrong place in full-screen mode
+        toggleZoomWheels();
+    }
+
     QWidget *ps = m_mainScroll->takeWidget();
     ps->setParent(0);
 
@@ -427,6 +432,7 @@
         if (sc) delete sc;
     }
 
+    m_paneStack->showNormal();
     m_mainScroll->setWidget(m_paneStack);
 }
 
@@ -537,6 +543,12 @@
     connect(this, SIGNAL(canExportAudio(bool)), action, SLOT(setEnabled(bool)));
     menu->addAction(action);
 
+    action = new QAction(tr("&Export Audio Data..."), this);
+    action->setStatusTip(tr("Export audio from selection into a data file"));
+    connect(action, SIGNAL(triggered()), this, SLOT(exportAudioData()));
+    connect(this, SIGNAL(canExportAudio(bool)), action, SLOT(setEnabled(bool)));
+    menu->addAction(action);
+
     QAction *actionCreateIMAF = new QAction(tr("&Export IMAF File..."), this);
     actionCreateIMAF->setStatusTip(tr("Export selection as an IMAF file"));
     menu->addAction(actionCreateIMAF);
@@ -547,9 +559,6 @@
     menu->addAction(actionOpenIMAF);
     connect(actionOpenIMAF,SIGNAL(triggered()),this,SLOT(importIMAF()));
 
-
-
-
     menu->addSeparator();
 
     action = new QAction(tr("Import Annotation &Layer..."), this);
@@ -800,9 +809,15 @@
         }
     }
 
+    action = new QAction(tr("Reset Numbering Counters"), this);
+    action->setStatusTip(tr("Reset to 1 all the counters used for counter-based labelling"));
+    connect(action, SIGNAL(triggered()), this, SLOT(resetInstantsCounters()));
+    connect(this, SIGNAL(replacedDocument()), action, SLOT(trigger()));
+    menu->addAction(action);
+
     action = new QAction(tr("Set Numbering Counters..."), this);
     action->setStatusTip(tr("Set the counters used for counter-based labelling"));
-    connect(action, SIGNAL(triggered()), this, SLOT(resetInstantsCounters()));
+    connect(action, SIGNAL(triggered()), this, SLOT(setInstantsCounters()));
     menu->addAction(action);
 
     action = new QAction(tr("Renumber Selected Instants"), this);
@@ -2085,6 +2100,7 @@
     action->setShortcut(tr("1"));
     action->setStatusTip(tr("Navigate"));
     connect(action, SIGNAL(triggered()), this, SLOT(toolNavigateSelected()));
+    connect(this, SIGNAL(replacedDocument()), action, SLOT(trigger()));
     group->addAction(action);
     m_keyReference->registerShortcut(action);
     m_toolActions[ViewManager::NavigateMode] = action;
@@ -2357,6 +2373,18 @@
 void
 MainWindow::exportAudio()
 {
+    exportAudio(false);
+}
+
+void
+MainWindow::exportAudioData()
+{
+    exportAudio(true);
+}
+
+void
+MainWindow::exportAudio(bool asData)
+{
     if (!getMainModel()) return;
 
     RangeSummarisableTimeValueModel *model = getMainModel();
@@ -2418,7 +2446,12 @@
         }
     }
 
-    QString path = getSaveFileName(FileFinder::AudioFile);
+    QString path;
+    if (asData) {
+        path = getSaveFileName(FileFinder::CSVFile);
+    } else {
+        path = getSaveFileName(FileFinder::AudioFile);
+    }
     if (path == "") return;
 
     bool ok = false;
@@ -2449,25 +2482,32 @@
 
     } else if (selections.size() > 1) {
 
-    QStringList items;
-    items << tr("Export the selected regions into a single audio file")
-          << tr("Export the selected regions into separate files")
-          << tr("Export the whole audio file");
-
-    QString item = ListInputDialog::getItem
-        (this, tr("Select region to export"),
-         tr("Multiple regions of the original audio file are selected.\nWhat do you want to export?"),
-         items, 0, &ok);
-
-    if (!ok || item.isEmpty()) return;
-
-    if (item == items[0]) {
-
+        bool multiple = false;
+
+        if (!asData) { // Multi-file export not supported for data
+
+            QStringList items;
+            items << tr("Export the selected regions into a single file")
+                  << tr("Export the selected regions into separate files")
+                  << tr("Export the whole file");
+
+            QString item = ListInputDialog::getItem
+                (this, tr("Select region to export"),
+                 tr("Multiple regions of the original audio file are selected.\nWhat do you want to export?"),
+                 items, 0, &ok);
+	    
+            if (!ok || item.isEmpty()) return;
+            
+            if (item == items[0]) {
+                selectionToWrite = &ms;
+            } else if (item == items[1]) {
+                multiple = true;
+            }
+        } else { // asData
             selectionToWrite = &ms;
-
-        } else if (item == items[1]) {
-
-            multiple = true;
+        }
+
+        if (multiple) { // Can only happen when asData false
 
         int n = 1;
         QString base = path;
@@ -2503,13 +2543,26 @@
     }
 
     if (!multiple) {
-        WavFileWriter writer(path,
-                             model->getSampleRate(),
-                             model->getChannelCount(),
-                             WavFileWriter::WriteToTemporary);
-        writer.writeModel(model, selectionToWrite);
-    ok = writer.isOK();
-    error = writer.getError();
+        if (asData) {
+            CSVFileWriter writer(path, model,
+                                 ((QFileInfo(path).suffix() == "csv") ?
+                                  "," : "\t"));
+            if (selectionToWrite) {
+                writer.writeSelection(selectionToWrite);
+            } else {
+                writer.write();
+            }
+            ok = writer.isOK();
+            error = writer.getError();
+        } else {
+            WavFileWriter writer(path,
+                                 model->getSampleRate(),
+                                 model->getChannelCount(),
+                                 WavFileWriter::WriteToTemporary);
+            writer.writeModel(model, selectionToWrite);
+            ok = writer.isOK();
+            error = writer.getError();
+        }
     }
 
     if (ok) {
@@ -2520,7 +2573,7 @@
             m_recentFiles.addFile(path);
         }
     } else {
-    QMessageBox::critical(this, tr("Failed to write file"), error);
+        QMessageBox::critical(this, tr("Failed to write file"), error);
     }
 }
 
@@ -3121,8 +3174,11 @@
 
     QSettings settings;
     settings.beginGroup("MainWindow");
-    settings.setValue("size", size());
-    settings.setValue("position", pos());
+    settings.setValue("maximised", isMaximized());
+    if (!isMaximized()) {
+        settings.setValue("size", size());
+        settings.setValue("position", pos());
+    }
     settings.endGroup();
 
     if (m_preferencesDialog &&
@@ -4083,7 +4139,7 @@
 }
 
 void
-MainWindow::resetInstantsCounters()
+MainWindow::setInstantsCounters()
 {
     LabelCounterInputDialog dialog(m_labeller, this);
     dialog.setWindowTitle(tr("Reset Counters"));
@@ -4091,6 +4147,12 @@
 }
 
 void
+MainWindow::resetInstantsCounters()
+{
+    if (m_labeller) m_labeller->resetCounters();
+}
+
+void
 MainWindow::modelGenerationFailed(QString transformName, QString message)
 {
     emit hideSplash();