# HG changeset patch # User Chris Cannam # Date 1341229585 -3600 # Node ID 26ebbe098bce4943d917c35336e68c5e24511331 # Parent eb5f79d6eaa9d03ad8debc4e915e3e9ca97e94d0 Add means to replace the main audio model diff -r eb5f79d6eaa9 -r 26ebbe098bce main/MainWindow.cpp --- 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("File open failed

Audio file \"%1\" could not be opened").arg(path)); + } + } +} + +void MainWindow::exportAudio() { if (!getMainModel()) return; diff -r eb5f79d6eaa9 -r 26ebbe098bce main/MainWindow.h --- 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();