📄 notationview.cpp
字号:
m_rawNoteRuler(0), m_annotationsVisible(false), m_lilypondDirectivesVisible(false), m_selectDefaultNote(0), m_fontCombo(0), m_fontSizeCombo(0), m_spacingCombo(0), m_fontSizeActionMenu(0), m_pannerDialog(new ScrollBoxDialog(this, ScrollBox::FixHeight)), m_renderTimer(0), m_playTracking(true), m_progressDisplayer(PROGRESS_NONE), m_inhibitRefresh(true), m_ok(false), m_printMode(false), m_printSize(8) // set in positionStaffs{ initActionDataMaps(); // does something only the 1st time it's called m_toolBox = new NotationToolBox(this); assert(segments.size() > 0); NOTATION_DEBUG << "NotationView ctor" << endl; // Initialise the display-related defaults that will be needed // by both the actions and the layout toolbar m_config->setGroup(NotationViewConfigGroup); m_fontName = qstrtostr(m_config->readEntry ("notefont", strtoqstr(NoteFontFactory::getDefaultFontName()))); try { (void)NoteFontFactory::getFont (m_fontName, NoteFontFactory::getDefaultSize(m_fontName)); } catch (Exception e) { m_fontName = NoteFontFactory::getDefaultFontName(); } m_fontSize = m_config->readUnsignedNumEntry ((segments.size() > 1 ? "multistaffnotesize" : "singlestaffnotesize"), NoteFontFactory::getDefaultSize(m_fontName)); int defaultSpacing = m_config->readNumEntry("spacing", 100); m_hlayout->setSpacing(defaultSpacing); int defaultProportion = m_config->readNumEntry("proportion", 60); m_hlayout->setProportion(defaultProportion); delete m_notePixmapFactory; m_notePixmapFactory = new NotePixmapFactory(m_fontName, m_fontSize); m_hlayout->setNotePixmapFactory(m_notePixmapFactory); m_vlayout->setNotePixmapFactory(m_notePixmapFactory); setupActions(); // setupAddControlRulerMenu(); - too early for notation, moved to end of ctor. initLayoutToolbar(); initStatusBar(); setBackgroundMode(PaletteBase); QCanvas *tCanvas = new QCanvas(this); tCanvas->resize(width() * 2, height() * 2); setCanvasView(new NotationCanvasView(*this, tCanvas, getCentralWidget())); updateViewCaption(); setTopStandardRuler(new StandardRuler(getDocument(), m_hlayout, m_leftGutter, 25, false, getCentralWidget())); m_topStandardRuler->getLoopRuler()->setBackgroundColor (GUIPalette::getColour(GUIPalette::InsertCursorRuler)); m_chordNameRuler = new ChordNameRuler (m_hlayout, doc, segments, m_leftGutter, 20, getCentralWidget()); addRuler(m_chordNameRuler); if (showProgressive) m_chordNameRuler->show(); m_tempoRuler = new TempoRuler (m_hlayout, doc, this, m_leftGutter, 24, false, getCentralWidget()); addRuler(m_tempoRuler); m_tempoRuler->hide(); static_cast<TempoRuler *>(m_tempoRuler)->connectSignals(); m_rawNoteRuler = new RawNoteRuler (m_hlayout, segments[0], m_leftGutter, 20, getCentralWidget()); addRuler(m_rawNoteRuler); m_rawNoteRuler->show(); // All toolbars should be created before this is called setAutoSaveSettings("NotationView", true); // All rulers must have been created before this is called, // or the program will crash readOptions(); setBottomStandardRuler(new StandardRuler(getDocument(), m_hlayout, m_leftGutter, 25, true, getBottomWidget())); connect(m_topStandardRuler->getLoopRuler(), SIGNAL(startMouseMove(int)), m_canvasView, SLOT(startAutoScroll(int))); connect(m_topStandardRuler->getLoopRuler(), SIGNAL(stopMouseMove()), m_canvasView, SLOT(stopAutoScroll())); connect(m_bottomStandardRuler->getLoopRuler(), SIGNAL(startMouseMove(int)), m_canvasView, SLOT(startAutoScroll(int))); connect(m_bottomStandardRuler->getLoopRuler(), SIGNAL(stopMouseMove()), m_canvasView, SLOT(stopAutoScroll())); for (unsigned int i = 0; i < segments.size(); ++i) { m_staffs.push_back(new NotationStaff (canvas(), segments[i], 0, // snap i, this, m_fontName, m_fontSize)); } // // layout // ProgressDialog* progressDlg = 0; if (showProgressive) { show(); ProgressDialog::processEvents(); NOTATION_DEBUG << "NotationView : setting up progress dialog" << endl; progressDlg = new ProgressDialog(i18n("Starting..."), 100, this); progressDlg->setAutoClose(false); progressDlg->setAutoReset(true); progressDlg->setMinimumDuration(1000); setupProgress(progressDlg); m_progressDisplayer = PROGRESS_DIALOG; } m_chordNameRuler->setStudio(&getDocument()->getStudio()); m_currentStaff = 0; m_staffs[0]->setCurrent(true); m_config->setGroup(NotationViewConfigGroup); int layoutMode = m_config->readNumEntry("layoutmode", 0); try { LinedStaff::PageMode mode = LinedStaff::LinearMode; if (layoutMode == 1) mode = LinedStaff::ContinuousPageMode; else if (layoutMode == 2) mode = LinedStaff::MultiPageMode; setPageMode(mode); for (unsigned int i = 0; i < m_staffs.size(); ++i) { m_staffs[i]->getSegment().getRefreshStatus (m_segmentsRefreshStatusIds[i]).setNeedsRefresh(false); } m_ok = true; } catch (ProgressReporter::Cancelled c) { // when cancelled, m_ok is false -- checked by calling method NOTATION_DEBUG << "NotationView ctor : layout Cancelled" << endl; } NOTATION_DEBUG << "NotationView ctor : m_ok = " << m_ok << endl; delete progressDlg; // at this point we can return if operation was cancelled if (!isOK()) { setOutOfCtor(); return ; } // otherwise, carry on setupDefaultProgress(); // // Connect signals // QObject::connect (getCanvasView(), SIGNAL(renderRequired(double, double)), this, SLOT(slotCheckRendered(double, double))); m_topStandardRuler->connectRulerToDocPointer(doc); m_bottomStandardRuler->connectRulerToDocPointer(doc); // Disconnect the default connection for this signal from the // top ruler, and connect our own instead QObject::disconnect (m_topStandardRuler->getLoopRuler(), SIGNAL(setPointerPosition(timeT)), 0, 0); QObject::connect (m_topStandardRuler->getLoopRuler(), SIGNAL(setPointerPosition(timeT)), this, SLOT(slotSetInsertCursorPosition(timeT))); QObject::connect (m_topStandardRuler, SIGNAL(dragPointerToPosition(timeT)), this, SLOT(slotSetInsertCursorPosition(timeT))); connect(m_bottomStandardRuler, SIGNAL(dragPointerToPosition(timeT)), this, SLOT(slotSetPointerPosition(timeT))); QObject::connect (getCanvasView(), SIGNAL(itemPressed(int, int, QMouseEvent*, NotationElement*)), this, SLOT (slotItemPressed(int, int, QMouseEvent*, NotationElement*))); QObject::connect (getCanvasView(), SIGNAL(activeItemPressed(QMouseEvent*, QCanvasItem*)), this, SLOT (slotActiveItemPressed(QMouseEvent*, QCanvasItem*))); QObject::connect (getCanvasView(), SIGNAL(nonNotationItemPressed(QMouseEvent*, QCanvasItem*)), this, SLOT (slotNonNotationItemPressed(QMouseEvent*, QCanvasItem*))); QObject::connect (getCanvasView(), SIGNAL(textItemPressed(QMouseEvent*, QCanvasItem*)), this, SLOT (slotTextItemPressed(QMouseEvent*, QCanvasItem*))); QObject::connect (getCanvasView(), SIGNAL(mouseMoved(QMouseEvent*)), this, SLOT (slotMouseMoved(QMouseEvent*))); QObject::connect (getCanvasView(), SIGNAL(mouseReleased(QMouseEvent*)), this, SLOT (slotMouseReleased(QMouseEvent*))); QObject::connect (getCanvasView(), SIGNAL(hoveredOverNoteChanged(const QString&)), this, SLOT (slotHoveredOverNoteChanged(const QString&))); QObject::connect (getCanvasView(), SIGNAL(hoveredOverAbsoluteTimeChanged(unsigned int)), this, SLOT (slotHoveredOverAbsoluteTimeChanged(unsigned int))); QObject::connect (getCanvasView(), SIGNAL(zoomIn()), this, SLOT(slotZoomIn())); QObject::connect (getCanvasView(), SIGNAL(zoomOut()), this, SLOT(slotZoomOut())); QObject::connect (m_pannerDialog->scrollbox(), SIGNAL(valueChanged(const QPoint &)), getCanvasView(), SLOT(slotSetScrollPos(const QPoint &))); QObject::connect (getCanvasView()->horizontalScrollBar(), SIGNAL(valueChanged(int)), m_pannerDialog->scrollbox(), SLOT(setViewX(int))); QObject::connect (getCanvasView()->verticalScrollBar(), SIGNAL(valueChanged(int)), m_pannerDialog->scrollbox(), SLOT(setViewY(int))); QObject::connect (doc, SIGNAL(pointerPositionChanged(timeT)), this, SLOT(slotSetPointerPosition(timeT))); stateChanged("have_selection", KXMLGUIClient::StateReverse); stateChanged("have_notes_in_selection", KXMLGUIClient::StateReverse); stateChanged("have_rests_in_selection", KXMLGUIClient::StateReverse); stateChanged("have_multiple_staffs", (m_staffs.size() > 1 ? KXMLGUIClient::StateNoReverse : KXMLGUIClient::StateReverse)); stateChanged("rest_insert_tool_current", KXMLGUIClient::StateReverse); slotTestClipboard(); if (getSegmentsOnlyRestsAndClefs()) { m_selectDefaultNote->activate(); stateChanged("note_insert_tool_current", KXMLGUIClient::StateNoReverse); } else { actionCollection()->action("select")->activate(); stateChanged("note_insert_tool_current", KXMLGUIClient::StateReverse); } timeT start = doc->getComposition().getLoopStart(); timeT end = doc->getComposition().getLoopEnd(); m_topStandardRuler->getLoopRuler()->slotSetLoopMarker(start, end); m_bottomStandardRuler->getLoopRuler()->slotSetLoopMarker(start, end); slotSetInsertCursorPosition(0); slotSetPointerPosition(doc->getComposition().getPosition()); setCurrentSelection(0, false, true); slotUpdateInsertModeStatus(); m_chordNameRuler->repaint(); m_tempoRuler->repaint(); m_rawNoteRuler->repaint(); m_inhibitRefresh = false; // slotCheckRendered(0, getCanvasView()->visibleWidth()); // getCanvasView()->repaintContents(); updateView(); QObject::connect (this, SIGNAL(renderComplete()), getCanvasView(), SLOT(slotRenderComplete())); if (parent) { const TrackButtons * trackLabels = ((RosegardenGUIView*)parent)->getTrackEditor()->getTrackButtons(); QObject::connect (trackLabels, SIGNAL(nameChanged()), this, SLOT(slotUpdateStaffName())); } setConfigDialogPageIndex(3); setOutOfCtor(); // Property and Control Rulers // if (getCurrentSegment()->getViewFeatures()) slotShowVelocityControlRuler(); setupControllerTabs(); setupAddControlRulerMenu(); setRewFFwdToAutoRepeat(); slotCompositionStateUpdate(); NOTATION_DEBUG << "NotationView ctor exiting" << endl;}NotationView::NotationView(RosegardenGUIDoc *doc, std::vector<Segment *> segments, QWidget *parent, NotationView *referenceView) : EditView(doc, segments, 1, 0, "printview"), m_properties(getViewLocalPropertyPrefix()), m_selectionCounter(0), m_currentNotePixmap(0), m_hoveredOverNoteName(0), m_hoveredOverAbsoluteTime(0), m_lastFinishingStaff( -1), m_title(0), m_subtitle(0), m_composer(0), m_copyright(0), m_insertionTime(0), m_deferredCursorMove(NoCursorMoveNeeded), m_lastNoteAction("crotchet"), m_fontName(NoteFontFactory::getDefaultFontName()), m_fontSize(NoteFontFactory::getDefaultSize(m_fontName)), m_pageMode(LinedStaff::LinearMode), m_leftGutter(0), m_notePixmapFactory(new NotePixmapFactory(m_fontName, m_fontSize)), m_hlayout(new NotationHLayout(&doc->getComposition(), m_notePixmapFactory,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -