Mercurial > hg > tony
comparison src/MainWindow.cpp @ 402:a0eedd10dee3 cxx11-types
Merge from default branch
| author | Chris Cannam |
|---|---|
| date | Mon, 23 Mar 2015 10:33:32 +0000 |
| parents | ffd1a89a68fa bed6493c3042 |
| children | cc33cdb114f6 |
comparison
equal
deleted
inserted
replaced
| 400:4b9b7ff3f19c | 402:a0eedd10dee3 |
|---|---|
| 86 #include <errno.h> | 86 #include <errno.h> |
| 87 | 87 |
| 88 using std::vector; | 88 using std::vector; |
| 89 | 89 |
| 90 | 90 |
| 91 MainWindow::MainWindow(bool withAudioOutput) : | 91 MainWindow::MainWindow(bool withAudioOutput, bool withSonification, bool withSpectrogram) : |
| 92 MainWindowBase(withAudioOutput, false), | 92 MainWindowBase(withAudioOutput, false), |
| 93 m_overview(0), | 93 m_overview(0), |
| 94 m_mainMenusCreated(false), | 94 m_mainMenusCreated(false), |
| 95 m_playbackMenu(0), | 95 m_playbackMenu(0), |
| 96 m_recentFilesMenu(0), | 96 m_recentFilesMenu(0), |
| 100 m_ffwdAction(0), | 100 m_ffwdAction(0), |
| 101 m_rwdAction(0), | 101 m_rwdAction(0), |
| 102 m_intelligentActionOn(true), //GF: !!! temporary | 102 m_intelligentActionOn(true), //GF: !!! temporary |
| 103 m_activityLog(new ActivityLog()), | 103 m_activityLog(new ActivityLog()), |
| 104 m_keyReference(new KeyReference()), | 104 m_keyReference(new KeyReference()), |
| 105 m_selectionAnchor(0) | 105 m_selectionAnchor(0), |
| 106 m_withSonification(withSonification), | |
| 107 m_withSpectrogram(withSpectrogram) | |
| 106 { | 108 { |
| 107 setWindowTitle(QApplication::applicationName()); | 109 setWindowTitle(QApplication::applicationName()); |
| 108 | 110 |
| 109 #ifdef Q_OS_MAC | 111 #ifdef Q_OS_MAC |
| 110 #if (QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)) | 112 #if (QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)) |
| 158 m_viewManager->setAlignMode(false); | 160 m_viewManager->setAlignMode(false); |
| 159 m_viewManager->setPlaySoloMode(false); | 161 m_viewManager->setPlaySoloMode(false); |
| 160 m_viewManager->setToolMode(ViewManager::NavigateMode); | 162 m_viewManager->setToolMode(ViewManager::NavigateMode); |
| 161 m_viewManager->setZoomWheelsEnabled(false); | 163 m_viewManager->setZoomWheelsEnabled(false); |
| 162 m_viewManager->setIlluminateLocalFeatures(true); | 164 m_viewManager->setIlluminateLocalFeatures(true); |
| 163 m_viewManager->setShowWorkTitle(true); | 165 m_viewManager->setShowWorkTitle(false); |
| 164 m_viewManager->setShowCentreLine(false); | 166 m_viewManager->setShowCentreLine(false); |
| 167 m_viewManager->setShowDuration(false); | |
| 165 m_viewManager->setOverlayMode(ViewManager::GlobalOverlays); | 168 m_viewManager->setOverlayMode(ViewManager::GlobalOverlays); |
| 166 | 169 |
| 167 connect(m_viewManager, SIGNAL(selectionChangedByUser()), | 170 connect(m_viewManager, SIGNAL(selectionChangedByUser()), |
| 168 this, SLOT(selectionChangedByUser())); | 171 this, SLOT(selectionChangedByUser())); |
| 169 | 172 |
| 185 connect(m_paneStack, SIGNAL(doubleClickSelectInvoked(sv_frame_t)), | 188 connect(m_paneStack, SIGNAL(doubleClickSelectInvoked(sv_frame_t)), |
| 186 this, SLOT(doubleClickSelectInvoked(sv_frame_t))); | 189 this, SLOT(doubleClickSelectInvoked(sv_frame_t))); |
| 187 scroll->setWidget(m_paneStack); | 190 scroll->setWidget(m_paneStack); |
| 188 | 191 |
| 189 m_overview = new Overview(frame); | 192 m_overview = new Overview(frame); |
| 193 m_overview->setPlaybackFollow(PlaybackScrollPage); | |
| 190 m_overview->setViewManager(m_viewManager); | 194 m_overview->setViewManager(m_viewManager); |
| 191 m_overview->setFixedHeight(40); | 195 m_overview->setFixedHeight(60); |
| 192 #ifndef _WIN32 | 196 #ifndef _WIN32 |
| 193 // For some reason, the contents of the overview never appear if we | 197 // For some reason, the contents of the overview never appear if we |
| 194 // make this setting on Windows. I have no inclination at the moment | 198 // make this setting on Windows. I have no inclination at the moment |
| 195 // to track down the reason why. | 199 // to track down the reason why. |
| 196 m_overview->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken); | 200 m_overview->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken); |
| 199 this, SLOT(contextHelpChanged(const QString &))); | 203 this, SLOT(contextHelpChanged(const QString &))); |
| 200 | 204 |
| 201 m_panLayer = new WaveformLayer; | 205 m_panLayer = new WaveformLayer; |
| 202 m_panLayer->setChannelMode(WaveformLayer::MergeChannels); | 206 m_panLayer->setChannelMode(WaveformLayer::MergeChannels); |
| 203 m_panLayer->setAggressiveCacheing(true); | 207 m_panLayer->setAggressiveCacheing(true); |
| 208 m_panLayer->setGain(0.5); | |
| 204 m_overview->addLayer(m_panLayer); | 209 m_overview->addLayer(m_panLayer); |
| 205 | 210 |
| 206 if (m_viewManager->getGlobalDarkBackground()) { | 211 if (m_viewManager->getGlobalDarkBackground()) { |
| 207 m_panLayer->setBaseColour | 212 m_panLayer->setBaseColour |
| 208 (ColourDatabase::getInstance()->getColourIndex(tr("Bright Green"))); | 213 (ColourDatabase::getInstance()->getColourIndex(tr("Bright Green"))); |
| 251 connect(m_gainAudio, SIGNAL(valueChanged(int)), | 256 connect(m_gainAudio, SIGNAL(valueChanged(int)), |
| 252 this, SLOT(audioGainChanged(int))); | 257 this, SLOT(audioGainChanged(int))); |
| 253 connect(m_gainAudio, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget())); | 258 connect(m_gainAudio, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget())); |
| 254 connect(m_gainAudio, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget())); | 259 connect(m_gainAudio, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget())); |
| 255 | 260 |
| 256 m_gainPitch = new AudioDial(frame); | 261 if (m_withSonification) |
| 257 m_gainPitch->setMeterColor(Qt::darkRed); | 262 { |
| 258 m_gainPitch->setMinimum(-50); | 263 m_gainPitch = new AudioDial(frame); |
| 259 m_gainPitch->setMaximum(50); | 264 m_gainPitch->setMeterColor(Qt::darkRed); |
| 260 m_gainPitch->setValue(0); | 265 m_gainPitch->setMinimum(-50); |
| 261 m_gainPitch->setDefaultValue(0); | 266 m_gainPitch->setMaximum(50); |
| 262 m_gainPitch->setFixedWidth(24); | 267 m_gainPitch->setValue(0); |
| 263 m_gainPitch->setFixedHeight(24); | 268 m_gainPitch->setDefaultValue(0); |
| 264 m_gainPitch->setNotchesVisible(true); | 269 m_gainPitch->setFixedWidth(24); |
| 265 m_gainPitch->setPageStep(10); | 270 m_gainPitch->setFixedHeight(24); |
| 266 m_gainPitch->setObjectName(tr("Pitch Track Gain")); | 271 m_gainPitch->setNotchesVisible(true); |
| 267 m_gainPitch->setRangeMapper(new LinearRangeMapper(-50, 50, -25, 25, tr("dB"))); | 272 m_gainPitch->setPageStep(10); |
| 268 m_gainPitch->setShowToolTip(true); | 273 m_gainPitch->setObjectName(tr("Pitch Track Gain")); |
| 269 connect(m_gainPitch, SIGNAL(valueChanged(int)), | 274 m_gainPitch->setRangeMapper(new LinearRangeMapper(-50, 50, -25, 25, tr("dB"))); |
| 270 this, SLOT(pitchGainChanged(int))); | 275 m_gainPitch->setShowToolTip(true); |
| 271 connect(m_gainPitch, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget())); | 276 connect(m_gainPitch, SIGNAL(valueChanged(int)), |
| 272 connect(m_gainPitch, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget())); | 277 this, SLOT(pitchGainChanged(int))); |
| 273 | 278 connect(m_gainPitch, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget())); |
| 274 m_gainNotes = new AudioDial(frame); | 279 connect(m_gainPitch, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget())); |
| 275 m_gainNotes->setMeterColor(Qt::darkRed); | 280 |
| 276 m_gainNotes->setMinimum(-50); | 281 m_gainNotes = new AudioDial(frame); |
| 277 m_gainNotes->setMaximum(50); | 282 m_gainNotes->setMeterColor(Qt::darkRed); |
| 278 m_gainNotes->setValue(0); | 283 m_gainNotes->setMinimum(-50); |
| 279 m_gainNotes->setDefaultValue(0); | 284 m_gainNotes->setMaximum(50); |
| 280 m_gainNotes->setFixedWidth(24); | 285 m_gainNotes->setValue(0); |
| 281 m_gainNotes->setFixedHeight(24); | 286 m_gainNotes->setDefaultValue(0); |
| 282 m_gainNotes->setNotchesVisible(true); | 287 m_gainNotes->setFixedWidth(24); |
| 283 m_gainNotes->setPageStep(10); | 288 m_gainNotes->setFixedHeight(24); |
| 284 m_gainNotes->setObjectName(tr("Pitch Track Gain")); | 289 m_gainNotes->setNotchesVisible(true); |
| 285 m_gainNotes->setRangeMapper(new LinearRangeMapper(-50, 50, -25, 25, tr("dB"))); | 290 m_gainNotes->setPageStep(10); |
| 286 m_gainNotes->setShowToolTip(true); | 291 m_gainNotes->setObjectName(tr("Note Gain")); |
| 287 connect(m_gainNotes, SIGNAL(valueChanged(int)), | 292 m_gainNotes->setRangeMapper(new LinearRangeMapper(-50, 50, -25, 25, tr("dB"))); |
| 288 this, SLOT(notesGainChanged(int))); | 293 m_gainNotes->setShowToolTip(true); |
| 289 connect(m_gainNotes, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget())); | 294 connect(m_gainNotes, SIGNAL(valueChanged(int)), |
| 290 connect(m_gainNotes, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget())); | 295 this, SLOT(notesGainChanged(int))); |
| 296 connect(m_gainNotes, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget())); | |
| 297 connect(m_gainNotes, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget())); | |
| 298 } | |
| 291 // End of Gain controls | 299 // End of Gain controls |
| 292 | 300 |
| 293 // Pan controls | 301 // Pan controls |
| 294 m_panAudio = new AudioDial(frame); | 302 m_panAudio = new AudioDial(frame); |
| 295 m_panAudio->setMeterColor(Qt::darkGreen); | 303 m_panAudio->setMeterColor(Qt::darkGreen); |
| 308 connect(m_panAudio, SIGNAL(valueChanged(int)), | 316 connect(m_panAudio, SIGNAL(valueChanged(int)), |
| 309 this, SLOT(audioPanChanged(int))); | 317 this, SLOT(audioPanChanged(int))); |
| 310 connect(m_panAudio, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget())); | 318 connect(m_panAudio, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget())); |
| 311 connect(m_panAudio, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget())); | 319 connect(m_panAudio, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget())); |
| 312 | 320 |
| 313 m_panPitch = new AudioDial(frame); | 321 |
| 314 m_panPitch->setMeterColor(Qt::darkGreen); | 322 |
| 315 m_panPitch->setMinimum(-100); | 323 if (m_withSonification) |
| 316 m_panPitch->setMaximum(100); | 324 { |
| 317 m_panPitch->setValue(100); | 325 m_panPitch = new AudioDial(frame); |
| 318 m_panPitch->setDefaultValue(100); | 326 m_panPitch->setMeterColor(Qt::darkGreen); |
| 319 m_panPitch->setFixedWidth(24); | 327 m_panPitch->setMinimum(-100); |
| 320 m_panPitch->setFixedHeight(24); | 328 m_panPitch->setMaximum(100); |
| 321 m_panPitch->setNotchesVisible(true); | 329 m_panPitch->setValue(100); |
| 322 m_panPitch->setPageStep(10); | 330 m_panPitch->setDefaultValue(100); |
| 323 m_panPitch->setObjectName(tr("Pitch Track Pan")); | 331 m_panPitch->setFixedWidth(24); |
| 324 m_panPitch->setRangeMapper(new LinearRangeMapper(-100, 100, -100, 100, tr(""))); | 332 m_panPitch->setFixedHeight(24); |
| 325 m_panPitch->setShowToolTip(true); | 333 m_panPitch->setNotchesVisible(true); |
| 326 connect(m_panPitch, SIGNAL(valueChanged(int)), | 334 m_panPitch->setPageStep(10); |
| 327 this, SLOT(pitchPanChanged(int))); | 335 m_panPitch->setObjectName(tr("Pitch Track Pan")); |
| 328 connect(m_panPitch, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget())); | 336 m_panPitch->setRangeMapper(new LinearRangeMapper(-100, 100, -100, 100, tr(""))); |
| 329 connect(m_panPitch, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget())); | 337 m_panPitch->setShowToolTip(true); |
| 330 | 338 connect(m_panPitch, SIGNAL(valueChanged(int)), |
| 331 m_panNotes = new AudioDial(frame); | 339 this, SLOT(pitchPanChanged(int))); |
| 332 m_panNotes->setMeterColor(Qt::darkGreen); | 340 connect(m_panPitch, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget())); |
| 333 m_panNotes->setMinimum(-100); | 341 connect(m_panPitch, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget())); |
| 334 m_panNotes->setMaximum(100); | 342 |
| 335 m_panNotes->setValue(100); | 343 m_panNotes = new AudioDial(frame); |
| 336 m_panNotes->setDefaultValue(100); | 344 m_panNotes->setMeterColor(Qt::darkGreen); |
| 337 m_panNotes->setFixedWidth(24); | 345 m_panNotes->setMinimum(-100); |
| 338 m_panNotes->setFixedHeight(24); | 346 m_panNotes->setMaximum(100); |
| 339 m_panNotes->setNotchesVisible(true); | 347 m_panNotes->setValue(100); |
| 340 m_panNotes->setPageStep(10); | 348 m_panNotes->setDefaultValue(100); |
| 341 m_panNotes->setObjectName(tr("Notes Track Pan")); | 349 m_panNotes->setFixedWidth(24); |
| 342 m_panNotes->setRangeMapper(new LinearRangeMapper(-100, 100, -100, 100, tr(""))); | 350 m_panNotes->setFixedHeight(24); |
| 343 m_panNotes->setShowToolTip(true); | 351 m_panNotes->setNotchesVisible(true); |
| 344 connect(m_panNotes, SIGNAL(valueChanged(int)), | 352 m_panNotes->setPageStep(10); |
| 345 this, SLOT(notesPanChanged(int))); | 353 m_panNotes->setObjectName(tr("Note Pan")); |
| 346 connect(m_panNotes, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget())); | 354 m_panNotes->setRangeMapper(new LinearRangeMapper(-100, 100, -100, 100, tr(""))); |
| 347 connect(m_panNotes, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget())); | 355 m_panNotes->setShowToolTip(true); |
| 356 connect(m_panNotes, SIGNAL(valueChanged(int)), | |
| 357 this, SLOT(notesPanChanged(int))); | |
| 358 connect(m_panNotes, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget())); | |
| 359 connect(m_panNotes, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget())); | |
| 360 } | |
| 361 | |
| 348 // End of Pan controls | 362 // End of Pan controls |
| 349 | 363 |
| 350 layout->setSpacing(4); | 364 layout->setSpacing(4); |
| 351 layout->addWidget(m_overview, 0, 1); | 365 layout->addWidget(m_overview, 0, 1); |
| 352 layout->addWidget(scroll, 1, 1); | 366 layout->addWidget(scroll, 1, 1); |
| 410 | 424 |
| 411 void | 425 void |
| 412 MainWindow::setupMenus() | 426 MainWindow::setupMenus() |
| 413 { | 427 { |
| 414 if (!m_mainMenusCreated) { | 428 if (!m_mainMenusCreated) { |
| 429 | |
| 430 #ifdef Q_OS_LINUX | |
| 431 // In Ubuntu 14.04 the window's menu bar goes missing entirely | |
| 432 // if the user is running any desktop environment other than Unity | |
| 433 // (in which the faux single-menubar appears). The user has a | |
| 434 // workaround, to remove the appmenu-qt5 package, but that is | |
| 435 // awkward and the problem is so severe that it merits disabling | |
| 436 // the system menubar integration altogether. Like this: | |
| 437 menuBar()->setNativeMenuBar(false); | |
| 438 #endif | |
| 439 | |
| 415 m_rightButtonMenu = new QMenu(); | 440 m_rightButtonMenu = new QMenu(); |
| 416 } | 441 } |
| 417 | 442 |
| 418 if (!m_mainMenusCreated) { | 443 if (!m_mainMenusCreated) { |
| 419 CommandHistory::getInstance()->registerMenu(m_rightButtonMenu); | 444 CommandHistory::getInstance()->registerMenu(m_rightButtonMenu); |
| 916 m_keyReference->setCategory(tr("Help")); | 941 m_keyReference->setCategory(tr("Help")); |
| 917 | 942 |
| 918 IconLoader il; | 943 IconLoader il; |
| 919 | 944 |
| 920 QString name = QApplication::applicationName(); | 945 QString name = QApplication::applicationName(); |
| 921 | 946 QAction *action; |
| 922 QAction *action = new QAction(il.load("help"), | 947 |
| 948 action = new QAction(tr("&Key and Mouse Reference"), this); | |
| 949 action->setShortcut(tr("F2")); | |
| 950 action->setStatusTip(tr("Open a window showing the keystrokes you can use in %1").arg(name)); | |
| 951 connect(action, SIGNAL(triggered()), this, SLOT(keyReference())); | |
| 952 m_keyReference->registerShortcut(action); | |
| 953 menu->addAction(action); | |
| 954 | |
| 955 action = new QAction(il.load("help"), | |
| 923 tr("&Help Reference"), this); | 956 tr("&Help Reference"), this); |
| 924 action->setShortcut(tr("F1")); | 957 action->setShortcut(tr("F1")); |
| 925 action->setStatusTip(tr("Open the %1 reference manual").arg(name)); | 958 action->setStatusTip(tr("Open the %1 reference manual").arg(name)); |
| 926 connect(action, SIGNAL(triggered()), this, SLOT(help())); | 959 connect(action, SIGNAL(triggered()), this, SLOT(help())); |
| 927 m_keyReference->registerShortcut(action); | 960 m_keyReference->registerShortcut(action); |
| 928 menu->addAction(action); | 961 menu->addAction(action); |
| 929 | 962 |
| 930 action = new QAction(tr("&Key and Mouse Reference"), this); | |
| 931 action->setShortcut(tr("F2")); | |
| 932 action->setStatusTip(tr("Open a window showing the keystrokes you can use in %1").arg(name)); | |
| 933 connect(action, SIGNAL(triggered()), this, SLOT(keyReference())); | |
| 934 m_keyReference->registerShortcut(action); | |
| 935 menu->addAction(action); | |
| 936 | 963 |
| 937 action = new QAction(tr("%1 on the &Web").arg(name), this); | 964 action = new QAction(tr("%1 on the &Web").arg(name), this); |
| 938 action->setStatusTip(tr("Open the %1 website").arg(name)); | 965 action->setStatusTip(tr("Open the %1 website").arg(name)); |
| 939 connect(action, SIGNAL(triggered()), this, SLOT(website())); | 966 connect(action, SIGNAL(triggered()), this, SLOT(website())); |
| 940 menu->addAction(action); | 967 menu->addAction(action); |
| 1166 m_showPitch = toolbar->addAction(il.load("values"), tr("Show Pitch Track")); | 1193 m_showPitch = toolbar->addAction(il.load("values"), tr("Show Pitch Track")); |
| 1167 m_showPitch->setCheckable(true); | 1194 m_showPitch->setCheckable(true); |
| 1168 connect(m_showPitch, SIGNAL(triggered()), this, SLOT(showPitchToggled())); | 1195 connect(m_showPitch, SIGNAL(triggered()), this, SLOT(showPitchToggled())); |
| 1169 connect(this, SIGNAL(canPlay(bool)), m_showPitch, SLOT(setEnabled(bool))); | 1196 connect(this, SIGNAL(canPlay(bool)), m_showPitch, SLOT(setEnabled(bool))); |
| 1170 | 1197 |
| 1171 m_playPitch = toolbar->addAction(il.load("speaker"), tr("Play Pitch Track")); | 1198 if (!m_withSonification) |
| 1199 { | |
| 1200 m_playPitch = new QAction(tr("Play Pitch Track"), this); | |
| 1201 } else { | |
| 1202 m_playPitch = toolbar->addAction(il.load("speaker"), tr("Play Pitch Track")); | |
| 1203 toolbar->addWidget(m_gainPitch); | |
| 1204 toolbar->addWidget(m_panPitch); | |
| 1205 } | |
| 1172 m_playPitch->setCheckable(true); | 1206 m_playPitch->setCheckable(true); |
| 1173 connect(m_playPitch, SIGNAL(triggered()), this, SLOT(playPitchToggled())); | 1207 connect(m_playPitch, SIGNAL(triggered()), this, SLOT(playPitchToggled())); |
| 1174 connect(this, SIGNAL(canPlayPitch(bool)), m_playPitch, SLOT(setEnabled(bool))); | 1208 connect(this, SIGNAL(canPlayPitch(bool)), m_playPitch, SLOT(setEnabled(bool))); |
| 1175 | |
| 1176 toolbar->addWidget(m_gainPitch); | |
| 1177 toolbar->addWidget(m_panPitch); | |
| 1178 | 1209 |
| 1179 // Notes | 1210 // Notes |
| 1180 spacer = new QLabel; | 1211 spacer = new QLabel; |
| 1181 spacer->setFixedWidth(40); | 1212 spacer->setFixedWidth(40); |
| 1182 toolbar->addWidget(spacer); | 1213 toolbar->addWidget(spacer); |
| 1184 m_showNotes = toolbar->addAction(il.load("notes"), tr("Show Notes")); | 1215 m_showNotes = toolbar->addAction(il.load("notes"), tr("Show Notes")); |
| 1185 m_showNotes->setCheckable(true); | 1216 m_showNotes->setCheckable(true); |
| 1186 connect(m_showNotes, SIGNAL(triggered()), this, SLOT(showNotesToggled())); | 1217 connect(m_showNotes, SIGNAL(triggered()), this, SLOT(showNotesToggled())); |
| 1187 connect(this, SIGNAL(canPlay(bool)), m_showNotes, SLOT(setEnabled(bool))); | 1218 connect(this, SIGNAL(canPlay(bool)), m_showNotes, SLOT(setEnabled(bool))); |
| 1188 | 1219 |
| 1189 m_playNotes = toolbar->addAction(il.load("speaker"), tr("Play Notes")); | 1220 if (!m_withSonification) |
| 1221 { | |
| 1222 m_playNotes = new QAction(tr("Play Notes"), this); | |
| 1223 } else { | |
| 1224 m_playNotes = toolbar->addAction(il.load("speaker"), tr("Play Notes")); | |
| 1225 toolbar->addWidget(m_gainNotes); | |
| 1226 toolbar->addWidget(m_panNotes); | |
| 1227 } | |
| 1190 m_playNotes->setCheckable(true); | 1228 m_playNotes->setCheckable(true); |
| 1191 connect(m_playNotes, SIGNAL(triggered()), this, SLOT(playNotesToggled())); | 1229 connect(m_playNotes, SIGNAL(triggered()), this, SLOT(playNotesToggled())); |
| 1192 connect(this, SIGNAL(canPlayNotes(bool)), m_playNotes, SLOT(setEnabled(bool))); | 1230 connect(this, SIGNAL(canPlayNotes(bool)), m_playNotes, SLOT(setEnabled(bool))); |
| 1193 | |
| 1194 toolbar->addWidget(m_gainNotes); | |
| 1195 toolbar->addWidget(m_panNotes); | |
| 1196 | 1231 |
| 1197 // Spectrogram | 1232 // Spectrogram |
| 1198 spacer = new QLabel; | 1233 spacer = new QLabel; |
| 1199 spacer->setFixedWidth(40); | 1234 spacer->setFixedWidth(40); |
| 1200 toolbar->addWidget(spacer); | 1235 toolbar->addWidget(spacer); |
| 1201 | 1236 |
| 1202 m_showSpect = toolbar->addAction(il.load("spectrogram"), tr("Show Spectrogram")); | 1237 if (!m_withSpectrogram) |
| 1238 { | |
| 1239 m_showSpect = new QAction(tr("Show Spectrogram"), this); | |
| 1240 } else { | |
| 1241 m_showSpect = toolbar->addAction(il.load("spectrogram"), tr("Show Spectrogram")); | |
| 1242 } | |
| 1203 m_showSpect->setCheckable(true); | 1243 m_showSpect->setCheckable(true); |
| 1204 connect(m_showSpect, SIGNAL(triggered()), this, SLOT(showSpectToggled())); | 1244 connect(m_showSpect, SIGNAL(triggered()), this, SLOT(showSpectToggled())); |
| 1205 connect(this, SIGNAL(canPlay(bool)), m_showSpect, SLOT(setEnabled(bool))); | 1245 connect(this, SIGNAL(canPlay(bool)), m_showSpect, SLOT(setEnabled(bool))); |
| 1206 | 1246 |
| 1207 Pane::registerShortcuts(*m_keyReference); | 1247 Pane::registerShortcuts(*m_keyReference); |
| 1248 | |
| 1208 } | 1249 } |
| 1209 | 1250 |
| 1210 | 1251 |
| 1211 void | 1252 void |
| 1212 MainWindow::moveOneNoteRight() | 1253 MainWindow::moveOneNoteRight() |
| 1439 // just switched layer on; check whether playback was also on previously | 1480 // just switched layer on; check whether playback was also on previously |
| 1440 playOn = settings.value("playpitchwas", true).toBool(); | 1481 playOn = settings.value("playpitchwas", true).toBool(); |
| 1441 } else { | 1482 } else { |
| 1442 settings.setValue("playpitchwas", m_playPitch->isChecked()); | 1483 settings.setValue("playpitchwas", m_playPitch->isChecked()); |
| 1443 } | 1484 } |
| 1444 m_analyser->setAudible(Analyser::PitchTrack, playOn); | 1485 m_analyser->setAudible(Analyser::PitchTrack, playOn && m_withSonification); |
| 1445 m_playPitch->setChecked(playOn); | 1486 m_playPitch->setChecked(playOn); |
| 1446 | 1487 |
| 1447 settings.endGroup(); | 1488 settings.endGroup(); |
| 1448 | 1489 |
| 1449 updateMenuStates(); | 1490 updateMenuStates(); |
| 1468 // just switched layer on; check whether playback was also on previously | 1509 // just switched layer on; check whether playback was also on previously |
| 1469 playOn = settings.value("playnoteswas", true).toBool(); | 1510 playOn = settings.value("playnoteswas", true).toBool(); |
| 1470 } else { | 1511 } else { |
| 1471 settings.setValue("playnoteswas", m_playNotes->isChecked()); | 1512 settings.setValue("playnoteswas", m_playNotes->isChecked()); |
| 1472 } | 1513 } |
| 1473 m_analyser->setAudible(Analyser::Notes, playOn); | 1514 m_analyser->setAudible(Analyser::Notes, playOn && m_withSonification); |
| 1474 m_playNotes->setChecked(playOn); | 1515 m_playNotes->setChecked(playOn); |
| 1475 | 1516 |
| 1476 settings.endGroup(); | 1517 settings.endGroup(); |
| 1477 | 1518 |
| 1478 updateMenuStates(); | 1519 updateMenuStates(); |
| 1566 closeSession(); | 1607 closeSession(); |
| 1567 createDocument(); | 1608 createDocument(); |
| 1568 m_document->setAutoAlignment(true); | 1609 m_document->setAutoAlignment(true); |
| 1569 | 1610 |
| 1570 Pane *pane = m_paneStack->addPane(); | 1611 Pane *pane = m_paneStack->addPane(); |
| 1571 | 1612 pane->setPlaybackFollow(PlaybackScrollPage); |
| 1613 | |
| 1614 m_viewManager->setGlobalCentreFrame | |
| 1615 (pane->getFrameForX(width() / 2)); | |
| 1616 | |
| 1572 connect(pane, SIGNAL(contextHelpChanged(const QString &)), | 1617 connect(pane, SIGNAL(contextHelpChanged(const QString &)), |
| 1573 this, SLOT(contextHelpChanged(const QString &))); | 1618 this, SLOT(contextHelpChanged(const QString &))); |
| 1574 | 1619 |
| 1575 // Layer *waveform = m_document->createMainModelLayer(LayerFactory::Waveform); | 1620 // Layer *waveform = m_document->createMainModelLayer(LayerFactory::Waveform); |
| 1576 // m_document->addLayerToView(pane, waveform); | 1621 // m_document->addLayerToView(pane, waveform); |
| 1647 | 1692 |
| 1648 QString path = getOpenFileName(FileFinder::AnyFile); | 1693 QString path = getOpenFileName(FileFinder::AnyFile); |
| 1649 | 1694 |
| 1650 if (path.isEmpty()) return; | 1695 if (path.isEmpty()) return; |
| 1651 | 1696 |
| 1652 FileOpenStatus status = open(path, ReplaceSession); | 1697 FileOpenStatus status = openPath(path, ReplaceSession); |
| 1653 | 1698 |
| 1654 if (status == FileOpenFailed) { | 1699 if (status == FileOpenFailed) { |
| 1655 QMessageBox::critical(this, tr("Failed to open file"), | 1700 QMessageBox::critical(this, tr("Failed to open file"), |
| 1656 tr("<b>File open failed</b><p>File \"%1\" could not be opened").arg(path)); | 1701 tr("<b>File open failed</b><p>File \"%1\" could not be opened").arg(path)); |
| 1657 } else if (status == FileOpenWrongMode) { | 1702 } else if (status == FileOpenWrongMode) { |
| 1677 | 1722 |
| 1678 settings.setValue("lastremote", text); | 1723 settings.setValue("lastremote", text); |
| 1679 | 1724 |
| 1680 if (text.isEmpty()) return; | 1725 if (text.isEmpty()) return; |
| 1681 | 1726 |
| 1682 FileOpenStatus status = open(text, ReplaceSession); | 1727 FileOpenStatus status = openPath(text, ReplaceSession); |
| 1683 | 1728 |
| 1684 if (status == FileOpenFailed) { | 1729 if (status == FileOpenFailed) { |
| 1685 QMessageBox::critical(this, tr("Failed to open location"), | 1730 QMessageBox::critical(this, tr("Failed to open location"), |
| 1686 tr("<b>Open failed</b><p>URL \"%1\" could not be opened").arg(text)); | 1731 tr("<b>Open failed</b><p>URL \"%1\" could not be opened").arg(text)); |
| 1687 } else if (status == FileOpenWrongMode) { | 1732 } else if (status == FileOpenWrongMode) { |
| 1703 } | 1748 } |
| 1704 | 1749 |
| 1705 QString path = action->text(); | 1750 QString path = action->text(); |
| 1706 if (path == "") return; | 1751 if (path == "") return; |
| 1707 | 1752 |
| 1708 FileOpenStatus status = open(path, ReplaceSession); | 1753 FileOpenStatus status = openPath(path, ReplaceSession); |
| 1709 | 1754 |
| 1710 if (status == FileOpenFailed) { | 1755 if (status == FileOpenFailed) { |
| 1711 QMessageBox::critical(this, tr("Failed to open location"), | 1756 QMessageBox::critical(this, tr("Failed to open location"), |
| 1712 tr("<b>Open failed</b><p>File or URL \"%1\" could not be opened").arg(path)); | 1757 tr("<b>Open failed</b><p>File or URL \"%1\" could not be opened").arg(path)); |
| 1713 } else if (status == FileOpenWrongMode) { | 1758 } else if (status == FileOpenWrongMode) { |
| 1741 { | 1786 { |
| 1742 if (pane) m_paneStack->setCurrentPane(pane); | 1787 if (pane) m_paneStack->setCurrentPane(pane); |
| 1743 | 1788 |
| 1744 for (QStringList::iterator i = uriList.begin(); i != uriList.end(); ++i) { | 1789 for (QStringList::iterator i = uriList.begin(); i != uriList.end(); ++i) { |
| 1745 | 1790 |
| 1746 FileOpenStatus status = open(*i, ReplaceSession); | 1791 FileOpenStatus status = openPath(*i, ReplaceSession); |
| 1747 | 1792 |
| 1748 if (status == FileOpenFailed) { | 1793 if (status == FileOpenFailed) { |
| 1749 QMessageBox::critical(this, tr("Failed to open dropped URL"), | 1794 QMessageBox::critical(this, tr("Failed to open dropped URL"), |
| 1750 tr("<b>Open failed</b><p>Dropped URL \"%1\" could not be opened").arg(*i)); | 1795 tr("<b>Open failed</b><p>Dropped URL \"%1\" could not be opened").arg(*i)); |
| 1751 } else if (status == FileOpenWrongMode) { | 1796 } else if (status == FileOpenWrongMode) { |
| 2893 if (!getMainModel() || !p) { | 2938 if (!getMainModel() || !p) { |
| 2894 return; | 2939 return; |
| 2895 } | 2940 } |
| 2896 | 2941 |
| 2897 bool haveSelection = false; | 2942 bool haveSelection = false; |
| 2898 size_t startFrame = 0, endFrame = 0; | 2943 int startFrame = 0, endFrame = 0; |
| 2899 | 2944 |
| 2900 if (m_viewManager && m_viewManager->haveInProgressSelection()) { | 2945 if (m_viewManager && m_viewManager->haveInProgressSelection()) { |
| 2901 | 2946 |
| 2902 bool exclusive = false; | 2947 bool exclusive = false; |
| 2903 Selection s = m_viewManager->getInProgressSelection(exclusive); | 2948 Selection s = m_viewManager->getInProgressSelection(exclusive); |
| 2933 } else { | 2978 } else { |
| 2934 m_myStatusMessage = tr("Visible: %1 to %2 (duration %3)") | 2979 m_myStatusMessage = tr("Visible: %1 to %2 (duration %3)") |
| 2935 .arg(startStr).arg(endStr).arg(durationStr); | 2980 .arg(startStr).arg(endStr).arg(durationStr); |
| 2936 } | 2981 } |
| 2937 | 2982 |
| 2938 statusBar()->showMessage(m_myStatusMessage); | 2983 getStatusLabel()->setText(m_myStatusMessage); |
| 2939 } | 2984 } |
| 2940 | 2985 |
| 2941 void | 2986 void |
| 2942 MainWindow::updatePositionStatusDisplays() const | 2987 MainWindow::updatePositionStatusDisplays() const |
| 2943 { | 2988 { |
| 3074 } else { | 3119 } else { |
| 3075 pane = m_paneStack->getPane(0); | 3120 pane = m_paneStack->getPane(0); |
| 3076 selectionStrip = m_paneStack->getPane(1); | 3121 selectionStrip = m_paneStack->getPane(1); |
| 3077 } | 3122 } |
| 3078 | 3123 |
| 3124 pane->setPlaybackFollow(PlaybackScrollPage); | |
| 3125 | |
| 3079 if (selectionStrip) { | 3126 if (selectionStrip) { |
| 3127 selectionStrip->setPlaybackFollow(PlaybackScrollPage); | |
| 3080 selectionStrip->setFixedHeight(26); | 3128 selectionStrip->setFixedHeight(26); |
| 3081 m_paneStack->sizePanesEqually(); | 3129 m_paneStack->sizePanesEqually(); |
| 3082 m_viewManager->clearToolModeOverrides(); | 3130 m_viewManager->clearToolModeOverrides(); |
| 3083 m_viewManager->setToolModeFor(selectionStrip, | 3131 m_viewManager->setToolModeFor(selectionStrip, |
| 3084 ViewManager::SelectMode); | 3132 ViewManager::SelectMode); |
| 3098 (this, | 3146 (this, |
| 3099 tr("Failed to analyse audio"), | 3147 tr("Failed to analyse audio"), |
| 3100 tr("<b>Analysis failed</b><p>%1</p>").arg(error), | 3148 tr("<b>Analysis failed</b><p>%1</p>").arg(error), |
| 3101 QMessageBox::Ok); | 3149 QMessageBox::Ok); |
| 3102 } | 3150 } |
| 3151 } | |
| 3152 | |
| 3153 if (!m_withSpectrogram) | |
| 3154 { | |
| 3155 m_analyser->setVisible(Analyser::Spectrogram, false); | |
| 3156 } | |
| 3157 | |
| 3158 if (!m_withSonification) | |
| 3159 { | |
| 3160 m_analyser->setAudible(Analyser::PitchTrack, false); | |
| 3161 m_analyser->setAudible(Analyser::Notes, false); | |
| 3103 } | 3162 } |
| 3104 } | 3163 } |
| 3105 | 3164 |
| 3106 void | 3165 void |
| 3107 MainWindow::modelGenerationFailed(QString transformName, QString message) | 3166 MainWindow::modelGenerationFailed(QString transformName, QString message) |
| 3220 | 3279 |
| 3221 void | 3280 void |
| 3222 MainWindow::help() | 3281 MainWindow::help() |
| 3223 { | 3282 { |
| 3224 //!!! todo: help URL! | 3283 //!!! todo: help URL! |
| 3225 openHelpUrl(tr("http://code.soundsoftware.ac.uk/projects/tony/")); | 3284 openHelpUrl(tr("http://code.soundsoftware.ac.uk/projects/tony/wiki/Reference")); |
| 3226 } | 3285 } |
| 3227 | 3286 |
| 3228 void | 3287 void |
| 3229 MainWindow::about() | 3288 MainWindow::about() |
| 3230 { | 3289 { |
| 3278 settings.setValue(tag, false); | 3337 settings.setValue(tag, false); |
| 3279 } | 3338 } |
| 3280 settings.endGroup(); | 3339 settings.endGroup(); |
| 3281 } | 3340 } |
| 3282 | 3341 |
| 3283 | 3342 void |
| 3284 | 3343 MainWindow::ffwd() |
| 3344 { | |
| 3345 if (!getMainModel()) return; | |
| 3346 | |
| 3347 int frame = m_viewManager->getPlaybackFrame(); | |
| 3348 ++frame; | |
| 3349 | |
| 3350 size_t sr = getMainModel()->getSampleRate(); | |
| 3351 | |
| 3352 // The step is supposed to scale and be as wide as a step of | |
| 3353 // m_defaultFfwdRwdStep seconds at zoom level 720 and sr = 44100 | |
| 3354 size_t framesPerPixel = m_viewManager->getGlobalZoom(); | |
| 3355 size_t defaultZoom = (720 * 44100) / sr; | |
| 3356 | |
| 3357 float scaler = (framesPerPixel * 1.0f) / defaultZoom; | |
| 3358 | |
| 3359 | |
| 3360 frame = RealTime::realTime2Frame | |
| 3361 (RealTime::frame2RealTime(frame, sr) + m_defaultFfwdRwdStep * scaler, sr); | |
| 3362 if (frame > int(getMainModel()->getEndFrame())) { | |
| 3363 frame = getMainModel()->getEndFrame(); | |
| 3364 } | |
| 3365 | |
| 3366 if (frame < 0) frame = 0; | |
| 3367 | |
| 3368 if (m_viewManager->getPlaySelectionMode()) { | |
| 3369 frame = m_viewManager->constrainFrameToSelection(size_t(frame)); | |
| 3370 } | |
| 3371 | |
| 3372 m_viewManager->setPlaybackFrame(frame); | |
| 3373 | |
| 3374 if (frame == (int)getMainModel()->getEndFrame() && | |
| 3375 m_playSource && | |
| 3376 m_playSource->isPlaying() && | |
| 3377 !m_viewManager->getPlayLoopMode()) { | |
| 3378 stop(); | |
| 3379 } | |
| 3380 } | |
| 3381 | |
| 3382 void | |
| 3383 MainWindow::rewind() | |
| 3384 { | |
| 3385 if (!getMainModel()) return; | |
| 3386 | |
| 3387 int frame = m_viewManager->getPlaybackFrame(); | |
| 3388 if (frame > 0) --frame; | |
| 3389 | |
| 3390 size_t sr = getMainModel()->getSampleRate(); | |
| 3391 | |
| 3392 // The step is supposed to scale and be as wide as a step of | |
| 3393 // m_defaultFfwdRwdStep seconds at zoom level 720 and sr = 44100 | |
| 3394 size_t framesPerPixel = m_viewManager->getGlobalZoom(); | |
| 3395 size_t defaultZoom = (720 * 44100) / sr; | |
| 3396 | |
| 3397 float scaler = (framesPerPixel * 1.0f) / defaultZoom; | |
| 3398 frame = RealTime::realTime2Frame | |
| 3399 (RealTime::frame2RealTime(frame, sr) - m_defaultFfwdRwdStep * scaler, sr); | |
| 3400 if (frame < int(getMainModel()->getStartFrame())) { | |
| 3401 frame = getMainModel()->getStartFrame(); | |
| 3402 } | |
| 3403 | |
| 3404 if (frame < 0) frame = 0; | |
| 3405 | |
| 3406 if (m_viewManager->getPlaySelectionMode()) { | |
| 3407 frame = m_viewManager->constrainFrameToSelection(size_t(frame)); | |
| 3408 } | |
| 3409 | |
| 3410 m_viewManager->setPlaybackFrame(frame); | |
| 3411 } |
