Mercurial > hg > tony
comparison src/MainWindow.cpp @ 187:dedd09297a3e
Fix #884 (erroneously allows you to change candidate even when candidates not visible) and remaining part of #874 (show pitch candidates only on request). Also reorder menu items a little
author | Chris Cannam |
---|---|
date | Tue, 04 Mar 2014 14:10:37 +0000 |
parents | 01139b1cb98d |
children | b970b39e1fab |
comparison
equal
deleted
inserted
replaced
186:01139b1cb98d | 187:dedd09297a3e |
---|---|
333 frame->setLayout(layout); | 333 frame->setLayout(layout); |
334 | 334 |
335 m_analyser = new Analyser(); | 335 m_analyser = new Analyser(); |
336 connect(m_analyser, SIGNAL(layersChanged()), | 336 connect(m_analyser, SIGNAL(layersChanged()), |
337 this, SLOT(updateLayerStatuses())); | 337 this, SLOT(updateLayerStatuses())); |
338 connect(m_analyser, SIGNAL(layersChanged()), | |
339 this, SLOT(updateMenuStates())); | |
338 | 340 |
339 setupMenus(); | 341 setupMenus(); |
340 setupToolbars(); | 342 setupToolbars(); |
341 setupHelpMenu(); | 343 setupHelpMenu(); |
342 | 344 |
532 m_rightButtonMenu->addAction(action); | 534 m_rightButtonMenu->addAction(action); |
533 | 535 |
534 menu->addSeparator(); | 536 menu->addSeparator(); |
535 | 537 |
536 //!!! shortcuts, status tip, key reference etc | 538 //!!! shortcuts, status tip, key reference etc |
537 action = new QAction(tr("Clear Pitches"), this); | 539 m_showCandidatesAction = new QAction(tr("Show Pitch Candidates"), this); |
538 action->setShortcut(tr("Ctrl+Backspace")); | 540 m_showCandidatesAction->setShortcut(tr("Ctrl+Return")); |
539 connect(action, SIGNAL(triggered()), this, SLOT(clearPitches())); | 541 connect(m_showCandidatesAction, SIGNAL(triggered()), this, SLOT(togglePitchCandidates())); |
540 connect(this, SIGNAL(canClearSelection(bool)), action, SLOT(setEnabled(bool))); | 542 connect(this, SIGNAL(canClearSelection(bool)), m_showCandidatesAction, SLOT(setEnabled(bool))); |
541 menu->addAction(action); | 543 menu->addAction(m_showCandidatesAction); |
542 | 544 |
545 //!!! shortcuts, status tip, key reference etc | |
546 action = new QAction(tr("Pick Higher Pitch Candidate"), this); | |
547 action->setShortcut(tr("Ctrl+Up")); | |
548 connect(action, SIGNAL(triggered()), this, SLOT(switchPitchUp())); | |
549 connect(this, SIGNAL(canChangePitchCandidate(bool)), action, SLOT(setEnabled(bool))); | |
550 menu->addAction(action); | |
551 | |
552 //!!! shortcuts, status tip, key reference etc | |
553 action = new QAction(tr("Pick Lower Pitch Candidate"), this); | |
554 action->setShortcut(tr("Ctrl+Down")); | |
555 connect(action, SIGNAL(triggered()), this, SLOT(switchPitchDown())); | |
556 connect(this, SIGNAL(canChangePitchCandidate(bool)), action, SLOT(setEnabled(bool))); | |
557 menu->addAction(action); | |
558 | |
559 menu->addSeparator(); | |
560 | |
543 //!!! shortcuts, status tip, key reference etc | 561 //!!! shortcuts, status tip, key reference etc |
544 action = new QAction(tr("Octave Shift Up"), this); | 562 action = new QAction(tr("Octave Shift Up"), this); |
545 action->setShortcut(tr("PgUp")); | 563 action->setShortcut(tr("PgUp")); |
546 connect(action, SIGNAL(triggered()), this, SLOT(octaveShiftUp())); | 564 connect(action, SIGNAL(triggered()), this, SLOT(octaveShiftUp())); |
547 connect(this, SIGNAL(canClearSelection(bool)), action, SLOT(setEnabled(bool))); | 565 connect(this, SIGNAL(canClearSelection(bool)), action, SLOT(setEnabled(bool))); |
550 action = new QAction(tr("Octave Shift Down"), this); | 568 action = new QAction(tr("Octave Shift Down"), this); |
551 action->setShortcut(tr("PgDown")); | 569 action->setShortcut(tr("PgDown")); |
552 connect(action, SIGNAL(triggered()), this, SLOT(octaveShiftDown())); | 570 connect(action, SIGNAL(triggered()), this, SLOT(octaveShiftDown())); |
553 connect(this, SIGNAL(canClearSelection(bool)), action, SLOT(setEnabled(bool))); | 571 connect(this, SIGNAL(canClearSelection(bool)), action, SLOT(setEnabled(bool))); |
554 menu->addAction(action); | 572 menu->addAction(action); |
573 | |
574 menu->addSeparator(); | |
555 | 575 |
556 //!!! shortcuts, status tip, key reference etc | 576 //!!! shortcuts, status tip, key reference etc |
557 action = new QAction(tr("Toggle Alternative Pitch Candidates"), this); | 577 action = new QAction(tr("Remove Pitches"), this); |
558 action->setShortcut(tr("Ctrl+Return")); | 578 action->setShortcut(tr("Ctrl+Backspace")); |
559 connect(action, SIGNAL(triggered()), this, SLOT(togglePitchCandidates())); | 579 connect(action, SIGNAL(triggered()), this, SLOT(clearPitches())); |
560 connect(this, SIGNAL(canClearSelection(bool)), action, SLOT(setEnabled(bool))); | |
561 menu->addAction(action); | |
562 | |
563 //!!! shortcuts, status tip, key reference etc | |
564 action = new QAction(tr("Pick Higher Pitch Candidate"), this); | |
565 action->setShortcut(tr("Ctrl+Up")); | |
566 connect(action, SIGNAL(triggered()), this, SLOT(switchPitchUp())); | |
567 connect(this, SIGNAL(canClearSelection(bool)), action, SLOT(setEnabled(bool))); | |
568 menu->addAction(action); | |
569 | |
570 //!!! shortcuts, status tip, key reference etc | |
571 action = new QAction(tr("Pick Lower Pitch Candidate"), this); | |
572 action->setShortcut(tr("Ctrl+Down")); | |
573 connect(action, SIGNAL(triggered()), this, SLOT(switchPitchDown())); | |
574 connect(this, SIGNAL(canClearSelection(bool)), action, SLOT(setEnabled(bool))); | 580 connect(this, SIGNAL(canClearSelection(bool)), action, SLOT(setEnabled(bool))); |
575 menu->addAction(action); | 581 menu->addAction(action); |
576 } | 582 } |
577 | 583 |
578 void | 584 void |
1013 (currentPane != 0); | 1019 (currentPane != 0); |
1014 bool haveCurrentLayer = | 1020 bool haveCurrentLayer = |
1015 (haveCurrentPane && | 1021 (haveCurrentPane && |
1016 (currentLayer != 0)); | 1022 (currentLayer != 0)); |
1017 bool haveSelection = | 1023 bool haveSelection = |
1018 (m_viewManager && | 1024 (m_viewManager && |
1019 !m_viewManager->getSelections().empty()); | 1025 !m_viewManager->getSelections().empty()); |
1020 bool haveCurrentEditableLayer = | 1026 bool haveCurrentEditableLayer = |
1021 (haveCurrentLayer && | 1027 (haveCurrentLayer && |
1022 currentLayer->isLayerEditable()); | 1028 currentLayer->isLayerEditable()); |
1023 bool haveCurrentTimeInstantsLayer = | 1029 bool haveCurrentTimeInstantsLayer = |
1024 (haveCurrentLayer && | 1030 (haveCurrentLayer && |
1025 qobject_cast<TimeInstantLayer *>(currentLayer)); | 1031 qobject_cast<TimeInstantLayer *>(currentLayer)); |
1026 bool haveCurrentTimeValueLayer = | 1032 bool haveCurrentTimeValueLayer = |
1027 (haveCurrentLayer && | 1033 (haveCurrentLayer && |
1028 qobject_cast<TimeValueLayer *>(currentLayer)); | 1034 qobject_cast<TimeValueLayer *>(currentLayer)); |
1035 bool pitchCandidatesVisible = | |
1036 m_analyser->arePitchCandidatesShown(); | |
1029 | 1037 |
1030 emit canChangePlaybackSpeed(true); | 1038 emit canChangePlaybackSpeed(true); |
1031 int v = m_playSpeed->value(); | 1039 int v = m_playSpeed->value(); |
1032 emit canSpeedUpPlayback(v < m_playSpeed->maximum()); | 1040 emit canSpeedUpPlayback(v < m_playSpeed->maximum()); |
1033 emit canSlowDownPlayback(v > m_playSpeed->minimum()); | 1041 emit canSlowDownPlayback(v > m_playSpeed->minimum()); |
1042 | |
1043 emit canChangePitchCandidate(pitchCandidatesVisible && haveSelection); | |
1044 | |
1045 if (pitchCandidatesVisible) { | |
1046 m_showCandidatesAction->setText(tr("Hide Pitch Candidates")); | |
1047 m_showCandidatesAction->setStatusTip(tr("Remove the display of alternate pitch candidates for the selected region")); | |
1048 } else { | |
1049 m_showCandidatesAction->setText(tr("Show Pitch Candidates")); | |
1050 m_showCandidatesAction->setStatusTip(tr("Show alternate pitch candidates for the selected region")); | |
1051 } | |
1034 | 1052 |
1035 if (m_ffwdAction && m_rwdAction) { | 1053 if (m_ffwdAction && m_rwdAction) { |
1036 if (haveCurrentTimeInstantsLayer) { | 1054 if (haveCurrentTimeInstantsLayer) { |
1037 m_ffwdAction->setText(tr("Fast Forward to Next Instant")); | 1055 m_ffwdAction->setText(tr("Fast Forward to Next Instant")); |
1038 m_ffwdAction->setStatusTip(tr("Fast forward to the next time instant in the current layer")); | 1056 m_ffwdAction->setStatusTip(tr("Fast forward to the next time instant in the current layer")); |
1758 cerr << "MainWindow::selectionChanged" << endl; | 1776 cerr << "MainWindow::selectionChanged" << endl; |
1759 | 1777 |
1760 if (!selections.empty()) { | 1778 if (!selections.empty()) { |
1761 Selection sel = *selections.begin(); | 1779 Selection sel = *selections.begin(); |
1762 cerr << "MainWindow::selectionChanged: have selection" << endl; | 1780 cerr << "MainWindow::selectionChanged: have selection" << endl; |
1781 m_analyser->showPitchCandidates(false); | |
1763 QString error = m_analyser->reAnalyseSelection(sel); | 1782 QString error = m_analyser->reAnalyseSelection(sel); |
1764 if (error != "") { | 1783 if (error != "") { |
1765 QMessageBox::critical | 1784 QMessageBox::critical |
1766 (this, tr("Failed to analyse selection"), | 1785 (this, tr("Failed to analyse selection"), |
1767 tr("<b>Analysis failed</b><p>%2</p>").arg(error)); | 1786 tr("<b>Analysis failed</b><p>%2</p>").arg(error)); |
1814 | 1833 |
1815 void | 1834 void |
1816 MainWindow::togglePitchCandidates() | 1835 MainWindow::togglePitchCandidates() |
1817 { | 1836 { |
1818 m_analyser->showPitchCandidates(!m_analyser->arePitchCandidatesShown()); | 1837 m_analyser->showPitchCandidates(!m_analyser->arePitchCandidatesShown()); |
1838 updateMenuStates(); | |
1819 } | 1839 } |
1820 | 1840 |
1821 void | 1841 void |
1822 MainWindow::switchPitchUp() | 1842 MainWindow::switchPitchUp() |
1823 { | 1843 { |