diff main/MainWindow.cpp @ 508:26ebbe098bce

Add means to replace the main audio model
author Chris Cannam
date Mon, 02 Jul 2012 12:46:25 +0100
parents 22ebffe22f16
children f8833ed742fc
line wrap: on
line diff
--- a/main/MainWindow.cpp	Sat Jun 30 15:05:29 2012 +0100
+++ b/main/MainWindow.cpp	Mon Jul 02 12:46:25 2012 +0100
@@ -462,6 +462,13 @@
     connect(this, SIGNAL(canImportMoreAudio(bool)), iaction, SLOT(setEnabled(bool)));
     m_keyReference->registerShortcut(iaction);
 
+    // We want this one to go on the toolbar now, if we add it at all,
+    // but on the menu later
+    QAction *raction = new QAction(tr("Replace &Main Audio..."), this);
+    raction->setStatusTip(tr("Replace the main audio file of the session with a different file"));
+    connect(raction, SIGNAL(triggered()), this, SLOT(replaceMainAudio()));
+    connect(this, SIGNAL(canReplaceMainAudio(bool)), raction, SLOT(setEnabled(bool)));
+
     action = new QAction(tr("Open Lo&cation..."), this);
     action->setShortcut(tr("Ctrl+Shift+O"));
     action->setStatusTip(tr("Open or import a file from a remote URL"));
@@ -509,6 +516,9 @@
     menu->addAction(action);
 */
 
+    // the Replace action we made earlier
+    menu->addAction(raction);
+
     // the Import action we made earlier
     menu->addAction(iaction);
 
@@ -2306,6 +2316,20 @@
 }
 
 void
+MainWindow::replaceMainAudio()
+{
+    QString path = getOpenFileName(FileFinder::AudioFile);
+
+    if (path != "") {
+	if (openAudio(path, ReplaceMainModel) == FileOpenFailed) {
+            emit hideSplash();
+	    QMessageBox::critical(this, tr("Failed to open file"),
+				  tr("<b>File open failed</b><p>Audio file \"%1\" could not be opened").arg(path));
+	}
+    }
+}
+
+void
 MainWindow::exportAudio()
 {
     if (!getMainModel()) return;