comparison framework/MainWindowBase.cpp @ 520:c3648c667a0b 3.0-integration

Merge from branch "alignment-simple"
author Chris Cannam
date Thu, 21 Apr 2016 15:06:43 +0100
parents b926f08909b8
children 3ab6a5f7aca8
comparison
equal deleted inserted replaced
518:f7ec9e410108 520:c3648c667a0b
155 m_lastPlayStatusSec(0), 155 m_lastPlayStatusSec(0),
156 m_initialDarkBackground(false), 156 m_initialDarkBackground(false),
157 m_defaultFfwdRwdStep(2, 0), 157 m_defaultFfwdRwdStep(2, 0),
158 m_audioRecordMode(RecordCreateAdditionalModel), 158 m_audioRecordMode(RecordCreateAdditionalModel),
159 m_statusLabel(0), 159 m_statusLabel(0),
160 m_iconsVisibleInMenus(true),
160 m_menuShortcutMapper(0) 161 m_menuShortcutMapper(0)
161 { 162 {
162 Profiler profiler("MainWindowBase::MainWindowBase"); 163 Profiler profiler("MainWindowBase::MainWindowBase");
163 164
164 if (options & WithAudioInput) { 165 if (options & WithAudioInput) {
332 if (menu) finaliseMenu(menu); 333 if (menu) finaliseMenu(menu);
333 } 334 }
334 } 335 }
335 336
336 void 337 void
337 MainWindowBase::finaliseMenu(QMenu * 338 MainWindowBase::finaliseMenu(QMenu *menu)
338 #ifdef Q_OS_MAC 339 {
339 menu 340 foreach (QAction *a, menu->actions()) {
340 #endif 341 a->setIconVisibleInMenu(m_iconsVisibleInMenus);
341 ) 342 }
342 { 343
343 #ifdef Q_OS_MAC 344 #ifdef Q_OS_MAC
344 // See https://bugreports.qt-project.org/browse/QTBUG-38256 and 345 // See https://bugreports.qt-project.org/browse/QTBUG-38256 and
345 // our issue #890 http://code.soundsoftware.ac.uk/issues/890 -- 346 // our issue #890 http://code.soundsoftware.ac.uk/issues/890 --
346 // single-key shortcuts that are associated only with a menu 347 // single-key shortcuts that are associated only with a menu
347 // action (and not with a toolbar button) do not work with Qt 5.x 348 // action (and not with a toolbar button) do not work with Qt 5.x
1785 1786
1786 return FileOpenSucceeded; 1787 return FileOpenSucceeded;
1787 } 1788 }
1788 1789
1789 MainWindowBase::FileOpenStatus 1790 MainWindowBase::FileOpenStatus
1791 MainWindowBase::openDirOfAudio(QString dirPath)
1792 {
1793 QDir dir(dirPath);
1794 QStringList files = dir.entryList(QDir::Files | QDir::Readable);
1795 files.sort();
1796
1797 FileOpenStatus status = FileOpenFailed;
1798 bool first = true;
1799 bool cancelled = false;
1800
1801 foreach (QString file, files) {
1802
1803 FileSource source(dir.filePath(file));
1804 if (!source.isAvailable()) {
1805 continue;
1806 }
1807
1808 if (AudioFileReaderFactory::getKnownExtensions().contains
1809 (source.getExtension().toLower())) {
1810
1811 AudioFileOpenMode mode = CreateAdditionalModel;
1812 if (first) mode = ReplaceSession;
1813
1814 switch (openAudio(source, mode)) {
1815 case FileOpenSucceeded:
1816 status = FileOpenSucceeded;
1817 first = false;
1818 break;
1819 case FileOpenFailed:
1820 break;
1821 case FileOpenCancelled:
1822 cancelled = true;
1823 break;
1824 case FileOpenWrongMode:
1825 break;
1826 }
1827 }
1828
1829 if (cancelled) break;
1830 }
1831
1832 return status;
1833 }
1834
1835 MainWindowBase::FileOpenStatus
1790 MainWindowBase::openSessionPath(QString fileOrUrl) 1836 MainWindowBase::openSessionPath(QString fileOrUrl)
1791 { 1837 {
1792 ProgressDialog dialog(tr("Opening session..."), true, 2000, this); 1838 ProgressDialog dialog(tr("Opening session..."), true, 2000, this);
1793 connect(&dialog, SIGNAL(showing()), this, SIGNAL(hideSplash())); 1839 connect(&dialog, SIGNAL(showing()), this, SIGNAL(hideSplash()));
1794 return openSession(FileSource(fileOrUrl, &dialog)); 1840 return openSession(FileSource(fileOrUrl, &dialog));
2271 this, SLOT(modelRegenerationWarning(QString, QString, QString))); 2317 this, SLOT(modelRegenerationWarning(QString, QString, QString)));
2272 connect(m_document, SIGNAL(modelGenerationFailed(QString, QString)), 2318 connect(m_document, SIGNAL(modelGenerationFailed(QString, QString)),
2273 this, SLOT(modelGenerationFailed(QString, QString))); 2319 this, SLOT(modelGenerationFailed(QString, QString)));
2274 connect(m_document, SIGNAL(modelRegenerationWarning(QString, QString, QString)), 2320 connect(m_document, SIGNAL(modelRegenerationWarning(QString, QString, QString)),
2275 this, SLOT(modelRegenerationWarning(QString, QString, QString))); 2321 this, SLOT(modelRegenerationWarning(QString, QString, QString)));
2276 connect(m_document, SIGNAL(alignmentFailed(QString, QString)), 2322 connect(m_document, SIGNAL(alignmentComplete(AlignmentModel *)),
2277 this, SLOT(alignmentFailed(QString, QString))); 2323 this, SLOT(alignmentComplete(AlignmentModel *)));
2324 connect(m_document, SIGNAL(alignmentFailed(QString)),
2325 this, SLOT(alignmentFailed(QString)));
2278 2326
2279 emit replacedDocument(); 2327 emit replacedDocument();
2280 } 2328 }
2281 2329
2282 bool 2330 bool
2656 } 2704 }
2657 2705
2658 void 2706 void
2659 MainWindowBase::play() 2707 MainWindowBase::play()
2660 { 2708 {
2661 if (m_recordTarget->isRecording() || m_playSource->isPlaying()) { 2709 if ((m_recordTarget && m_recordTarget->isRecording()) ||
2710 (m_playSource && m_playSource->isPlaying())) {
2662 stop(); 2711 stop();
2663 QAction *action = qobject_cast<QAction *>(sender()); 2712 QAction *action = qobject_cast<QAction *>(sender());
2664 if (action) action->setChecked(false); 2713 if (action) action->setChecked(false);
2665 } else { 2714 } else {
2666 if (m_audioIO) m_audioIO->resume(); 2715 if (m_audioIO) m_audioIO->resume();
3035 } 3084 }
3036 3085
3037 void 3086 void
3038 MainWindowBase::stop() 3087 MainWindowBase::stop()
3039 { 3088 {
3040 if (m_recordTarget->isRecording()) { 3089 if (m_recordTarget &&
3090 m_recordTarget->isRecording()) {
3041 m_recordTarget->stopRecording(); 3091 m_recordTarget->stopRecording();
3042 } 3092 }
3043 3093
3094 if (!m_playSource) return;
3095
3044 m_playSource->stop(); 3096 m_playSource->stop();
3045 3097
3046 if (m_audioIO) m_audioIO->suspend(); 3098 if (m_audioIO) m_audioIO->suspend();
3047 else if (m_playTarget) m_playTarget->suspend(); 3099 else if (m_playTarget) m_playTarget->suspend();
3048 3100
3576 3628
3577 updateMenuStates(); 3629 updateMenuStates();
3578 } 3630 }
3579 3631
3580 void 3632 void
3633 MainWindowBase::alignmentComplete(AlignmentModel *model)
3634 {
3635 cerr << "MainWindowBase::alignmentComplete(" << model << ")" << endl;
3636 }
3637
3638 void
3581 MainWindowBase::pollOSC() 3639 MainWindowBase::pollOSC()
3582 { 3640 {
3583 if (!m_oscQueue || m_oscQueue->isEmpty()) return; 3641 if (!m_oscQueue || m_oscQueue->isEmpty()) return;
3584 SVDEBUG << "MainWindowBase::pollOSC: have " << m_oscQueue->getMessagesAvailable() << " messages" << endl; 3642 SVDEBUG << "MainWindowBase::pollOSC: have " << m_oscQueue->getMessagesAvailable() << " messages" << endl;
3585 3643