comparison framework/MainWindowBase.cpp @ 521:169aa5203faa tony-2.0-integration

Merge latest SV 3.0 branch code
author Chris Cannam
date Fri, 19 Aug 2016 15:58:57 +0100
parents b926f08909b8
children 3ab6a5f7aca8
comparison
equal deleted inserted replaced
510:83c60632bac0 521:169aa5203faa
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) {
194 settings.beginGroup("Preferences"); 195 settings.beginGroup("Preferences");
195 viewFontSize = settings.value("view-font-size", viewFontSize).toInt(); 196 viewFontSize = settings.value("view-font-size", viewFontSize).toInt();
196 settings.setValue("view-font-size", viewFontSize); 197 settings.setValue("view-font-size", viewFontSize);
197 settings.endGroup(); 198 settings.endGroup();
198 199
200 #ifdef NOT_DEFINED // This no longer works correctly on any platform AFAICS
199 Preferences::BackgroundMode mode = 201 Preferences::BackgroundMode mode =
200 Preferences::getInstance()->getBackgroundMode(); 202 Preferences::getInstance()->getBackgroundMode();
201 m_initialDarkBackground = m_viewManager->getGlobalDarkBackground(); 203 m_initialDarkBackground = m_viewManager->getGlobalDarkBackground();
202 if (mode != Preferences::BackgroundFromTheme) { 204 if (mode != Preferences::BackgroundFromTheme) {
203 m_viewManager->setGlobalDarkBackground 205 m_viewManager->setGlobalDarkBackground
204 (mode == Preferences::DarkBackground); 206 (mode == Preferences::DarkBackground);
205 } 207 }
208 #endif
206 209
207 m_paneStack = new PaneStack(0, m_viewManager); 210 m_paneStack = new PaneStack(0, m_viewManager);
208 connect(m_paneStack, SIGNAL(currentPaneChanged(Pane *)), 211 connect(m_paneStack, SIGNAL(currentPaneChanged(Pane *)),
209 this, SLOT(currentPaneChanged(Pane *))); 212 this, SLOT(currentPaneChanged(Pane *)));
210 connect(m_paneStack, SIGNAL(currentLayerChanged(Pane *, Layer *)), 213 connect(m_paneStack, SIGNAL(currentLayerChanged(Pane *, Layer *)),
330 if (menu) finaliseMenu(menu); 333 if (menu) finaliseMenu(menu);
331 } 334 }
332 } 335 }
333 336
334 void 337 void
335 MainWindowBase::finaliseMenu(QMenu * 338 MainWindowBase::finaliseMenu(QMenu *menu)
336 #ifdef Q_OS_MAC 339 {
337 menu 340 foreach (QAction *a, menu->actions()) {
338 #endif 341 a->setIconVisibleInMenu(m_iconsVisibleInMenus);
339 ) 342 }
340 { 343
341 #ifdef Q_OS_MAC 344 #ifdef Q_OS_MAC
342 // See https://bugreports.qt-project.org/browse/QTBUG-38256 and 345 // See https://bugreports.qt-project.org/browse/QTBUG-38256 and
343 // our issue #890 http://code.soundsoftware.ac.uk/issues/890 -- 346 // our issue #890 http://code.soundsoftware.ac.uk/issues/890 --
344 // single-key shortcuts that are associated only with a menu 347 // single-key shortcuts that are associated only with a menu
345 // 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
1783 1786
1784 return FileOpenSucceeded; 1787 return FileOpenSucceeded;
1785 } 1788 }
1786 1789
1787 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
1788 MainWindowBase::openSessionPath(QString fileOrUrl) 1836 MainWindowBase::openSessionPath(QString fileOrUrl)
1789 { 1837 {
1790 ProgressDialog dialog(tr("Opening session..."), true, 2000, this); 1838 ProgressDialog dialog(tr("Opening session..."), true, 2000, this);
1791 connect(&dialog, SIGNAL(showing()), this, SIGNAL(hideSplash())); 1839 connect(&dialog, SIGNAL(showing()), this, SIGNAL(hideSplash()));
1792 return openSession(FileSource(fileOrUrl, &dialog)); 1840 return openSession(FileSource(fileOrUrl, &dialog));
2269 this, SLOT(modelRegenerationWarning(QString, QString, QString))); 2317 this, SLOT(modelRegenerationWarning(QString, QString, QString)));
2270 connect(m_document, SIGNAL(modelGenerationFailed(QString, QString)), 2318 connect(m_document, SIGNAL(modelGenerationFailed(QString, QString)),
2271 this, SLOT(modelGenerationFailed(QString, QString))); 2319 this, SLOT(modelGenerationFailed(QString, QString)));
2272 connect(m_document, SIGNAL(modelRegenerationWarning(QString, QString, QString)), 2320 connect(m_document, SIGNAL(modelRegenerationWarning(QString, QString, QString)),
2273 this, SLOT(modelRegenerationWarning(QString, QString, QString))); 2321 this, SLOT(modelRegenerationWarning(QString, QString, QString)));
2274 connect(m_document, SIGNAL(alignmentFailed(QString, QString)), 2322 connect(m_document, SIGNAL(alignmentComplete(AlignmentModel *)),
2275 this, SLOT(alignmentFailed(QString, QString))); 2323 this, SLOT(alignmentComplete(AlignmentModel *)));
2324 connect(m_document, SIGNAL(alignmentFailed(QString)),
2325 this, SLOT(alignmentFailed(QString)));
2276 2326
2277 emit replacedDocument(); 2327 emit replacedDocument();
2278 } 2328 }
2279 2329
2280 bool 2330 bool
2654 } 2704 }
2655 2705
2656 void 2706 void
2657 MainWindowBase::play() 2707 MainWindowBase::play()
2658 { 2708 {
2659 if (m_recordTarget->isRecording() || m_playSource->isPlaying()) { 2709 if ((m_recordTarget && m_recordTarget->isRecording()) ||
2710 (m_playSource && m_playSource->isPlaying())) {
2660 stop(); 2711 stop();
2661 QAction *action = qobject_cast<QAction *>(sender()); 2712 QAction *action = qobject_cast<QAction *>(sender());
2662 if (action) action->setChecked(false); 2713 if (action) action->setChecked(false);
2663 } else { 2714 } else {
2664 if (m_audioIO) m_audioIO->resume(); 2715 if (m_audioIO) m_audioIO->resume();
3033 } 3084 }
3034 3085
3035 void 3086 void
3036 MainWindowBase::stop() 3087 MainWindowBase::stop()
3037 { 3088 {
3038 if (m_recordTarget->isRecording()) { 3089 if (m_recordTarget &&
3090 m_recordTarget->isRecording()) {
3039 m_recordTarget->stopRecording(); 3091 m_recordTarget->stopRecording();
3040 } 3092 }
3041 3093
3094 if (!m_playSource) return;
3095
3042 m_playSource->stop(); 3096 m_playSource->stop();
3043 3097
3044 if (m_audioIO) m_audioIO->suspend(); 3098 if (m_audioIO) m_audioIO->suspend();
3045 else if (m_playTarget) m_playTarget->suspend(); 3099 else if (m_playTarget) m_playTarget->suspend();
3046 3100
3574 3628
3575 updateMenuStates(); 3629 updateMenuStates();
3576 } 3630 }
3577 3631
3578 void 3632 void
3633 MainWindowBase::alignmentComplete(AlignmentModel *model)
3634 {
3635 cerr << "MainWindowBase::alignmentComplete(" << model << ")" << endl;
3636 }
3637
3638 void
3579 MainWindowBase::pollOSC() 3639 MainWindowBase::pollOSC()
3580 { 3640 {
3581 if (!m_oscQueue || m_oscQueue->isEmpty()) return; 3641 if (!m_oscQueue || m_oscQueue->isEmpty()) return;
3582 SVDEBUG << "MainWindowBase::pollOSC: have " << m_oscQueue->getMessagesAvailable() << " messages" << endl; 3642 SVDEBUG << "MainWindowBase::pollOSC: have " << m_oscQueue->getMessagesAvailable() << " messages" << endl;
3583 3643