📄 editview.cpp
字号:
c = dynamic_cast<SoftSynthDevice *>(getCurrentDevice()); if (!c) return ; } const ControlList &list = c->getControlParameters(); int i = 0; QString itemStr; for (ControlList::const_iterator it = list.begin(); it != list.end(); ++it) { if (it->getType() == Controller::EventType) { QString hexValue; hexValue.sprintf("(0x%x)", it->getControllerValue()); itemStr = i18n("%1 Controller %2 %3").arg(strtoqstr(it->getName())) .arg(it->getControllerValue()) .arg(hexValue); } else if (it->getType() == PitchBend::EventType) itemStr = i18n("Pitch Bend"); else itemStr = i18n("Unsupported Event Type"); addControlRulerMenu->insertItem(itemStr, i++); } connect(addControlRulerMenu, SIGNAL(activated(int)), SLOT(slotAddControlRuler(int))); }}boolEditView::setupControllerTabs(){ bool have = false; // Setup control rulers the Segment already has some stored against it. // Segment *segment = getCurrentSegment(); Segment::EventRulerList list = segment->getEventRulerList(); RG_DEBUG << "EditView::setupControllerTabs - got " << list.size() << " EventRulers" << endl; RG_DEBUG << "Segment view features: " << segment->getViewFeatures() << endl; if (segment->getViewFeatures() & FeatureShowVelocity) { showPropertyControlRuler(BaseProperties::VELOCITY); have = true; } if (list.size()) { Controllable *c = dynamic_cast<MidiDevice *>(getCurrentDevice()); if (!c) { c = dynamic_cast<SoftSynthDevice *>(getCurrentDevice()); if (!c) return have; } have = true; Segment::EventRulerListIterator it; for (it = list.begin(); it != list.end(); ++it) { // Get ControlParameter object from controller value // const ControlParameter *controlParameter = c->getControlParameter((*it)->m_type, MidiByte((*it)->m_controllerValue)); RG_DEBUG << "EditView::setupControllerTabs - " << "Control Parameter type = " << (*it)->m_type << endl; if (controlParameter) { ControllerEventsRuler* controlRuler = makeControllerEventRuler(controlParameter); addControlRuler(controlRuler); RG_DEBUG << "EditView::setupControllerTabs - adding Ruler" << endl; } } if (!m_controlRulers->isVisible()) m_controlRulers->show(); updateBottomWidgetGeometry(); } return have;}voidEditView::slotAddControlRuler(int controller){ RG_DEBUG << "EditView::slotAddControlRuler - item = " << controller << endl; Controllable *c = dynamic_cast<MidiDevice *>(getCurrentDevice()); if (!c) { c = dynamic_cast<SoftSynthDevice *>(getCurrentDevice()); if (!c) return ; } const ControlList &list = c->getControlParameters(); ControlParameter control = list[controller]; int index = 0; ControlRuler* existingRuler = findRuler(control, index); if (existingRuler) { m_controlRulers->setCurrentPage(index); } else { // Create control ruler to a specific controller. This duplicates // the control parameter in the supplied pointer. ControllerEventsRuler* controlRuler = makeControllerEventRuler(&control); addControlRuler(controlRuler); } if (!m_controlRulers->isVisible()) { m_controlRulers->show(); } updateBottomWidgetGeometry(); // Add the controller to the segment so the views can // remember what we've opened against it. // Staff *staff = getCurrentStaff(); staff->getSegment().addEventRuler(control.getType(), control.getControllerValue()); getDocument()->slotDocumentModified();}void EditView::slotRemoveControlRuler(QWidget* w){ ControllerEventsRuler* ruler = dynamic_cast<ControllerEventsRuler*>(w); if (ruler) { ControlParameter *controller = ruler->getControlParameter(); // remove the control parameter from the "showing controllers" list on the segment // if (controller) { Staff *staff = getCurrentStaff(); bool value = staff->getSegment(). deleteEventRuler(controller->getType(), controller->getControllerValue()); if (value) RG_DEBUG << "slotRemoveControlRuler : removed controller from segment\n"; else RG_DEBUG << "slotRemoveControlRuler : couldn't remove controller from segment - " << int(controller->getControllerValue()) << endl; } } else { // else it's probably a velocity ruler PropertyControlRuler *propertyRuler = dynamic_cast<PropertyControlRuler*>(w); if (propertyRuler) { Segment &seg = getCurrentStaff()->getSegment(); seg.setViewFeatures(0); // for the moment we only have one view feature so // we can just blank it out RG_DEBUG << "slotRemoveControlRuler : removed velocity ruler" << endl; } } delete w; if (m_controlRulers->count() == 0) { m_controlRulers->hide(); updateBottomWidgetGeometry(); } getDocument()->slotDocumentModified();}voidEditView::createInsertPitchActionMenu(){ QString notePitchNames[] = { i18n("I"), i18n("II"), i18n("III"), i18n("IV"), i18n("V"), i18n("VI"), i18n("VII"), i18n("VIII") }; QString flat = i18n("%1 flat"); QString sharp = i18n("%1 sharp"); const Key notePitchKeys[3][7] = { { Key_A, Key_S, Key_D, Key_F, Key_J, Key_K, Key_L, }, { Key_Q, Key_W, Key_E, Key_R, Key_U, Key_I, Key_O, }, { Key_Z, Key_X, Key_C, Key_V, Key_B, Key_N, Key_M, }, }; KActionMenu *insertPitchActionMenu = new KActionMenu(i18n("&Insert Note"), this, "insert_note_actionmenu"); for (int octave = 0; octave <= 2; ++octave) { KActionMenu *menu = insertPitchActionMenu; if (octave == 1) { menu = new KActionMenu(i18n("&Upper Octave"), this, "insert_note_actionmenu_upper_octave"); insertPitchActionMenu->insert(new KActionSeparator(this)); insertPitchActionMenu->insert(menu); } else if (octave == 2) { menu = new KActionMenu(i18n("&Lower Octave"), this, "insert_note_actionmenu_lower_octave"); insertPitchActionMenu->insert(menu); } for (unsigned int i = 0; i < 7; ++i) { KAction *insertPitchAction = 0; QString octaveSuffix; if (octave == 1) octaveSuffix = "_high"; else if (octave == 2) octaveSuffix = "_low"; // do and fa lack a flat if (i != 0 && i != 3) { insertPitchAction = new KAction (flat.arg(notePitchNames[i]), CTRL + SHIFT + notePitchKeys[octave][i], this, SLOT(slotInsertNoteFromAction()), actionCollection(), QString("insert_%1_flat%2").arg(i).arg(octaveSuffix)); menu->insert(insertPitchAction); } insertPitchAction = new KAction (notePitchNames[i], notePitchKeys[octave][i], this, SLOT(slotInsertNoteFromAction()), actionCollection(), QString("insert_%1%2").arg(i).arg(octaveSuffix)); menu->insert(insertPitchAction); // and mi and ti lack a sharp if (i != 2 && i != 6) { insertPitchAction = new KAction (sharp.arg(notePitchNames[i]), SHIFT + notePitchKeys[octave][i], this, SLOT(slotInsertNoteFromAction()), actionCollection(), QString("insert_%1_sharp%2").arg(i).arg(octaveSuffix)); menu->insert(insertPitchAction); } if (i < 6) menu->insert(new KActionSeparator(this)); } } actionCollection()->insert(insertPitchActionMenu);}intEditView::getPitchFromNoteInsertAction(QString name, Accidental &accidental, const Clef &clef, const ::Rosegarden::Key &key){ using namespace Accidentals; accidental = NoAccidental; if (name.left(7) == "insert_") { name = name.right(name.length() - 7); int modify = 0; int octave = 0; if (name.right(5) == "_high") { octave = 1; name = name.left(name.length() - 5); } else if (name.right(4) == "_low") { octave = -1; name = name.left(name.length() - 4); } if (name.right(6) == "_sharp") { modify = 1; accidental = Sharp; name = name.left(name.length() - 6); } else if (name.right(5) == "_flat") { modify = -1; accidental = Flat; name = name.left(name.length() - 5); } int scalePitch = name.toInt(); if (scalePitch < 0 || scalePitch > 7) { NOTATION_DEBUG << "EditView::getPitchFromNoteInsertAction: pitch " << scalePitch << " out of range, using 0" << endl; scalePitch = 0; } Pitch pitch (scalePitch, 4 + octave + clef.getOctave(), key, accidental); return pitch.getPerformancePitch(); } else { throw Exception("Not an insert action", __FILE__, __LINE__); }}void EditView::slotAddTempo(){ timeT insertionTime = getInsertionTime(); TempoDialog tempoDlg(this, getDocument()); connect(&tempoDlg, SIGNAL(changeTempo(timeT, tempoT, tempoT, TempoDialog::TempoDialogAction)), this, SIGNAL(changeTempo(timeT, tempoT, tempoT, TempoDialog::TempoDialogAction))); tempoDlg.setTempoPosition(insertionTime); tempoDlg.exec();}void EditView::slotAddTimeSignature(){ Segment *segment = getCurrentSegment(); if (!segment) return ; Composition *composition = segment->getComposition(); timeT insertionTime = getInsertionTime(); TimeSignatureDialog *dialog = 0; int timeSigNo = composition->getTimeSignatureNumberAt(insertionTime); if (timeSigNo >= 0) { dialog = new TimeSignatureDialog (this, composition, insertionTime, composition->getTimeSignatureAt(insertionTime)); } else { timeT endTime = composition->getDuration(); if (composition->getTimeSignatureCount() > 0) { endTime = composition->getTimeSignatureChange(0).first; } CompositionTimeSliceAdapter adapter (composition, insertionTime, endTime); AnalysisHelper helper; TimeSignature timeSig = helper.guessTimeSignature(adapter); dialog = new TimeSignatureDialog (this, composition, insertionTime, timeSig, false, i18n("Estimated time signature shown")); } if (dialog->exec() == QDialog::Accepted) { insertionTime = dialog->getTime(); if (dialog->shouldNormalizeRests()) { addCommandToHistory(new AddTimeSignatureAndNormalizeCommand (composition, insertionTime, dialog->getTimeSignature())); } else { addCommandToHistory(new AddTimeSignatureCommand (composition, insertionTime, dialog->getTimeSignature())); } } delete dialog;}void EditView::showPropertyControlRuler(PropertyName propertyName){ int index = 0; ControlRuler* existingRuler = findRuler(propertyName, index); if (existingRuler) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -