comparison src/MainWindow.cpp @ 310:1e9c4549107a

added Save In Audio Path option for saving
author matthiasm
date Thu, 12 Jun 2014 21:07:57 +0100
parents 585c045129c9
children 4cf65a721a77
comparison
equal deleted inserted replaced
309:585c045129c9 310:1e9c4549107a
473 icon.addPixmap(il.loadPixmap("filesaveas-22")); 473 icon.addPixmap(il.loadPixmap("filesaveas-22"));
474 action = new QAction(icon, tr("Save Session &As..."), this); 474 action = new QAction(icon, tr("Save Session &As..."), this);
475 action->setShortcut(tr("Ctrl+Shift+S")); 475 action->setShortcut(tr("Ctrl+Shift+S"));
476 action->setStatusTip(tr("Save the current session into a new %1 session file").arg(QApplication::applicationName())); 476 action->setStatusTip(tr("Save the current session into a new %1 session file").arg(QApplication::applicationName()));
477 connect(action, SIGNAL(triggered()), this, SLOT(saveSessionAs())); 477 connect(action, SIGNAL(triggered()), this, SLOT(saveSessionAs()));
478 menu->addAction(action);
479 toolbar->addAction(action);
480
481 icon = il.load("filesaveas");
482 icon.addPixmap(il.loadPixmap("filesaveas-22"));
483 action = new QAction(icon, tr("Save Session In &Audio Path"), this);
484 action->setShortcut(tr("Ctrl+Alt+S"));
485 action->setStatusTip(tr("Save the current session into a %1 session file with the same path and filename but .ton extension.").arg(QApplication::applicationName()));
486 connect(action, SIGNAL(triggered()), this, SLOT(saveSessionInAudioPath()));
478 menu->addAction(action); 487 menu->addAction(action);
479 toolbar->addAction(action); 488 toolbar->addAction(action);
480 489
481 menu->addSeparator(); 490 menu->addSeparator();
482 491
1791 saveSessionAs(); 1800 saveSessionAs();
1792 } 1801 }
1793 } 1802 }
1794 1803
1795 void 1804 void
1805 MainWindow::saveSessionInAudioPath()
1806 {
1807 // We do not want to save mid-analysis regions -- that would cause
1808 // confusion on reloading
1809 m_analyser->clearReAnalysis();
1810 clearSelection();
1811
1812 QString filepath = QFileInfo(m_audioFile).absoluteDir().canonicalPath();
1813 QString basename = QFileInfo(m_audioFile).completeBaseName();
1814
1815 QString path = QDir(filepath).filePath(basename + ".ton");
1816
1817 cerr << path << endl;
1818
1819 if (!saveSessionFile(path)) {
1820 QMessageBox::critical(this, tr("Failed to save file"),
1821 tr("Session file \"%1\" could not be saved.").arg(path));
1822 } else {
1823 setWindowTitle(tr("%1: %2")
1824 .arg(QApplication::applicationName())
1825 .arg(QFileInfo(path).fileName()));
1826 m_sessionFile = path;
1827 CommandHistory::getInstance()->documentSaved();
1828 documentRestored();
1829 m_recentFiles.addFile(path);
1830 }
1831 }
1832
1833 void
1796 MainWindow::saveSessionAs() 1834 MainWindow::saveSessionAs()
1797 { 1835 {
1798 // We do not want to save mid-analysis regions -- that would cause 1836 // We do not want to save mid-analysis regions -- that would cause
1799 // confusion on reloading 1837 // confusion on reloading
1800 m_analyser->clearReAnalysis(); 1838 m_analyser->clearReAnalysis();