comparison src/MainWindow.cpp @ 306:6c5df12a08da

Merge
author Chris Cannam
date Thu, 12 Jun 2014 17:23:23 +0100
parents 528d207fd661
children 6045288159e9
comparison
equal deleted inserted replaced
305:7777fa612a16 306:6c5df12a08da
658 connect(this, SIGNAL(canClearSelection(bool)), m_showCandidatesAction, SLOT(setEnabled(bool))); 658 connect(this, SIGNAL(canClearSelection(bool)), m_showCandidatesAction, SLOT(setEnabled(bool)));
659 menu->addAction(m_showCandidatesAction); 659 menu->addAction(m_showCandidatesAction);
660 m_rightButtonMenu->addAction(m_showCandidatesAction); 660 m_rightButtonMenu->addAction(m_showCandidatesAction);
661 661
662 action = new QAction(tr("Remove Pitches"), this); 662 action = new QAction(tr("Remove Pitches"), this);
663 //!!! NB this keyboard shortcut does not work with Qt5 on OS/X
664 //!!! (none of the single-key shortcuts do). But it does work if
665 //!!! the action is added to a toolbar button:
666 // action = toolbar->addAction(il.load("editdelete"), tr("Remove Pitches"));
667 action->setShortcut(tr("Backspace")); 663 action->setShortcut(tr("Backspace"));
668 action->setStatusTip(tr("Remove all pitch estimates within the selected region, making it unvoiced")); 664 action->setStatusTip(tr("Remove all pitch estimates within the selected region, making it unvoiced"));
669 m_keyReference->registerShortcut(action); 665 m_keyReference->registerShortcut(action);
670 connect(action, SIGNAL(triggered()), this, SLOT(clearPitches())); 666 connect(action, SIGNAL(triggered()), this, SLOT(clearPitches()));
671 connect(this, SIGNAL(canClearSelection(bool)), action, SLOT(setEnabled(bool))); 667 connect(this, SIGNAL(canClearSelection(bool)), action, SLOT(setEnabled(bool)));
731 727
732 m_keyReference->setCategory(tr("Panning and Navigation")); 728 m_keyReference->setCategory(tr("Panning and Navigation"));
733 729
734 QMenu *menu = menuBar()->addMenu(tr("&View")); 730 QMenu *menu = menuBar()->addMenu(tr("&View"));
735 menu->setTearOffEnabled(true); 731 menu->setTearOffEnabled(true);
736 action = new QAction(tr("Scroll &Left"), this); 732 action = new QAction(tr("Peek &Left"), this);
737 action->setShortcut(tr("Left")); 733 action->setShortcut(tr("Alt+Left"));
738 action->setStatusTip(tr("Scroll the current pane to the left")); 734 action->setStatusTip(tr("Scroll the current pane to the left without changing the play position"));
739 connect(action, SIGNAL(triggered()), this, SLOT(scrollLeft())); 735 connect(action, SIGNAL(triggered()), this, SLOT(scrollLeft()));
740 connect(this, SIGNAL(canScroll(bool)), action, SLOT(setEnabled(bool))); 736 connect(this, SIGNAL(canScroll(bool)), action, SLOT(setEnabled(bool)));
741 m_keyReference->registerShortcut(action); 737 m_keyReference->registerShortcut(action);
742 menu->addAction(action); 738 menu->addAction(action);
743 739
744 action = new QAction(tr("Scroll &Right"), this); 740 action = new QAction(tr("Peek &Right"), this);
745 action->setShortcut(tr("Right")); 741 action->setShortcut(tr("Alt+Right"));
746 action->setStatusTip(tr("Scroll the current pane to the right")); 742 action->setStatusTip(tr("Scroll the current pane to the right without changing the play position"));
747 connect(action, SIGNAL(triggered()), this, SLOT(scrollRight())); 743 connect(action, SIGNAL(triggered()), this, SLOT(scrollRight()));
748 connect(this, SIGNAL(canScroll(bool)), action, SLOT(setEnabled(bool)));
749 m_keyReference->registerShortcut(action);
750 menu->addAction(action);
751
752 action = new QAction(tr("&One Note Left"), this);
753 action->setShortcut(tr("Ctrl+Left"));
754 action->setStatusTip(tr("Move cursor to the preceding note (or silence) onset."));
755 connect(action, SIGNAL(triggered()), this, SLOT(moveOneNoteLeft()));
756 connect(this, SIGNAL(canScroll(bool)), action, SLOT(setEnabled(bool)));
757 m_keyReference->registerShortcut(action);
758 menu->addAction(action);
759
760 action = new QAction(tr("O&ne Note Right"), this);
761 action->setShortcut(tr("Ctrl+Right"));
762 action->setStatusTip(tr("Move cursor to the succeeding note (or silence)."));
763 connect(action, SIGNAL(triggered()), this, SLOT(moveOneNoteRight()));
764 connect(this, SIGNAL(canScroll(bool)), action, SLOT(setEnabled(bool)));
765 m_keyReference->registerShortcut(action);
766 menu->addAction(action);
767
768 action = new QAction(tr("&Select One Note Left"), this);
769 action->setShortcut(tr("Ctrl+Shift+Left"));
770 action->setStatusTip(tr("Select to the preceding note (or silence) onset."));
771 connect(action, SIGNAL(triggered()), this, SLOT(selectOneNoteLeft()));
772 connect(this, SIGNAL(canScroll(bool)), action, SLOT(setEnabled(bool)));
773 m_keyReference->registerShortcut(action);
774 menu->addAction(action);
775
776 action = new QAction(tr("S&elect One Note Right"), this);
777 action->setShortcut(tr("Ctrl+Shift+Right"));
778 action->setStatusTip(tr("Select to the succeeding note (or silence)."));
779 connect(action, SIGNAL(triggered()), this, SLOT(selectOneNoteRight()));
780 connect(this, SIGNAL(canScroll(bool)), action, SLOT(setEnabled(bool))); 744 connect(this, SIGNAL(canScroll(bool)), action, SLOT(setEnabled(bool)));
781 m_keyReference->registerShortcut(action); 745 m_keyReference->registerShortcut(action);
782 menu->addAction(action); 746 menu->addAction(action);
783 747
784 menu->addSeparator(); 748 menu->addSeparator();
904 connect(rwdStartAction, SIGNAL(triggered()), this, SLOT(rewindStart())); 868 connect(rwdStartAction, SIGNAL(triggered()), this, SLOT(rewindStart()));
905 connect(this, SIGNAL(canPlay(bool)), rwdStartAction, SLOT(setEnabled(bool))); 869 connect(this, SIGNAL(canPlay(bool)), rwdStartAction, SLOT(setEnabled(bool)));
906 870
907 QAction *m_rwdAction = toolbar->addAction(il.load("rewind"), 871 QAction *m_rwdAction = toolbar->addAction(il.load("rewind"),
908 tr("Rewind")); 872 tr("Rewind"));
909 m_rwdAction->setStatusTip(tr("Rewind to the previous time instant or time ruler notch")); 873 m_rwdAction->setShortcut(tr("Left"));
874 m_rwdAction->setStatusTip(tr("Rewind to the previous one-second boundary"));
910 connect(m_rwdAction, SIGNAL(triggered()), this, SLOT(rewind())); 875 connect(m_rwdAction, SIGNAL(triggered()), this, SLOT(rewind()));
911 connect(this, SIGNAL(canRewind(bool)), m_rwdAction, SLOT(setEnabled(bool))); 876 connect(this, SIGNAL(canRewind(bool)), m_rwdAction, SLOT(setEnabled(bool)));
877
878 setDefaultFfwdRwdStep(RealTime(1, 0));
912 879
913 QAction *playAction = toolbar->addAction(il.load("playpause"), 880 QAction *playAction = toolbar->addAction(il.load("playpause"),
914 tr("Play / Pause")); 881 tr("Play / Pause"));
915 playAction->setCheckable(true); 882 playAction->setCheckable(true);
916 playAction->setShortcut(tr("Space")); 883 playAction->setShortcut(tr("Space"));
920 playAction, SLOT(setChecked(bool))); 887 playAction, SLOT(setChecked(bool)));
921 connect(this, SIGNAL(canPlay(bool)), playAction, SLOT(setEnabled(bool))); 888 connect(this, SIGNAL(canPlay(bool)), playAction, SLOT(setEnabled(bool)));
922 889
923 m_ffwdAction = toolbar->addAction(il.load("ffwd"), 890 m_ffwdAction = toolbar->addAction(il.load("ffwd"),
924 tr("Fast Forward")); 891 tr("Fast Forward"));
925 m_ffwdAction->setStatusTip(tr("Fast-forward to the next time instant or time ruler notch")); 892 m_ffwdAction->setShortcut(tr("Right"));
893 m_ffwdAction->setStatusTip(tr("Fast-forward to the next one-second boundary"));
926 connect(m_ffwdAction, SIGNAL(triggered()), this, SLOT(ffwd())); 894 connect(m_ffwdAction, SIGNAL(triggered()), this, SLOT(ffwd()));
927 connect(this, SIGNAL(canFfwd(bool)), m_ffwdAction, SLOT(setEnabled(bool))); 895 connect(this, SIGNAL(canFfwd(bool)), m_ffwdAction, SLOT(setEnabled(bool)));
928 896
929 QAction *ffwdEndAction = toolbar->addAction(il.load("ffwd-end"), 897 QAction *ffwdEndAction = toolbar->addAction(il.load("ffwd-end"),
930 tr("Fast Forward to End")); 898 tr("Fast Forward to End"));
955 connect(m_viewManager, SIGNAL(playLoopModeChanged(bool)), 923 connect(m_viewManager, SIGNAL(playLoopModeChanged(bool)),
956 plAction, SLOT(setChecked(bool))); 924 plAction, SLOT(setChecked(bool)));
957 connect(plAction, SIGNAL(triggered()), this, SLOT(playLoopToggled())); 925 connect(plAction, SIGNAL(triggered()), this, SLOT(playLoopToggled()));
958 connect(this, SIGNAL(canPlay(bool)), plAction, SLOT(setEnabled(bool))); 926 connect(this, SIGNAL(canPlay(bool)), plAction, SLOT(setEnabled(bool)));
959 927
928 QAction *oneLeftAction = new QAction(tr("&One Note Left"), this);
929 oneLeftAction->setShortcut(tr("Ctrl+Left"));
930 oneLeftAction->setStatusTip(tr("Move cursor to the preceding note (or silence) onset."));
931 connect(oneLeftAction, SIGNAL(triggered()), this, SLOT(moveOneNoteLeft()));
932 connect(this, SIGNAL(canScroll(bool)), oneLeftAction, SLOT(setEnabled(bool)));
933
934 QAction *oneRightAction = new QAction(tr("O&ne Note Right"), this);
935 oneRightAction->setShortcut(tr("Ctrl+Right"));
936 oneRightAction->setStatusTip(tr("Move cursor to the succeeding note (or silence)."));
937 connect(oneRightAction, SIGNAL(triggered()), this, SLOT(moveOneNoteRight()));
938 connect(this, SIGNAL(canScroll(bool)), oneRightAction, SLOT(setEnabled(bool)));
939
940 QAction *selectOneLeftAction = new QAction(tr("&Select One Note Left"), this);
941 selectOneLeftAction->setShortcut(tr("Ctrl+Shift+Left"));
942 selectOneLeftAction->setStatusTip(tr("Select to the preceding note (or silence) onset."));
943 connect(selectOneLeftAction, SIGNAL(triggered()), this, SLOT(selectOneNoteLeft()));
944 connect(this, SIGNAL(canScroll(bool)), selectOneLeftAction, SLOT(setEnabled(bool)));
945
946 QAction *selectOneRightAction = new QAction(tr("S&elect One Note Right"), this);
947 selectOneRightAction->setShortcut(tr("Ctrl+Shift+Right"));
948 selectOneRightAction->setStatusTip(tr("Select to the succeeding note (or silence)."));
949 connect(selectOneRightAction, SIGNAL(triggered()), this, SLOT(selectOneNoteRight()));
950 connect(this, SIGNAL(canScroll(bool)), selectOneRightAction, SLOT(setEnabled(bool)));
951
960 m_keyReference->registerShortcut(psAction); 952 m_keyReference->registerShortcut(psAction);
961 m_keyReference->registerShortcut(plAction); 953 m_keyReference->registerShortcut(plAction);
962 m_keyReference->registerShortcut(playAction); 954 m_keyReference->registerShortcut(playAction);
963 m_keyReference->registerShortcut(m_rwdAction); 955 m_keyReference->registerShortcut(m_rwdAction);
964 m_keyReference->registerShortcut(m_ffwdAction); 956 m_keyReference->registerShortcut(m_ffwdAction);
965 m_keyReference->registerShortcut(rwdStartAction); 957 m_keyReference->registerShortcut(rwdStartAction);
966 m_keyReference->registerShortcut(ffwdEndAction); 958 m_keyReference->registerShortcut(ffwdEndAction);
959 m_keyReference->registerShortcut(oneLeftAction);
960 m_keyReference->registerShortcut(oneRightAction);
961 m_keyReference->registerShortcut(selectOneLeftAction);
962 m_keyReference->registerShortcut(selectOneRightAction);
967 963
968 menu->addAction(playAction); 964 menu->addAction(playAction);
969 menu->addAction(psAction); 965 menu->addAction(psAction);
970 menu->addAction(plAction); 966 menu->addAction(plAction);
971 menu->addSeparator(); 967 menu->addSeparator();
973 menu->addAction(m_ffwdAction); 969 menu->addAction(m_ffwdAction);
974 menu->addSeparator(); 970 menu->addSeparator();
975 menu->addAction(rwdStartAction); 971 menu->addAction(rwdStartAction);
976 menu->addAction(ffwdEndAction); 972 menu->addAction(ffwdEndAction);
977 menu->addSeparator(); 973 menu->addSeparator();
974 menu->addAction(oneLeftAction);
975 menu->addAction(oneRightAction);
976 menu->addAction(selectOneLeftAction);
977 menu->addAction(selectOneRightAction);
978 menu->addSeparator();
978 979
979 m_rightButtonPlaybackMenu->addAction(playAction); 980 m_rightButtonPlaybackMenu->addAction(playAction);
980 m_rightButtonPlaybackMenu->addAction(psAction); 981 m_rightButtonPlaybackMenu->addAction(psAction);
981 m_rightButtonPlaybackMenu->addAction(plAction); 982 m_rightButtonPlaybackMenu->addAction(plAction);
982 m_rightButtonPlaybackMenu->addSeparator(); 983 m_rightButtonPlaybackMenu->addSeparator();
983 m_rightButtonPlaybackMenu->addAction(m_rwdAction); 984 m_rightButtonPlaybackMenu->addAction(m_rwdAction);
984 m_rightButtonPlaybackMenu->addAction(m_ffwdAction); 985 m_rightButtonPlaybackMenu->addAction(m_ffwdAction);
985 m_rightButtonPlaybackMenu->addSeparator(); 986 m_rightButtonPlaybackMenu->addSeparator();
986 m_rightButtonPlaybackMenu->addAction(rwdStartAction); 987 m_rightButtonPlaybackMenu->addAction(rwdStartAction);
987 m_rightButtonPlaybackMenu->addAction(ffwdEndAction); 988 m_rightButtonPlaybackMenu->addAction(ffwdEndAction);
989 m_rightButtonPlaybackMenu->addSeparator();
990 m_rightButtonPlaybackMenu->addAction(oneLeftAction);
991 m_rightButtonPlaybackMenu->addAction(oneRightAction);
992 m_rightButtonPlaybackMenu->addAction(selectOneLeftAction);
993 m_rightButtonPlaybackMenu->addAction(selectOneRightAction);
988 m_rightButtonPlaybackMenu->addSeparator(); 994 m_rightButtonPlaybackMenu->addSeparator();
989 995
990 QAction *fastAction = menu->addAction(tr("Speed Up")); 996 QAction *fastAction = menu->addAction(tr("Speed Up"));
991 fastAction->setShortcut(tr("Ctrl+PgUp")); 997 fastAction->setShortcut(tr("Ctrl+PgUp"));
992 fastAction->setStatusTip(tr("Time-stretch playback to speed it up without changing pitch")); 998 fastAction->setStatusTip(tr("Time-stretch playback to speed it up without changing pitch"));
1113 1119
1114 1120
1115 void 1121 void
1116 MainWindow::moveByOneNote(bool right, bool doSelect) 1122 MainWindow::moveByOneNote(bool right, bool doSelect)
1117 { 1123 {
1118 // cerr << "MainWindow::moveByOneNote" << endl;
1119 int frame = m_viewManager->getPlaybackFrame(); 1124 int frame = m_viewManager->getPlaybackFrame();
1125 cerr << "MainWindow::moveByOneNote startframe: " << frame << endl;
1120 1126
1121 Pane *p = m_analyser->getPane(); 1127 Pane *p = m_analyser->getPane();
1122 1128
1123 if (!doSelect) { 1129 if (!doSelect) {
1124 m_selectionAnchor = frame; 1130 m_selectionAnchor = frame;
1164 } else { 1170 } else {
1165 sel = Selection(frame, m_selectionAnchor); 1171 sel = Selection(frame, m_selectionAnchor);
1166 } 1172 }
1167 m_viewManager->setSelection(sel); 1173 m_viewManager->setSelection(sel);
1168 } 1174 }
1175 cerr << "MainWindow::moveByOneNote endframe: " << frame << endl;
1169 } 1176 }
1170 1177
1171 void 1178 void
1172 MainWindow::toolNavigateSelected() 1179 MainWindow::toolNavigateSelected()
1173 { 1180 {