Mercurial > hg > tony
comparison src/MainWindow.cpp @ 238:fce61899aeea
Add Merge Notes
author | Chris Cannam |
---|---|
date | Thu, 27 Mar 2014 16:30:26 +0000 |
parents | 63092d9871f9 |
children | d40c6cdb30a4 |
comparison
equal
deleted
inserted
replaced
237:63092d9871f9 | 238:fce61899aeea |
---|---|
589 m_rightButtonMenu->addAction(action); | 589 m_rightButtonMenu->addAction(action); |
590 | 590 |
591 menu->addSeparator(); | 591 menu->addSeparator(); |
592 m_rightButtonMenu->addSeparator(); | 592 m_rightButtonMenu->addSeparator(); |
593 | 593 |
594 action = new QAction(tr("Snap Notes to Pitch Track"), this); | |
595 action->setShortcut(tr("Ctrl+=")); | |
596 action->setStatusTip(tr("Set all notes within the selected region to have the median frequency of their underlying pitches")); | |
597 m_keyReference->registerShortcut(action); | |
598 connect(action, SIGNAL(triggered()), this, SLOT(snapNotesToPitches())); | |
599 connect(this, SIGNAL(canSnapNotes(bool)), action, SLOT(setEnabled(bool))); | |
600 menu->addAction(action); | |
601 m_rightButtonMenu->addAction(action); | |
602 | |
603 action = new QAction(tr("Split Notes at Selection Boundaries"), this); | 594 action = new QAction(tr("Split Notes at Selection Boundaries"), this); |
604 action->setShortcut(tr("Ctrl+/")); | 595 action->setShortcut(tr("Ctrl+/")); |
605 action->setStatusTip(tr("If any notes overlap the start or end of the selected region, split them at those points")); | 596 action->setStatusTip(tr("If any notes overlap the start or end of the selected region, split them at those points")); |
606 m_keyReference->registerShortcut(action); | 597 m_keyReference->registerShortcut(action); |
607 connect(action, SIGNAL(triggered()), this, SLOT(splitNotesAtSelection())); | 598 connect(action, SIGNAL(triggered()), this, SLOT(splitNotesAtSelection())); |
608 connect(this, SIGNAL(canSnapNotes(bool)), action, SLOT(setEnabled(bool))); | 599 connect(this, SIGNAL(canSnapNotes(bool)), action, SLOT(setEnabled(bool))); |
609 menu->addAction(action); | 600 menu->addAction(action); |
610 m_rightButtonMenu->addAction(action); | 601 m_rightButtonMenu->addAction(action); |
602 | |
603 action = new QAction(tr("Merge Notes"), this); | |
604 action->setShortcut(tr("Ctrl+.")); | |
605 action->setStatusTip(tr("Merge all notes within the selected region into a single note")); | |
606 m_keyReference->registerShortcut(action); | |
607 connect(action, SIGNAL(triggered()), this, SLOT(mergeNotes())); | |
608 connect(this, SIGNAL(canSnapNotes(bool)), action, SLOT(setEnabled(bool))); | |
609 menu->addAction(action); | |
610 m_rightButtonMenu->addAction(action); | |
611 | |
612 action = new QAction(tr("Snap Notes to Pitch Track"), this); | |
613 action->setShortcut(tr("Ctrl+=")); | |
614 action->setStatusTip(tr("Set notes within the selected region to the median frequency of their underlying pitches, or remove them if there are no underlying pitches")); | |
615 m_keyReference->registerShortcut(action); | |
616 connect(action, SIGNAL(triggered()), this, SLOT(snapNotesToPitches())); | |
617 connect(this, SIGNAL(canSnapNotes(bool)), action, SLOT(setEnabled(bool))); | |
618 menu->addAction(action); | |
619 m_rightButtonMenu->addAction(action); | |
620 | |
611 } | 621 } |
612 | 622 |
613 void | 623 void |
614 MainWindow::setupViewMenu() | 624 MainWindow::setupViewMenu() |
615 { | 625 { |
2092 CommandHistory::getInstance()->endCompoundOperation(); | 2102 CommandHistory::getInstance()->endCompoundOperation(); |
2093 } | 2103 } |
2094 } | 2104 } |
2095 | 2105 |
2096 void | 2106 void |
2107 MainWindow::mergeNotes() | |
2108 { | |
2109 FlexiNoteLayer *layer = | |
2110 qobject_cast<FlexiNoteLayer *>(m_analyser->getLayer(Analyser::Notes)); | |
2111 if (!layer) return; | |
2112 | |
2113 MultiSelection::SelectionList selections = m_viewManager->getSelections(); | |
2114 | |
2115 if (!selections.empty()) { | |
2116 | |
2117 CommandHistory::getInstance()->startCompoundOperation | |
2118 (tr("Merge Notes"), true); | |
2119 | |
2120 for (MultiSelection::SelectionList::iterator k = selections.begin(); | |
2121 k != selections.end(); ++k) { | |
2122 layer->mergeNotes(m_analyser->getPane(), *k); | |
2123 } | |
2124 | |
2125 CommandHistory::getInstance()->endCompoundOperation(); | |
2126 } | |
2127 } | |
2128 | |
2129 void | |
2097 MainWindow::playSpeedChanged(int position) | 2130 MainWindow::playSpeedChanged(int position) |
2098 { | 2131 { |
2099 PlaySpeedRangeMapper mapper(0, 200); | 2132 PlaySpeedRangeMapper mapper(0, 200); |
2100 | 2133 |
2101 float percent = m_playSpeed->mappedValue(); | 2134 float percent = m_playSpeed->mappedValue(); |