changeset 508:26ebbe098bce

Add means to replace the main audio model
author Chris Cannam
date Mon, 02 Jul 2012 12:46:25 +0100 (2012-07-02)
parents eb5f79d6eaa9
children 451d3c087112
files main/MainWindow.cpp main/MainWindow.h
diffstat 2 files changed, 25 insertions(+), 0 deletions(-) [+]
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;
--- a/main/MainWindow.h	Sat Jun 30 15:05:29 2012 +0100
+++ b/main/MainWindow.h	Mon Jul 02 12:46:25 2012 +0100
@@ -85,6 +85,7 @@
     virtual void openSession();
     virtual void importAudio();
     virtual void importMoreAudio();
+    virtual void replaceMainAudio();
     virtual void openSomething();
     virtual void openLocation();
     virtual void openRecentFile();