Mercurial > hg > tony
comparison src/MainWindow.cpp @ 283:604816843bd4
basic selection by one note left/right there, but not quite good yet
author | matthiasm |
---|---|
date | Thu, 22 May 2014 22:21:27 +0100 |
parents | 118775decf28 |
children | 5f06331c8b4f |
comparison
equal
deleted
inserted
replaced
282:118775decf28 | 283:604816843bd4 |
---|---|
610 connect(this, SIGNAL(canSelect(bool)), action, SLOT(setEnabled(bool))); | 610 connect(this, SIGNAL(canSelect(bool)), action, SLOT(setEnabled(bool))); |
611 m_keyReference->registerShortcut(action); | 611 m_keyReference->registerShortcut(action); |
612 menu->addAction(action); | 612 menu->addAction(action); |
613 m_rightButtonMenu->addAction(action); | 613 m_rightButtonMenu->addAction(action); |
614 | 614 |
615 action = new QAction(tr("C&lear Selection"), this); | 615 // action = new QAction(tr("C&lear Selection"), this); |
616 action = toolbar->addAction(il.load("blank-16"), tr("Esc")); | |
616 action->setShortcuts(QList<QKeySequence>() | 617 action->setShortcuts(QList<QKeySequence>() |
617 << QKeySequence(tr("Esc")) | 618 << QKeySequence(tr("Esc")) |
618 << QKeySequence(tr("Ctrl+Esc"))); | 619 << QKeySequence(tr("Ctrl+Esc"))); |
619 action->setStatusTip(tr("Clear the selection and abandon any pending pitch choices in it")); | 620 action->setStatusTip(tr("Clear the selection and abandon any pending pitch choices in it")); |
620 connect(action, SIGNAL(triggered()), this, SLOT(abandonSelection())); | 621 connect(action, SIGNAL(triggered()), this, SLOT(abandonSelection())); |
656 menu->addAction(m_showCandidatesAction); | 657 menu->addAction(m_showCandidatesAction); |
657 m_rightButtonMenu->addAction(m_showCandidatesAction); | 658 m_rightButtonMenu->addAction(m_showCandidatesAction); |
658 | 659 |
659 | 660 |
660 // action = new QAction(tr("Remove Pitches"), this); | 661 // action = new QAction(tr("Remove Pitches"), this); |
661 action = toolbar->addAction(il.load("blank-16"), tr("Remove Pitches")); | 662 action = toolbar->addAction(il.load("blank-16"), tr("Del")); |
662 action->setShortcut(tr("Backspace")); | 663 action->setShortcut(tr("Backspace")); |
663 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")); |
664 m_keyReference->registerShortcut(action); | 665 m_keyReference->registerShortcut(action); |
665 connect(action, SIGNAL(triggered()), this, SLOT(clearPitches())); | 666 connect(action, SIGNAL(triggered()), this, SLOT(clearPitches())); |
666 connect(this, SIGNAL(canClearSelection(bool)), action, SLOT(setEnabled(bool))); | 667 connect(this, SIGNAL(canClearSelection(bool)), action, SLOT(setEnabled(bool))); |
668 m_rightButtonMenu->addAction(action); | 669 m_rightButtonMenu->addAction(action); |
669 | 670 |
670 menu->addSeparator(); | 671 menu->addSeparator(); |
671 m_rightButtonMenu->addSeparator(); | 672 m_rightButtonMenu->addSeparator(); |
672 | 673 |
673 action = new QAction(tr("Split Note"), this); | 674 // action = new QAction(tr("Split Note"), this); |
674 action->setShortcut(tr("Ctrl+/")); | 675 action = toolbar->addAction(il.load("blank-16"), tr("Split")); |
676 action->setShortcut(tr("/")); | |
675 action->setStatusTip(tr("Split the note at the current playback position into two")); | 677 action->setStatusTip(tr("Split the note at the current playback position into two")); |
676 m_keyReference->registerShortcut(action); | 678 m_keyReference->registerShortcut(action); |
677 connect(action, SIGNAL(triggered()), this, SLOT(splitNote())); | 679 connect(action, SIGNAL(triggered()), this, SLOT(splitNote())); |
678 connect(this, SIGNAL(canExportNotes(bool)), action, SLOT(setEnabled(bool))); | 680 connect(this, SIGNAL(canExportNotes(bool)), action, SLOT(setEnabled(bool))); |
679 menu->addAction(action); | 681 menu->addAction(action); |
680 m_rightButtonMenu->addAction(action); | 682 m_rightButtonMenu->addAction(action); |
681 | 683 |
682 action = new QAction(tr("Merge Notes"), this); | 684 // action = new QAction(tr("Merge Notes"), this); |
683 action->setShortcut(tr("Ctrl+\\")); | 685 action = toolbar->addAction(il.load("blank-16"), tr("Merge")); |
686 action->setShortcut(tr("\\")); | |
684 action->setStatusTip(tr("Merge all notes within the selected region into a single note")); | 687 action->setStatusTip(tr("Merge all notes within the selected region into a single note")); |
685 m_keyReference->registerShortcut(action); | 688 m_keyReference->registerShortcut(action); |
686 connect(action, SIGNAL(triggered()), this, SLOT(mergeNotes())); | 689 connect(action, SIGNAL(triggered()), this, SLOT(mergeNotes())); |
687 connect(this, SIGNAL(canSnapNotes(bool)), action, SLOT(setEnabled(bool))); | 690 connect(this, SIGNAL(canSnapNotes(bool)), action, SLOT(setEnabled(bool))); |
688 menu->addAction(action); | 691 menu->addAction(action); |
745 | 748 |
746 action = new QAction(tr("O&ne Note Right"), this); | 749 action = new QAction(tr("O&ne Note Right"), this); |
747 action->setShortcut(tr("Ctrl+Right")); | 750 action->setShortcut(tr("Ctrl+Right")); |
748 action->setStatusTip(tr("Move cursor to the succeeding note (or silence).")); | 751 action->setStatusTip(tr("Move cursor to the succeeding note (or silence).")); |
749 connect(action, SIGNAL(triggered()), this, SLOT(moveOneNoteRight())); | 752 connect(action, SIGNAL(triggered()), this, SLOT(moveOneNoteRight())); |
753 connect(this, SIGNAL(canScroll(bool)), action, SLOT(setEnabled(bool))); | |
754 m_keyReference->registerShortcut(action); | |
755 menu->addAction(action); | |
756 | |
757 action = new QAction(tr("&Select One Note Left"), this); | |
758 action->setShortcut(tr("Ctrl+Shift+Left")); | |
759 action->setStatusTip(tr("Select to the preceding note (or silence) onset.")); | |
760 connect(action, SIGNAL(triggered()), this, SLOT(selectOneNoteLeft())); | |
761 connect(this, SIGNAL(canScroll(bool)), action, SLOT(setEnabled(bool))); | |
762 m_keyReference->registerShortcut(action); | |
763 menu->addAction(action); | |
764 | |
765 action = new QAction(tr("S&elect One Note Right"), this); | |
766 action->setShortcut(tr("Ctrl+Shift+Right")); | |
767 action->setStatusTip(tr("Select to the succeeding note (or silence).")); | |
768 connect(action, SIGNAL(triggered()), this, SLOT(selectOneNoteRight())); | |
750 connect(this, SIGNAL(canScroll(bool)), action, SLOT(setEnabled(bool))); | 769 connect(this, SIGNAL(canScroll(bool)), action, SLOT(setEnabled(bool))); |
751 m_keyReference->registerShortcut(action); | 770 m_keyReference->registerShortcut(action); |
752 menu->addAction(action); | 771 menu->addAction(action); |
753 | 772 |
754 menu->addSeparator(); | 773 menu->addSeparator(); |
1135 MainWindow::moveOneNoteLeft() | 1154 MainWindow::moveOneNoteLeft() |
1136 { | 1155 { |
1137 // cerr << "MainWindow::moveOneNoteLeft" << endl; | 1156 // cerr << "MainWindow::moveOneNoteLeft" << endl; |
1138 moveByOneNote(false); | 1157 moveByOneNote(false); |
1139 } | 1158 } |
1159 | |
1160 void | |
1161 MainWindow::selectOneNoteRight() | |
1162 { | |
1163 int frame0 = m_viewManager->getPlaybackFrame(); | |
1164 Selection origSel = *(m_viewManager->getSelections().begin()); | |
1165 if (origSel.getEndFrame() == frame0) | |
1166 { | |
1167 frame0 = origSel.getStartFrame(); // extending origSel | |
1168 } | |
1169 moveByOneNote(true); | |
1170 int frame1 = m_viewManager->getPlaybackFrame(); | |
1171 Selection sel(frame0, frame1); | |
1172 if (sel.isEmpty()) return; | |
1173 m_viewManager->setSelection(sel); | |
1174 } | |
1175 | |
1176 void | |
1177 MainWindow::selectOneNoteLeft() | |
1178 { | |
1179 int frame1 = m_viewManager->getPlaybackFrame(); | |
1180 Selection origSel = *(m_viewManager->getSelections().begin()); | |
1181 if (origSel.getStartFrame() == frame1) | |
1182 { | |
1183 frame1 = origSel.getEndFrame(); // extending origSel | |
1184 } | |
1185 moveByOneNote(false); | |
1186 int frame0 = m_viewManager->getPlaybackFrame(); | |
1187 Selection sel(frame0, frame1); | |
1188 if (sel.isEmpty()) return; | |
1189 m_viewManager->setSelection(sel); | |
1190 } | |
1191 | |
1140 | 1192 |
1141 void | 1193 void |
1142 MainWindow::moveByOneNote(bool right) | 1194 MainWindow::moveByOneNote(bool right) |
1143 { | 1195 { |
1144 // cerr << "MainWindow::moveByOneNote" << endl; | 1196 // cerr << "MainWindow::moveByOneNote" << endl; |