changeset 294:975f6b6c414c sv-v1.4 sv-v1.4rc1

* Improvements to importer feedback dialogs and suchlike
author Chris Cannam
date Fri, 05 Dec 2008 18:45:49 +0000
parents c4bc499122ec
children 75c32cc2814a
files main/MainWindow.cpp main/MainWindow.h
diffstat 2 files changed, 37 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/main/MainWindow.cpp	Thu Dec 04 17:17:06 2008 +0000
+++ b/main/MainWindow.cpp	Fri Dec 05 18:45:49 2008 +0000
@@ -2182,7 +2182,7 @@
         } else if (status == FileOpenWrongMode) {
             emit hideSplash();
             QMessageBox::critical(this, tr("Failed to open file"),
-                                  tr("<b>Audio required</b><p>Please load at least one audio file before importing annotation data"));
+                                  tr("<b>Audio required</b><p>Unable to load layer data from \"%1\" without an audio file.<br>Please load at least one audio file before importing annotations.").arg(path));
         }
     }
 }
@@ -2482,7 +2482,7 @@
     } else if (status == FileOpenWrongMode) {
         emit hideSplash();
         QMessageBox::critical(this, tr("Failed to open file"),
-                              tr("<b>Audio required</b><p>Please load at least one audio file before importing annotation data"));
+                              tr("<b>Audio required</b><p>Unable to load layer data from \"%1\" without an audio file.<br>Please load at least one audio file before importing annotations.").arg(path));
     }
 }
 
@@ -2514,7 +2514,7 @@
     } else if (status == FileOpenWrongMode) {
         emit hideSplash();
         QMessageBox::critical(this, tr("Failed to open location"),
-                              tr("<b>Audio required</b><p>Please load at least one audio file before importing annotation data"));
+                              tr("<b>Audio required</b><p>Unable to load layer data from \"%1\" without an audio file.<br>Please load at least one audio file before importing annotations.").arg(text));
     }
 }
 
@@ -2542,7 +2542,7 @@
     } else if (status == FileOpenWrongMode) {
         emit hideSplash();
         QMessageBox::critical(this, tr("Failed to open location"),
-                              tr("<b>Audio required</b><p>Please load at least one audio file before importing annotation data"));
+                              tr("<b>Audio required</b><p>Unable to load layer data from \"%1\" without an audio file.<br>Please load at least one audio file before importing annotations.").arg(path));
     }
 }
 
@@ -2580,7 +2580,7 @@
         } else if (status == FileOpenWrongMode) {
             emit hideSplash();
             QMessageBox::critical(this, tr("Failed to open dropped URL"),
-                                  tr("<b>Audio required</b><p>Please load at least one audio file before importing annotation data"));
+                                  tr("<b>Audio required</b><p>Unable to load layer data from \"%1\" without an audio file.<br>Please load at least one audio file before importing annotations.").arg(*i));
         }
     }
 }
@@ -2728,20 +2728,39 @@
 }
 
 bool
-MainWindow::shouldCreateNewSessionForRDFAudio()
+MainWindow::shouldCreateNewSessionForRDFAudio(bool *cancel)
 {
-    QMessageBox mb;
-    mb.setWindowTitle("Open as new session?");
-    mb.setText("<b>RDF refers to audio files</b><p>This RDF document refers to one or more audio files.<br>Do you want to start a new session for it?");
-    QPushButton *a = mb.addButton(tr("Create new session"), QMessageBox::AcceptRole);
-    QPushButton *b = mb.addButton(tr("Add to current session"), QMessageBox::RejectRole);
-    mb.setDefaultButton(a);
-    mb.exec();
-    if (mb.clickedButton() == a) {
-        return true;
-    } else {
+    //!!! This is very similar to part of MainWindowBase::openAudio --
+    //!!! make them a bit more uniform
+
+    QSettings settings;
+    settings.beginGroup("MainWindow");
+    bool prevNewSession = settings.value("newsessionforrdfaudio", true).toBool();
+    settings.endGroup();
+    bool newSession = true;
+            
+    QStringList items;
+    items << tr("Close the current session and create a new one")
+          << tr("Add this data to the current session");
+
+    bool ok = false;
+    QString item = ListInputDialog::getItem
+        (this, tr("Select target for import"),
+         tr("<b>Select a target for import</b><p>This RDF document refers to one or more audio files.<br>You already have an audio waveform loaded.<br>What would you like to do with the new data?"),
+         items, prevNewSession ? 0 : 1, &ok);
+            
+    if (!ok || item.isEmpty()) {
+        *cancel = true;
         return false;
     }
+            
+    newSession = (item == items[0]);
+    settings.beginGroup("MainWindow");
+    settings.setValue("newsessionforrdfaudio", newSession);
+    settings.endGroup();
+
+    if (newSession) return true;
+    else return false;
 }
 
 void
@@ -3731,3 +3750,4 @@
     m_keyReference->show();
 }
 
+
--- a/main/MainWindow.h	Thu Dec 04 17:17:06 2008 +0000
+++ b/main/MainWindow.h	Fri Dec 05 18:45:49 2008 +0000
@@ -261,7 +261,7 @@
 
     virtual void updateVisibleRangeDisplay(Pane *p) const;
 
-    virtual bool shouldCreateNewSessionForRDFAudio();
+    virtual bool shouldCreateNewSessionForRDFAudio(bool *cancel);
     
     virtual void connectLayerEditDialog(ModelDataTableDialog *);
 };