Logo Search packages:      
Sourcecode: rosegarden version File versions  Download package

void RosegardenGUIApp::initView (  )  [protected]

creates the centerwidget of the KTMainWindow instance and sets it as the view

Definition at line 1269 of file rosegardengui.cpp.

References RosegardenGUIDoc::attachView(), RosegardenGUIDoc::getComposition(), RosegardenGUIDoc::getConfiguration(), RosegardenGUIDoc::getTitle(), RosegardenGUIView::getTrackEditor(), RosegardenGUIView::initChordNameRuler(), instrumentParametersChanged(), isUsingSequencer(), m_doc, m_view, segmentsSelected(), slotActivateTool(), slotChangeZoom(), slotEnableTransport(), RosegardenGUIView::slotSelectTrackSegments(), slotSetPointerPosition(), slotStateChanged(), slotToggleChordNameRuler(), slotTogglePreviews(), slotToggleRulers(), slotToggleSegmentLabels(), slotToggleTempoRuler(), and TrackEditor::slotToggleTracking().

Referenced by setDocument().

{ 
    ////////////////////////////////////////////////////////////////////
    // create the main widget here that is managed by KTMainWindow's view-region and
    // connect the widget to your document to display document contents.

    RG_DEBUG << "RosegardenGUIApp::initView()" << endl;

    Rosegarden::Composition &comp = m_doc->getComposition();

    // Ensure that the start and end markers for the piece are set
    // to something reasonable
    //
    if (comp.getStartMarker() == 0 &&
        comp.getEndMarker() == 0)
    {
        int endMarker = comp.getBarRange(100 + comp.getNbBars()).second;
        comp.setEndMarker(endMarker);
    }
    
    m_swapView = new RosegardenGUIView(m_viewTrackLabels->isChecked(),
                                       m_segmentParameterBox,
                                       m_instrumentParameterBox, 
                                       m_trackParameterBox, this);

    // Connect up this signal so that we can force tool mode
    // changes from the view
    connect(m_swapView, SIGNAL(activateTool(QString)),
            this,   SLOT(slotActivateTool(QString)));

    connect(m_swapView,
            SIGNAL(segmentsSelected(const Rosegarden::SegmentSelection &)),
            SIGNAL(segmentsSelected(const Rosegarden::SegmentSelection &)));

    connect(m_swapView,
            SIGNAL(addAudioFile(Rosegarden::AudioFileId)),
            SLOT(slotAddAudioFile(Rosegarden::AudioFileId)));

    connect(m_swapView, SIGNAL(toggleSolo(bool)), SLOT(slotToggleSolo(bool)));

    m_doc->attachView(m_swapView);

    m_mainDockWidget->setWidget(m_swapView);

//     setCentralWidget(m_swapView);
    setCaption(m_doc->getTitle());

    // set the pointer position
    //
    slotSetPointerPosition(m_doc->getComposition().getPosition());


    // Transport setup
    //

    slotEnableTransport(true);

    // and the time signature
    //
    getTransport()->setTimeSignature(comp.getTimeSignatureAt(comp.getPosition()));

    // set the tempo in the transport
    //
    getTransport()->setTempo(comp.getCurrentTempo());

    // bring the transport to the front 
    //
    getTransport()->raise();

    // set the play metronome button
    getTransport()->MetronomeButton()->setOn(comp.usePlayMetronome());

    // Set the solo button
    getTransport()->SoloButton()->setOn(comp.isSolo());

    // make sure we show
    //
    RosegardenGUIView *oldView = m_view;
    m_view = m_swapView;

    connect(m_view, SIGNAL(stateChange(QString, bool)),
            this,   SLOT  (slotStateChanged(QString, bool)));

    connect(m_view, SIGNAL(instrumentParametersChanged(Rosegarden::InstrumentId)),
          this, SIGNAL(instrumentParametersChanged(Rosegarden::InstrumentId)));

    // We only check for the SequenceManager to make sure
    // we're not on the first pass though - we don't want
    // to send these toggles twice on initialisation.
    //
    // Clunky but we just about get away with it for the
    // moment.
    //
    if (m_seqManager != 0)
    {
        slotToggleChordNameRuler();
        slotToggleRulers();
        slotToggleTempoRuler();
        slotTogglePreviews();
        slotToggleSegmentLabels();

        // Reset any loop on the sequencer
        //
        try
        {
            if (isUsingSequencer()) m_seqManager->setLoop(0, 0);
          stateChanged("have_range", KXMLGUIClient::StateReverse);
        }
        catch(QString s)
        {
          KStartupLogo::hideIfStillThere();
          CurrentProgressDialog::freeze();
            KMessageBox::error(this, s);
          CurrentProgressDialog::thaw();
        }

      connect(m_seqManager, SIGNAL(controllerDeviceEventReceived(Rosegarden::MappedEvent *)),
            m_view, SLOT(slotControllerDeviceEventReceived(Rosegarden::MappedEvent *)));
    }

//    delete m_playList;
//    m_playList = 0;

    delete m_deviceManager;
    m_deviceManager = 0;

    delete m_synthManager;
    m_synthManager = 0;

    delete m_audioMixer;
    m_audioMixer = 0;

    delete m_bankEditor;
    m_bankEditor = 0;

    delete m_markerEditor;
    m_markerEditor = 0;

    delete m_tempoView;
    m_tempoView = 0;

    delete m_triggerSegmentManager;
    m_triggerSegmentManager = 0;

    delete oldView;

    // set the highlighted track
    m_view->slotSelectTrackSegments(comp.getSelectedTrack());

    // play tracking on in the editor by default: turn off if need be
    KToggleAction *trackingAction = dynamic_cast<KToggleAction *>
        (actionCollection()->action("toggle_tracking"));
    if (trackingAction && !trackingAction->isChecked()) {
      m_view->getTrackEditor()->slotToggleTracking();
    }

    m_view->show();

    // We have to do this to make sure that the 2nd call ("select")
    // actually has any effect. Activating the same radio action
    // doesn't work the 2nd time (like pressing down the same radio
    // button twice - it doesn't have any effect), so if you load two
    // files in a row, on the 2nd file a new SegmentCanvas will be
    // created but its tool won't be set, even though it will appear
    // to be selected.
    //
    actionCollection()->action("move")->activate();
    if (m_doc->getComposition().getNbSegments() > 0)
        actionCollection()->action("select")->activate();
    else
        actionCollection()->action("draw")->activate();

    int zoomLevel = m_doc->getConfiguration().
        get<Rosegarden::Int>
            (Rosegarden::DocumentConfiguration::ZoomLevel);

    m_zoomSlider->setSize(double(zoomLevel)/1000.0);
    slotChangeZoom(zoomLevel);

    //slotChangeZoom(int(m_zoomSlider->getCurrentSize()));

    stateChanged("new_file");

    RosegardenProgressDialog::processEvents();
    
    if (m_viewChordNameRuler->isChecked()) {
      SetWaitCursor swc;
      m_view->initChordNameRuler();
    } else {
      m_view->initChordNameRuler();
    }
}


Generated by  Doxygen 1.6.0   Back to index