Mercurial > hg > sonic-visualiser
comparison main/MainWindow.cpp @ 2181:b0e8217719ed
Merge from branch fix-static-analysis
author | Chris Cannam |
---|---|
date | Wed, 09 Jan 2019 15:27:32 +0000 |
parents | 12ff1b9ceeea 0b15f3b16776 |
children | a4dde0f408e4 |
comparison
equal
deleted
inserted
replaced
2180:52eda31c7b33 | 2181:b0e8217719ed |
---|---|
137 using std::set; | 137 using std::set; |
138 | 138 |
139 | 139 |
140 MainWindow::MainWindow(SoundOptions options, bool withOSCSupport) : | 140 MainWindow::MainWindow(SoundOptions options, bool withOSCSupport) : |
141 MainWindowBase(options), | 141 MainWindowBase(options), |
142 m_overview(0), | 142 m_overview(nullptr), |
143 m_mainMenusCreated(false), | 143 m_mainMenusCreated(false), |
144 m_paneMenu(0), | 144 m_paneMenu(nullptr), |
145 m_layerMenu(0), | 145 m_layerMenu(nullptr), |
146 m_transformsMenu(0), | 146 m_transformsMenu(nullptr), |
147 m_playbackMenu(0), | 147 m_playbackMenu(nullptr), |
148 m_existingLayersMenu(0), | 148 m_existingLayersMenu(nullptr), |
149 m_sliceMenu(0), | 149 m_sliceMenu(nullptr), |
150 m_recentFilesMenu(0), | 150 m_recentFilesMenu(nullptr), |
151 m_recentTransformsMenu(0), | 151 m_recentTransformsMenu(nullptr), |
152 m_templatesMenu(0), | 152 m_templatesMenu(nullptr), |
153 m_rightButtonMenu(0), | 153 m_rightButtonMenu(nullptr), |
154 m_rightButtonLayerMenu(0), | 154 m_rightButtonLayerMenu(nullptr), |
155 m_rightButtonTransformsMenu(0), | 155 m_rightButtonTransformsMenu(nullptr), |
156 m_rightButtonPlaybackMenu(0), | 156 m_rightButtonPlaybackMenu(nullptr), |
157 m_soloAction(0), | 157 m_soloAction(nullptr), |
158 m_rwdStartAction(0), | 158 m_rwdStartAction(nullptr), |
159 m_rwdSimilarAction(0), | 159 m_rwdSimilarAction(nullptr), |
160 m_rwdAction(0), | 160 m_rwdAction(nullptr), |
161 m_ffwdAction(0), | 161 m_ffwdAction(nullptr), |
162 m_ffwdSimilarAction(0), | 162 m_ffwdSimilarAction(nullptr), |
163 m_ffwdEndAction(0), | 163 m_ffwdEndAction(nullptr), |
164 m_playAction(0), | 164 m_playAction(nullptr), |
165 m_recordAction(0), | 165 m_recordAction(nullptr), |
166 m_playSelectionAction(0), | 166 m_playSelectionAction(nullptr), |
167 m_playLoopAction(0), | 167 m_playLoopAction(nullptr), |
168 m_soloModified(false), | 168 m_soloModified(false), |
169 m_prevSolo(false), | 169 m_prevSolo(false), |
170 m_playControlsSpacer(0), | 170 m_playControlsSpacer(nullptr), |
171 m_playControlsWidth(0), | 171 m_playControlsWidth(0), |
172 m_preferencesDialog(0), | 172 m_preferencesDialog(nullptr), |
173 m_layerTreeDialog(0), | 173 m_layerTreeDialog(nullptr), |
174 m_activityLog(new ActivityLog()), | 174 m_activityLog(new ActivityLog()), |
175 m_unitConverter(new UnitConverter()), | 175 m_unitConverter(new UnitConverter()), |
176 m_keyReference(new KeyReference()), | 176 m_keyReference(new KeyReference()), |
177 m_templateWatcher(0) | 177 m_templateWatcher(nullptr) |
178 { | 178 { |
179 Profiler profiler("MainWindow::MainWindow"); | 179 Profiler profiler("MainWindow::MainWindow"); |
180 | 180 |
181 SVDEBUG << "MainWindow: " << getReleaseText() << endl; | 181 SVDEBUG << "MainWindow: " << getReleaseText() << endl; |
182 | 182 |
348 m_versionTester = new VersionTester | 348 m_versionTester = new VersionTester |
349 ("sonicvisualiser.org", "latest-version.txt", SV_VERSION); | 349 ("sonicvisualiser.org", "latest-version.txt", SV_VERSION); |
350 connect(m_versionTester, SIGNAL(newerVersionAvailable(QString)), | 350 connect(m_versionTester, SIGNAL(newerVersionAvailable(QString)), |
351 this, SLOT(newerVersionAvailable(QString))); | 351 this, SLOT(newerVersionAvailable(QString))); |
352 } else { | 352 } else { |
353 m_surveyer = 0; | 353 m_surveyer = nullptr; |
354 m_versionTester = 0; | 354 m_versionTester = nullptr; |
355 } | 355 } |
356 | 356 |
357 /* | 357 /* |
358 QTimer::singleShot(500, this, SLOT(betaReleaseWarning())); | 358 QTimer::singleShot(500, this, SLOT(betaReleaseWarning())); |
359 */ | 359 */ |
445 // The wheels seem to end up in the wrong place in full-screen mode | 445 // The wheels seem to end up in the wrong place in full-screen mode |
446 toggleZoomWheels(); | 446 toggleZoomWheels(); |
447 } | 447 } |
448 | 448 |
449 QWidget *ps = m_mainScroll->takeWidget(); | 449 QWidget *ps = m_mainScroll->takeWidget(); |
450 ps->setParent(0); | 450 ps->setParent(nullptr); |
451 | 451 |
452 QShortcut *sc; | 452 QShortcut *sc; |
453 | 453 |
454 sc = new QShortcut(QKeySequence("Esc"), ps); | 454 sc = new QShortcut(QKeySequence("Esc"), ps); |
455 connect(sc, SIGNAL(activated()), this, SLOT(endFullScreen())); | 455 connect(sc, SIGNAL(activated()), this, SLOT(endFullScreen())); |
922 { | 922 { |
923 if (m_mainMenusCreated) return; | 923 if (m_mainMenusCreated) return; |
924 | 924 |
925 IconLoader il; | 925 IconLoader il; |
926 | 926 |
927 QAction *action = 0; | 927 QAction *action = nullptr; |
928 | 928 |
929 m_keyReference->setCategory(tr("Panning and Navigation")); | 929 m_keyReference->setCategory(tr("Panning and Navigation")); |
930 | 930 |
931 QMenu *menu = menuBar()->addMenu(tr("&View")); | 931 QMenu *menu = menuBar()->addMenu(tr("&View")); |
932 menu->setTearOffEnabled(true); | 932 menu->setTearOffEnabled(true); |
1304 for (int menuType = paneMenuType; menuType <= layerMenuType; ++menuType) { | 1304 for (int menuType = paneMenuType; menuType <= layerMenuType; ++menuType) { |
1305 | 1305 |
1306 if (menuType == paneMenuType) menu = m_paneMenu; | 1306 if (menuType == paneMenuType) menu = m_paneMenu; |
1307 else menu = m_layerMenu; | 1307 else menu = m_layerMenu; |
1308 | 1308 |
1309 QMenu *submenu = 0; | 1309 QMenu *submenu = nullptr; |
1310 | 1310 |
1311 QIcon icon; | 1311 QIcon icon; |
1312 QString mainText, tipText, channelText; | 1312 QString mainText, tipText, channelText; |
1313 LayerFactory::LayerType type = backgroundTypes[i]; | 1313 LayerFactory::LayerType type = backgroundTypes[i]; |
1314 bool mono = true; | 1314 bool mono = true; |
1501 connect(action, SIGNAL(triggered()), | 1501 connect(action, SIGNAL(triggered()), |
1502 this, SLOT(addLayer())); | 1502 this, SLOT(addLayer())); |
1503 connect(this, SIGNAL(canAddLayer(bool)), | 1503 connect(this, SIGNAL(canAddLayer(bool)), |
1504 action, SLOT(setEnabled(bool))); | 1504 action, SLOT(setEnabled(bool))); |
1505 m_layerActions.push_back | 1505 m_layerActions.push_back |
1506 ({ action, LayerConfiguration(type, 0, 0) }); | 1506 ({ action, LayerConfiguration(type, nullptr, 0) }); |
1507 m_rightButtonLayerMenu->addAction(action); | 1507 m_rightButtonLayerMenu->addAction(action); |
1508 } | 1508 } |
1509 } | 1509 } |
1510 } | 1510 } |
1511 } | 1511 } |
1968 connect(defaultAction, SIGNAL(triggered()), this, SLOT(applyTemplate())); | 1968 connect(defaultAction, SIGNAL(triggered()), this, SLOT(applyTemplate())); |
1969 m_templatesMenu->addAction(defaultAction); | 1969 m_templatesMenu->addAction(defaultAction); |
1970 | 1970 |
1971 m_templatesMenu->addSeparator(); | 1971 m_templatesMenu->addSeparator(); |
1972 | 1972 |
1973 QAction *action = 0; | 1973 QAction *action = nullptr; |
1974 | 1974 |
1975 QStringList templates = ResourceFinder().getResourceFiles("templates", "svt"); | 1975 QStringList templates = ResourceFinder().getResourceFiles("templates", "svt"); |
1976 | 1976 |
1977 bool havePersonal = false; | 1977 bool havePersonal = false; |
1978 | 1978 |
2232 connect(m_viewManager, SIGNAL(playSoloModeChanged(bool)), | 2232 connect(m_viewManager, SIGNAL(playSoloModeChanged(bool)), |
2233 m_soloAction, SLOT(setChecked(bool))); | 2233 m_soloAction, SLOT(setChecked(bool))); |
2234 connect(m_soloAction, SIGNAL(triggered()), this, SLOT(playSoloToggled())); | 2234 connect(m_soloAction, SIGNAL(triggered()), this, SLOT(playSoloToggled())); |
2235 connect(this, SIGNAL(canChangeSolo(bool)), m_soloAction, SLOT(setEnabled(bool))); | 2235 connect(this, SIGNAL(canChangeSolo(bool)), m_soloAction, SLOT(setEnabled(bool))); |
2236 | 2236 |
2237 QAction *alAction = 0; | 2237 QAction *alAction = nullptr; |
2238 if (Document::canAlign()) { | 2238 if (Document::canAlign()) { |
2239 alAction = toolbar->addAction(il.load("align"), | 2239 alAction = toolbar->addAction(il.load("align"), |
2240 tr("Align File Timelines")); | 2240 tr("Align File Timelines")); |
2241 alAction->setCheckable(true); | 2241 alAction->setCheckable(true); |
2242 alAction->setChecked(m_viewManager->getAlignMode()); | 2242 alAction->setChecked(m_viewManager->getAlignMode()); |
2481 void | 2481 void |
2482 MainWindow::updateMenuStates() | 2482 MainWindow::updateMenuStates() |
2483 { | 2483 { |
2484 MainWindowBase::updateMenuStates(); | 2484 MainWindowBase::updateMenuStates(); |
2485 | 2485 |
2486 Pane *currentPane = 0; | 2486 Pane *currentPane = nullptr; |
2487 Layer *currentLayer = 0; | 2487 Layer *currentLayer = nullptr; |
2488 | 2488 |
2489 if (m_paneStack) currentPane = m_paneStack->getCurrentPane(); | 2489 if (m_paneStack) currentPane = m_paneStack->getCurrentPane(); |
2490 if (currentPane) currentLayer = currentPane->getSelectedLayer(); | 2490 if (currentPane) currentLayer = currentPane->getSelectedLayer(); |
2491 | 2491 |
2492 bool haveCurrentPane = | 2492 bool haveCurrentPane = |
2493 (currentPane != 0); | 2493 (currentPane != nullptr); |
2494 bool haveCurrentLayer = | 2494 bool haveCurrentLayer = |
2495 (haveCurrentPane && | 2495 (haveCurrentPane && |
2496 (currentLayer != 0)); | 2496 (currentLayer != nullptr)); |
2497 bool havePlayTarget = | 2497 bool havePlayTarget = |
2498 (m_playTarget != 0 || m_audioIO != 0); | 2498 (m_playTarget != nullptr || m_audioIO != nullptr); |
2499 bool haveSelection = | 2499 bool haveSelection = |
2500 (m_viewManager && | 2500 (m_viewManager && |
2501 !m_viewManager->getSelections().empty()); | 2501 !m_viewManager->getSelections().empty()); |
2502 bool haveCurrentEditableLayer = | 2502 bool haveCurrentEditableLayer = |
2503 (haveCurrentLayer && | 2503 (haveCurrentLayer && |
2761 MultiSelection ms = m_viewManager->getSelection(); | 2761 MultiSelection ms = m_viewManager->getSelection(); |
2762 MultiSelection::SelectionList selections = m_viewManager->getSelections(); | 2762 MultiSelection::SelectionList selections = m_viewManager->getSelections(); |
2763 | 2763 |
2764 bool multiple = false; | 2764 bool multiple = false; |
2765 | 2765 |
2766 MultiSelection *selectionToWrite = 0; | 2766 MultiSelection *selectionToWrite = nullptr; |
2767 | 2767 |
2768 if (selections.size() == 1) { | 2768 if (selections.size() == 1) { |
2769 | 2769 |
2770 QStringList items; | 2770 QStringList items; |
2771 items << tr("Export the selected region only") | 2771 items << tr("Export the selected region only") |
3144 | 3144 |
3145 if (!ok || item.isEmpty()) return; | 3145 if (!ok || item.isEmpty()) return; |
3146 | 3146 |
3147 settings.setValue("lastimageexportregion", deflt); | 3147 settings.setValue("lastimageexportregion", deflt); |
3148 | 3148 |
3149 QImage *image = 0; | 3149 QImage *image = nullptr; |
3150 | 3150 |
3151 if (item == items[0]) { | 3151 if (item == items[0]) { |
3152 image = pane->renderToNewImage(); | 3152 image = pane->renderToNewImage(); |
3153 } else if (item == items[1]) { | 3153 } else if (item == items[1]) { |
3154 image = pane->renderPartToNewImage(pane->getFirstVisibleFrame(), | 3154 image = pane->renderPartToNewImage(pane->getFirstVisibleFrame(), |
3325 m_activityLog->hide(); | 3325 m_activityLog->hide(); |
3326 m_unitConverter->hide(); | 3326 m_unitConverter->hide(); |
3327 m_keyReference->hide(); | 3327 m_keyReference->hide(); |
3328 | 3328 |
3329 delete m_document; | 3329 delete m_document; |
3330 m_document = 0; | 3330 m_document = nullptr; |
3331 m_viewManager->clearSelections(); | 3331 m_viewManager->clearSelections(); |
3332 m_timeRulerLayer = 0; // document owned this | 3332 m_timeRulerLayer = nullptr; // document owned this |
3333 | 3333 |
3334 m_sessionFile = ""; | 3334 m_sessionFile = ""; |
3335 setWindowTitle(QApplication::applicationName()); | 3335 setWindowTitle(QApplication::applicationName()); |
3336 | 3336 |
3337 CommandHistory::getInstance()->clear(); | 3337 CommandHistory::getInstance()->clear(); |
3899 } | 3899 } |
3900 | 3900 |
3901 Layer *newLayer = m_document->createLayer(configuration.layer); | 3901 Layer *newLayer = m_document->createLayer(configuration.layer); |
3902 | 3902 |
3903 Model *suggestedModel = configuration.sourceModel; | 3903 Model *suggestedModel = configuration.sourceModel; |
3904 Model *model = 0; | 3904 Model *model = nullptr; |
3905 | 3905 |
3906 if (suggestedModel) { | 3906 if (suggestedModel) { |
3907 | 3907 |
3908 // check its validity | 3908 // check its validity |
3909 std::vector<Model *> inputModels = m_document->getTransformInputModels(); | 3909 std::vector<Model *> inputModels = m_document->getTransformInputModels(); |
4021 LayerFactory::LayerType type = i->second.layer; | 4021 LayerFactory::LayerType type = i->second.layer; |
4022 | 4022 |
4023 LayerFactory::LayerTypeSet emptyTypes = | 4023 LayerFactory::LayerTypeSet emptyTypes = |
4024 LayerFactory::getInstance()->getValidEmptyLayerTypes(); | 4024 LayerFactory::getInstance()->getValidEmptyLayerTypes(); |
4025 | 4025 |
4026 Layer *newLayer = 0; | 4026 Layer *newLayer = nullptr; |
4027 | 4027 |
4028 if (emptyTypes.find(type) != emptyTypes.end()) { | 4028 if (emptyTypes.find(type) != emptyTypes.end()) { |
4029 | 4029 |
4030 newLayer = m_document->createEmptyLayer(type); | 4030 newLayer = m_document->createEmptyLayer(type); |
4031 if (newLayer) { | 4031 if (newLayer) { |
4130 } | 4130 } |
4131 | 4131 |
4132 std::vector<Model *> candidateInputModels = | 4132 std::vector<Model *> candidateInputModels = |
4133 m_document->getTransformInputModels(); | 4133 m_document->getTransformInputModels(); |
4134 | 4134 |
4135 Model *defaultInputModel = 0; | 4135 Model *defaultInputModel = nullptr; |
4136 | 4136 |
4137 for (int j = 0; j < pane->getLayerCount(); ++j) { | 4137 for (int j = 0; j < pane->getLayerCount(); ++j) { |
4138 | 4138 |
4139 Layer *layer = pane->getLayer(j); | 4139 Layer *layer = pane->getLayer(j); |
4140 if (!layer) continue; | 4140 if (!layer) continue; |
4154 } | 4154 } |
4155 | 4155 |
4156 if (defaultInputModel) break; | 4156 if (defaultInputModel) break; |
4157 } | 4157 } |
4158 | 4158 |
4159 AggregateWaveModel *aggregate = 0; | 4159 AggregateWaveModel *aggregate = nullptr; |
4160 | 4160 |
4161 if (candidateInputModels.size() > 1) { | 4161 if (candidateInputModels.size() > 1) { |
4162 // Add an aggregate model as another option | 4162 // Add an aggregate model as another option |
4163 AggregateWaveModel::ChannelSpecList sl; | 4163 AggregateWaveModel::ChannelSpecList sl; |
4164 foreach (Model *m, candidateInputModels) { | 4164 foreach (Model *m, candidateInputModels) { |
4255 return; | 4255 return; |
4256 } | 4256 } |
4257 TransformId transform = finder->getTransform(); | 4257 TransformId transform = finder->getTransform(); |
4258 delete finder; | 4258 delete finder; |
4259 | 4259 |
4260 if (getMainModel() != 0 && m_paneStack->getCurrentPane() != 0) { | 4260 if (getMainModel() != nullptr && m_paneStack->getCurrentPane() != nullptr) { |
4261 addLayer(transform); | 4261 addLayer(transform); |
4262 } | 4262 } |
4263 } | 4263 } |
4264 | 4264 |
4265 void | 4265 void |
4482 void | 4482 void |
4483 MainWindow::updatePositionStatusDisplays() const | 4483 MainWindow::updatePositionStatusDisplays() const |
4484 { | 4484 { |
4485 if (!statusBar()->isVisible()) return; | 4485 if (!statusBar()->isVisible()) return; |
4486 | 4486 |
4487 Pane *pane = 0; | 4487 Pane *pane = nullptr; |
4488 sv_frame_t frame = m_viewManager->getPlaybackFrame(); | 4488 sv_frame_t frame = m_viewManager->getPlaybackFrame(); |
4489 | 4489 |
4490 if (m_paneStack) pane = m_paneStack->getCurrentPane(); | 4490 if (m_paneStack) pane = m_paneStack->getCurrentPane(); |
4491 if (!pane) return; | 4491 if (!pane) return; |
4492 | 4492 |
4582 } | 4582 } |
4583 | 4583 |
4584 void | 4584 void |
4585 MainWindow::midiEventsAvailable() | 4585 MainWindow::midiEventsAvailable() |
4586 { | 4586 { |
4587 Pane *currentPane = 0; | 4587 Pane *currentPane = nullptr; |
4588 NoteLayer *currentNoteLayer = 0; | 4588 NoteLayer *currentNoteLayer = nullptr; |
4589 TimeValueLayer *currentTimeValueLayer = 0; | 4589 TimeValueLayer *currentTimeValueLayer = nullptr; |
4590 | 4590 |
4591 if (m_paneStack) { | 4591 if (m_paneStack) { |
4592 currentPane = m_paneStack->getCurrentPane(); | 4592 currentPane = m_paneStack->getCurrentPane(); |
4593 } | 4593 } |
4594 | 4594 |
4675 } | 4675 } |
4676 | 4676 |
4677 void | 4677 void |
4678 MainWindow::playStatusChanged(bool ) | 4678 MainWindow::playStatusChanged(bool ) |
4679 { | 4679 { |
4680 Pane *currentPane = 0; | 4680 Pane *currentPane = nullptr; |
4681 NoteLayer *currentNoteLayer = 0; | 4681 NoteLayer *currentNoteLayer = nullptr; |
4682 | 4682 |
4683 if (m_paneStack) currentPane = m_paneStack->getCurrentPane(); | 4683 if (m_paneStack) currentPane = m_paneStack->getCurrentPane(); |
4684 if (currentPane) { | 4684 if (currentPane) { |
4685 currentNoteLayer = dynamic_cast<NoteLayer *>(currentPane->getSelectedLayer()); | 4685 currentNoteLayer = dynamic_cast<NoteLayer *>(currentPane->getSelectedLayer()); |
4686 } | 4686 } |
4752 void | 4752 void |
4753 MainWindow::modelAboutToBeDeleted(Model *model) | 4753 MainWindow::modelAboutToBeDeleted(Model *model) |
4754 { | 4754 { |
4755 if (model == m_panLayer->getModel()) { | 4755 if (model == m_panLayer->getModel()) { |
4756 if (model == getMainModel()) { | 4756 if (model == getMainModel()) { |
4757 m_panLayer->setModel(0); | 4757 m_panLayer->setModel(nullptr); |
4758 } else { | 4758 } else { |
4759 m_panLayer->setModel(getMainModel()); | 4759 m_panLayer->setModel(getMainModel()); |
4760 } | 4760 } |
4761 } | 4761 } |
4762 MainWindowBase::modelAboutToBeDeleted(model); | 4762 MainWindowBase::modelAboutToBeDeleted(model); |