comparison src/MainWindow.cpp @ 211:e79f63161b41

Rework key shortcuts after issue #890: merge the octave up/down and candidate up/down functions and make all Tony pitch-editing functions have Ctrl modifier
author Chris Cannam
date Thu, 06 Mar 2014 14:31:04 +0000
parents 40e6ba379f2c
children d66256e86f79
comparison
equal deleted inserted replaced
210:86bc160075c7 211:e79f63161b41
530 m_keyReference->registerShortcut(action); 530 m_keyReference->registerShortcut(action);
531 menu->addAction(action); 531 menu->addAction(action);
532 m_rightButtonMenu->addAction(action); 532 m_rightButtonMenu->addAction(action);
533 533
534 action = new QAction(tr("C&lear Selection"), this); 534 action = new QAction(tr("C&lear Selection"), this);
535 action->setShortcut(tr("Esc")); 535 action->setShortcuts(QList<QKeySequence>()
536 action->setStatusTip(tr("Clear the selection")); 536 << QKeySequence(tr("Esc"))
537 << QKeySequence(tr("Ctrl+Esc")));
538 action->setStatusTip(tr("Clear the selection and abandon any pending pitch choices in it"));
537 connect(action, SIGNAL(triggered()), this, SLOT(abandonSelection())); 539 connect(action, SIGNAL(triggered()), this, SLOT(abandonSelection()));
538 connect(this, SIGNAL(canClearSelection(bool)), action, SLOT(setEnabled(bool))); 540 connect(this, SIGNAL(canClearSelection(bool)), action, SLOT(setEnabled(bool)));
539 m_keyReference->registerShortcut(action); 541 m_keyReference->registerShortcut(action);
542 m_keyReference->registerAlternativeShortcut(action, QKeySequence(tr("Ctrl+Esc")));
540 menu->addAction(action); 543 menu->addAction(action);
541 m_rightButtonMenu->addAction(action); 544 m_rightButtonMenu->addAction(action);
542 545
543 menu->addSeparator(); 546 menu->addSeparator();
544 m_rightButtonMenu->addSeparator(); 547 m_rightButtonMenu->addSeparator();
545 548
546 m_keyReference->setCategory(tr("Pitch Track")); 549 m_keyReference->setCategory(tr("Pitch Track"));
550
551 action = new QAction(tr("Choose Higher Pitch"), this);
552 action->setShortcut(tr("Ctrl+Up"));
553 action->setStatusTip(tr("Move pitches up an octave, or to the next higher pitch candidate"));
554 m_keyReference->registerShortcut(action);
555 connect(action, SIGNAL(triggered()), this, SLOT(switchPitchUp()));
556 connect(this, SIGNAL(canClearSelection(bool)), action, SLOT(setEnabled(bool)));
557 menu->addAction(action);
558 m_rightButtonMenu->addAction(action);
559
560 action = new QAction(tr("Choose Lower Pitch"), this);
561 action->setShortcut(tr("Ctrl+Down"));
562 action->setStatusTip(tr("Move pitches down an octave, or to the next lower pitch candidate"));
563 m_keyReference->registerShortcut(action);
564 connect(action, SIGNAL(triggered()), this, SLOT(switchPitchDown()));
565 connect(this, SIGNAL(canClearSelection(bool)), action, SLOT(setEnabled(bool)));
566 menu->addAction(action);
567 m_rightButtonMenu->addAction(action);
547 568
548 m_showCandidatesAction = new QAction(tr("Show Pitch Candidates"), this); 569 m_showCandidatesAction = new QAction(tr("Show Pitch Candidates"), this);
549 m_showCandidatesAction->setShortcut(tr("Ctrl+Return")); 570 m_showCandidatesAction->setShortcut(tr("Ctrl+Return"));
550 m_showCandidatesAction->setStatusTip(tr("Toggle the display of alternative pitch candidates for the selected region")); 571 m_showCandidatesAction->setStatusTip(tr("Toggle the display of alternative pitch candidates for the selected region"));
551 m_keyReference->registerShortcut(m_showCandidatesAction); 572 m_keyReference->registerShortcut(m_showCandidatesAction);
552 connect(m_showCandidatesAction, SIGNAL(triggered()), this, SLOT(togglePitchCandidates())); 573 connect(m_showCandidatesAction, SIGNAL(triggered()), this, SLOT(togglePitchCandidates()));
553 connect(this, SIGNAL(canClearSelection(bool)), m_showCandidatesAction, SLOT(setEnabled(bool))); 574 connect(this, SIGNAL(canClearSelection(bool)), m_showCandidatesAction, SLOT(setEnabled(bool)));
554 menu->addAction(m_showCandidatesAction); 575 menu->addAction(m_showCandidatesAction);
555 m_rightButtonMenu->addAction(m_showCandidatesAction); 576 m_rightButtonMenu->addAction(m_showCandidatesAction);
556 577
557 action = new QAction(tr("Pick Higher Pitch Candidate"), this);
558 action->setShortcut(tr("Ctrl+Up"));
559 action->setStatusTip(tr("Switch to the next higher pitch candidate in the selected region"));
560 m_keyReference->registerShortcut(action);
561 connect(action, SIGNAL(triggered()), this, SLOT(switchPitchUp()));
562 connect(this, SIGNAL(canChangeToHigherCandidate(bool)), action, SLOT(setEnabled(bool)));
563 menu->addAction(action);
564 m_rightButtonMenu->addAction(action);
565
566 action = new QAction(tr("Pick Lower Pitch Candidate"), this);
567 action->setShortcut(tr("Ctrl+Down"));
568 action->setStatusTip(tr("Switch to the next lower pitch candidate in the selected region"));
569 m_keyReference->registerShortcut(action);
570 connect(action, SIGNAL(triggered()), this, SLOT(switchPitchDown()));
571 connect(this, SIGNAL(canChangeToLowerCandidate(bool)), action, SLOT(setEnabled(bool)));
572 menu->addAction(action);
573 m_rightButtonMenu->addAction(action);
574
575 menu->addSeparator();
576 m_rightButtonMenu->addSeparator();
577
578 action = new QAction(tr("Octave Shift Up"), this);
579 action->setShortcut(tr("PgUp"));
580 action->setStatusTip(tr("Move all pitches up an octave in the selected region"));
581 m_keyReference->registerShortcut(action);
582 connect(action, SIGNAL(triggered()), this, SLOT(octaveShiftUp()));
583 connect(this, SIGNAL(canClearSelection(bool)), action, SLOT(setEnabled(bool)));
584 menu->addAction(action);
585 m_rightButtonMenu->addAction(action);
586
587 action = new QAction(tr("Octave Shift Down"), this);
588 action->setShortcut(tr("PgDown"));
589 action->setStatusTip(tr("Move all pitches down an octave in the selected region"));
590 m_keyReference->registerShortcut(action);
591 connect(action, SIGNAL(triggered()), this, SLOT(octaveShiftDown()));
592 connect(this, SIGNAL(canClearSelection(bool)), action, SLOT(setEnabled(bool)));
593 menu->addAction(action);
594 m_rightButtonMenu->addAction(action);
595
596 menu->addSeparator();
597 m_rightButtonMenu->addSeparator();
598
599 action = new QAction(tr("Remove Pitches"), this); 578 action = new QAction(tr("Remove Pitches"), this);
600 action->setShortcut(tr("Ctrl+Backspace")); 579 action->setShortcut(tr("Ctrl+Backspace"));
601 action->setStatusTip(tr("Remove all pitch estimates within the selected region (converting it to unvoiced)")); 580 action->setStatusTip(tr("Remove all pitch estimates within the selected region, making it unvoiced"));
602 m_keyReference->registerShortcut(action); 581 m_keyReference->registerShortcut(action);
603 connect(action, SIGNAL(triggered()), this, SLOT(clearPitches())); 582 connect(action, SIGNAL(triggered()), this, SLOT(clearPitches()));
604 connect(this, SIGNAL(canClearSelection(bool)), action, SLOT(setEnabled(bool))); 583 connect(this, SIGNAL(canClearSelection(bool)), action, SLOT(setEnabled(bool)));
605 menu->addAction(action); 584 menu->addAction(action);
606 m_rightButtonMenu->addAction(action); 585 m_rightButtonMenu->addAction(action);
1069 emit canChangePlaybackSpeed(true); 1048 emit canChangePlaybackSpeed(true);
1070 int v = m_playSpeed->value(); 1049 int v = m_playSpeed->value();
1071 emit canSpeedUpPlayback(v < m_playSpeed->maximum()); 1050 emit canSpeedUpPlayback(v < m_playSpeed->maximum());
1072 emit canSlowDownPlayback(v > m_playSpeed->minimum()); 1051 emit canSlowDownPlayback(v > m_playSpeed->minimum());
1073 1052
1074 emit canChangePitchCandidate(pitchCandidatesVisible && haveSelection);
1075 emit canChangeToHigherCandidate(pitchCandidatesVisible && haveSelection && haveHigher);
1076 emit canChangeToLowerCandidate(pitchCandidatesVisible && haveSelection && haveLower);
1077
1078 if (pitchCandidatesVisible) { 1053 if (pitchCandidatesVisible) {
1079 m_showCandidatesAction->setText(tr("Hide Pitch Candidates")); 1054 m_showCandidatesAction->setText(tr("Hide Pitch Candidates"));
1080 m_showCandidatesAction->setStatusTip(tr("Remove the display of alternate pitch candidates for the selected region")); 1055 m_showCandidatesAction->setStatusTip(tr("Remove the display of alternate pitch candidates for the selected region"));
1081 } else { 1056 } else {
1082 m_showCandidatesAction->setText(tr("Show Pitch Candidates")); 1057 m_showCandidatesAction->setText(tr("Show Pitch Candidates"));
1883 1858
1884 CommandHistory::getInstance()->endCompoundOperation(); 1859 CommandHistory::getInstance()->endCompoundOperation();
1885 } 1860 }
1886 1861
1887 void 1862 void
1888 MainWindow::octaveShiftUp()
1889 {
1890 octaveShift(true);
1891 }
1892
1893 void
1894 MainWindow::octaveShiftDown()
1895 {
1896 octaveShift(false);
1897 }
1898
1899 void
1900 MainWindow::octaveShift(bool up) 1863 MainWindow::octaveShift(bool up)
1901 { 1864 {
1902 MultiSelection::SelectionList selections = m_viewManager->getSelections(); 1865 MultiSelection::SelectionList selections = m_viewManager->getSelections();
1903 1866
1904 CommandHistory::getInstance()->startCompoundOperation(tr("Octave Shift"), true); 1867 CommandHistory::getInstance()->startCompoundOperation
1868 (up ? tr("Choose Higher Octave") : tr("Choose Lower Octave"), true);
1905 1869
1906 for (MultiSelection::SelectionList::iterator k = selections.begin(); 1870 for (MultiSelection::SelectionList::iterator k = selections.begin();
1907 k != selections.end(); ++k) { 1871 k != selections.end(); ++k) {
1908 1872
1909 m_analyser->shiftOctave(*k, up); 1873 m_analyser->shiftOctave(*k, up);
1925 } 1889 }
1926 1890
1927 void 1891 void
1928 MainWindow::switchPitchUp() 1892 MainWindow::switchPitchUp()
1929 { 1893 {
1930 CommandHistory::getInstance()->startCompoundOperation 1894 if (m_analyser->arePitchCandidatesShown()) {
1931 (tr("Switch Pitch Candidate"), true); 1895 if (m_analyser->haveHigherPitchCandidate()) {
1932 1896
1933 MultiSelection::SelectionList selections = m_viewManager->getSelections(); 1897 CommandHistory::getInstance()->startCompoundOperation
1934 1898 (tr("Choose Higher Pitch Candidate"), true);
1935 for (MultiSelection::SelectionList::iterator k = selections.begin(); 1899
1936 k != selections.end(); ++k) { 1900 MultiSelection::SelectionList selections = m_viewManager->getSelections();
1937 m_analyser->switchPitchCandidate(*k, true); 1901
1938 } 1902 for (MultiSelection::SelectionList::iterator k = selections.begin();
1939 1903 k != selections.end(); ++k) {
1940 CommandHistory::getInstance()->endCompoundOperation(); 1904 m_analyser->switchPitchCandidate(*k, true);
1905 }
1906
1907 CommandHistory::getInstance()->endCompoundOperation();
1908
1909 }
1910 } else {
1911 octaveShift(true);
1912 }
1941 } 1913 }
1942 1914
1943 void 1915 void
1944 MainWindow::switchPitchDown() 1916 MainWindow::switchPitchDown()
1945 { 1917 {
1946 CommandHistory::getInstance()->startCompoundOperation 1918 if (m_analyser->arePitchCandidatesShown()) {
1947 (tr("Switch Pitch Candidate"), true); 1919 if (m_analyser->haveLowerPitchCandidate()) {
1948 1920
1949 MultiSelection::SelectionList selections = m_viewManager->getSelections(); 1921 CommandHistory::getInstance()->startCompoundOperation
1950 1922 (tr("Choose Lower Pitch Candidate"), true);
1951 for (MultiSelection::SelectionList::iterator k = selections.begin(); 1923
1952 k != selections.end(); ++k) { 1924 MultiSelection::SelectionList selections = m_viewManager->getSelections();
1953 m_analyser->switchPitchCandidate(*k, false); 1925
1954 } 1926 for (MultiSelection::SelectionList::iterator k = selections.begin();
1955 1927 k != selections.end(); ++k) {
1956 CommandHistory::getInstance()->endCompoundOperation(); 1928 m_analyser->switchPitchCandidate(*k, false);
1929 }
1930
1931 CommandHistory::getInstance()->endCompoundOperation();
1932 }
1933 } else {
1934 octaveShift(false);
1935 }
1957 } 1936 }
1958 1937
1959 void 1938 void
1960 MainWindow::playSpeedChanged(int position) 1939 MainWindow::playSpeedChanged(int position)
1961 { 1940 {