void TrackParameterBox::slotLoadPressed() { // Inherits style. Centers on main window. //PresetHandlerDialog dialog(this); // Does not inherit style? Centers on monitor #1? PresetHandlerDialog dialog(0); Track *track = getTrack(); if (!track) return; try { // Launch the PresetHandlerDialog. If the user selects OK... if (dialog.exec() == QDialog::Accepted) { // Update the Track. track->setPresetLabel(qstrtostr(dialog.getName())); track->setClef(dialog.getClef()); track->setTranspose(dialog.getTranspose()); track->setHighestPlayable(dialog.getHighRange()); track->setLowestPlayable(dialog.getLowRange()); // Enable this until it is subsequently re-disabled by the // user overriding the preset, calling one of the other slots // in the normal course. // ??? This is too subtle. We should probably just clear it // when modifications are made. After all, it's no longer // the selected preset. Or add "(modified)"? Or change // color? Or allow the user to edit it and save it to the // .rg file as part of the Track. m_preset->setEnabled(true); // If we need to convert the track's segments if (dialog.getConvertAllSegments()) { Composition &comp = m_doc->getComposition(); SegmentSyncCommand* command = new SegmentSyncCommand( comp.getSegments(), m_selectedTrackId, dialog.getTranspose(), dialog.getLowRange(), dialog.getHighRange(), clefIndexToClef(dialog.getClef())); CommandHistory::getInstance()->addCommand(command); } m_doc->slotDocumentModified(); // Notify observers // This will trigger a call to updateWidgets2(). Composition &comp = m_doc->getComposition(); comp.notifyTrackChanged(track); } } catch (Exception &e) { // from PresetHandlerDialog // !!! This should be a more verbose error to pass along the // row/column of the corruption. QMessageBox::warning(0, tr("Rosegarden"), tr("The instrument preset database is corrupt. Check your installation.")); } }
void SegmentPencil::mouseReleaseEvent(QMouseEvent *e) { // Have to allow middle button for SegmentSelector's middle // button feature to work. if (e->button() != Qt::LeftButton && e->button() != Qt::MidButton) return; // No need to propagate. e->accept(); QPoint pos = m_canvas->viewportToContents(e->pos()); setContextHelpFor(pos); if (m_newRect) { QRect tmpRect = m_canvas->getNewSegmentRect(); int trackPosition = m_canvas->grid().getYBin(tmpRect.y()); Track *track = m_doc->getComposition().getTrackByPosition(trackPosition); SegmentInsertCommand *command = new SegmentInsertCommand(m_doc, track->getId(), m_startTime, m_endTime); m_newRect = false; CommandHistory::getInstance()->addCommand(command); // add the SegmentItem by hand, instead of allowing the usual // update mechanism to spot it. This way we can select the // segment as we add it; otherwise we'd have no way to know // that the segment was created by this tool rather than by // e.g. a simple file load Segment *segment = command->getSegment(); // add a clef to the start of the segment (tracks initialize to a // default of 0 for this property, so treble will be the default if it // is not specified elsewhere) segment->insert(clefIndexToClef(track->getClef()).getAsEvent (segment->getStartTime())); //!!! Should not a default key be inserted here equally in order to // have the "hide redundant clefs and keys" mechanism working // on the segments using the default key ? segment->setTranspose(track->getTranspose()); segment->setColourIndex(track->getColor()); segment->setLowestPlayable(track->getLowestPlayable()); segment->setHighestPlayable(track->getHighestPlayable()); std::string label = track->getPresetLabel(); if (label != "") { segment->setLabel( track->getPresetLabel().c_str() ); } m_canvas->getModel()->clearSelected(); m_canvas->getModel()->setSelected(segment); m_canvas->getModel()->selectionHasChanged(); m_canvas->hideNewSegment(); m_canvas->slotUpdateAll(); } }