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

RosegardenGUIApp::RosegardenGUIApp ( bool  useSequencer = true,
bool  useExistingSequencer = false,
QObject *  startupStatusMessageReceiver = 0 
)

construtor of RosegardenGUIApp, calls all init functions to create the application.

  • useSequencer : if true, the sequencer is launched
    See also:
    initMenuBar initToolBar

Definition at line 226 of file rosegardengui.cpp.

References RosegardenParameterArea::addRosegardenParameterBox(), RosegardenGUIDoc::getStudio(), initStatusBar(), initZoomToolbar(), instrumentParametersChanged(), launchSequencer(), m_doc, m_view, pluginBypassed(), pluginSelected(), readOptions(), RosegardenParameterArea::setArrangement(), setDocument(), setupActions(), setupFileDialogSpeedbar(), slotParametersClosed(), slotParametersDockedBack(), slotPluginSelected(), slotShowPluginDialog(), slotStateChanged(), and slotTestClipboard().

Referenced by slotFileNewWindow().

    : DCOPObject("RosegardenIface"), RosegardenIface(this), KDockMainWindow(0), 
      m_actionsSetup(false),
      m_fileRecent(0),
      m_view(0),
      m_swapView(0),
      m_mainDockWidget(0),
      m_dockLeft(0),
      m_doc(0),
      m_sequencerProcess(0),
      m_sequencerCheckedIn(false),
#ifdef HAVE_LIBJACK
      m_jackProcess(0),
#endif
      m_zoomSlider(0),
      m_seqManager(0),
      m_transport(0),
      m_audioManagerDialog(0),
      m_originatingJump(false),
      m_storedLoopStart(0),
      m_storedLoopEnd(0),
      m_useSequencer(useSequencer),
      m_dockVisible(true),
      m_autoSaveTimer(new QTimer(this)),
      m_clipboard(new Rosegarden::Clipboard),
      m_playList(0),
      m_deviceManager(0),
      m_synthManager(0),
      m_audioMixer(0),
      m_midiMixer(0),
      m_bankEditor(0),
      m_markerEditor(0),
      m_tempoView(0),
      m_triggerSegmentManager(0),
#ifdef HAVE_LIBLO
      m_pluginGUIManager(new AudioPluginOSCGUIManager(this)),
#endif
      m_playTimer(new QTimer(this)),
      m_stopTimer(new QTimer(this)),
      m_startupTester(0),
#ifdef HAVE_LIRC
      m_lircClient(0),
      m_lircCommander(0),
#endif
      m_parameterArea(0)
{
    m_myself = this;


    if (startupStatusMessageReceiver) {
        QObject::connect(this, SIGNAL(startupStatusMessage(QString)),
                         startupStatusMessageReceiver,
                         SLOT(slotShowStatusMessage(QString)));
    }

    // Try to start the sequencer
    //
    if (m_useSequencer) {

#ifdef HAVE_LIBJACK
#define OFFER_JACK_START_OPTION 1
#ifdef OFFER_JACK_START_OPTION
        // First we check if jackd is running allready

        std::string jackClientName = "rosegarden";

        // attempt connection to JACK server
        //
        jack_client_t* testJackClient;
        testJackClient =jack_client_new(jackClientName.c_str());
        if (testJackClient == 0 ) {

            // If no connection to JACK
            // try to launch JACK - if the configuration wants us to.
            if (!launchJack()) {
                KStartupLogo::hideIfStillThere();
                KMessageBox::error(this, i18n("Attempted to launch JACK audio daemon failed.  Audio will be disabled.\nPlease check configuration (Settings->Configure Rosegarden->Sequencer->JACK control)\n and restart."));
            }
        } else {
            //this client was just for testing
            jack_client_close(testJackClient);
        }
#endif // OFFER_JACK_START_OPTION
#endif // HAVE_LIBJACK

        emit startupStatusMessage(i18n("Starting sequencer..."));
        launchSequencer(useExistingSequencer);

    } else RG_DEBUG << "RosegardenGUIApp : don't use sequencer\n";

    // Plugin manager
    //
    emit startupStatusMessage(i18n("Initializing plugin manager..."));
    m_pluginManager = new Rosegarden::AudioPluginManager();

    // call inits to invoke all other construction parts
    //
    emit startupStatusMessage(i18n("Initializing view..."));
    initStatusBar();
    setupActions();
    iFaceDelayedInit(this);
    initZoomToolbar();

    QPixmap dummyPixmap; // any icon will do
    m_mainDockWidget = createDockWidget("Rosegarden MainDockWidget", dummyPixmap, 0L, "main_dock_widget");
    // allow others to dock to the left and right sides only
    m_mainDockWidget->setDockSite(KDockWidget::DockLeft | KDockWidget::DockRight);
    // forbit docking abilities of m_mainDockWidget itself
    m_mainDockWidget->setEnableDocking(KDockWidget::DockNone);
    setView(m_mainDockWidget); // central widget in a KDE mainwindow
    setMainDockWidget(m_mainDockWidget); // master dockwidget

    m_dockLeft = createDockWidget("params dock", dummyPixmap, 0L,
                                  i18n("Special Parameters"));
    m_dockLeft->manualDock(m_mainDockWidget,            // dock target
                           KDockWidget::DockLeft, // dock site
                           20);                   // relation target/this (in percent)

    connect(m_dockLeft, SIGNAL(iMBeingClosed()),
            this, SLOT(slotParametersClosed()));
    connect(m_dockLeft, SIGNAL(hasUndocked()),
            this, SLOT(slotParametersClosed()));
    // Apparently, hasUndocked() is emitted when the dock widget's
    // 'close' button on the dock handle is clicked.
    connect(m_mainDockWidget, SIGNAL(docking(KDockWidget*, KDockWidget::DockPosition)),
            this, SLOT(slotParametersDockedBack(KDockWidget*, KDockWidget::DockPosition)));

    stateChanged("parametersbox_closed", KXMLGUIClient::StateReverse);

    RosegardenGUIDoc* doc = new RosegardenGUIDoc(this, m_pluginManager);

    m_parameterArea = new RosegardenParameterArea(m_dockLeft);
    m_dockLeft->setWidget(m_parameterArea);

    // Populate the parameter-box area with the respective
    // parameter box widgets.

    m_segmentParameterBox = new SegmentParameterBox(doc, m_parameterArea);
    m_parameterArea->addRosegardenParameterBox(m_segmentParameterBox);
    m_trackParameterBox = new TrackParameterBox(doc, m_parameterArea);
    m_parameterArea->addRosegardenParameterBox(m_trackParameterBox);
    m_instrumentParameterBox = new InstrumentParameterBox(doc, m_parameterArea);
    m_parameterArea->addRosegardenParameterBox(m_instrumentParameterBox);

    // Lookup the configuration parameter that specifies the default
    // arrangement, and instantiate it.

    kapp->config()->setGroup(Rosegarden::GeneralOptionsConfigGroup);
    m_parameterArea->setArrangement((RosegardenParameterArea::Arrangement)
        kapp->config()->readUnsignedNumEntry("sidebarstyle",
        RosegardenParameterArea::CLASSIC_STYLE));
    
    m_dockLeft->update();

    connect(m_instrumentParameterBox,
          SIGNAL(selectPlugin(QWidget *, Rosegarden::InstrumentId, int)),
          this,
          SLOT(slotShowPluginDialog(QWidget *, Rosegarden::InstrumentId, int)));

    connect(m_instrumentParameterBox,
          SIGNAL(showPluginGUI(Rosegarden::InstrumentId, int)),
          this,
          SLOT(slotShowPluginGUI(Rosegarden::InstrumentId, int)));

    // relay this through our own signal so that others can use it too
    connect(m_instrumentParameterBox,
          SIGNAL(instrumentParametersChanged(Rosegarden::InstrumentId)),
          this,
          SIGNAL(instrumentParametersChanged(Rosegarden::InstrumentId)));

    connect(this,
          SIGNAL(instrumentParametersChanged(Rosegarden::InstrumentId)),
          m_instrumentParameterBox,
          SLOT(slotInstrumentParametersChanged(Rosegarden::InstrumentId)));

    connect(this,
          SIGNAL(pluginSelected(Rosegarden::InstrumentId, int, int)),
          m_instrumentParameterBox,
          SLOT(slotPluginSelected(Rosegarden::InstrumentId, int, int)));

    connect(this,
          SIGNAL(pluginBypassed(Rosegarden::InstrumentId, int, bool)),
          m_instrumentParameterBox,
          SLOT(slotPluginBypassed(Rosegarden::InstrumentId, int, bool)));

    // Load the initial document (this includes doc's own autoload)
    //
    setDocument(doc);

    emit startupStatusMessage(i18n("Starting sequence manager..."));

    // transport is created by setupActions()
    m_seqManager = new Rosegarden::SequenceManager(m_doc, getTransport());

    try {
      if (m_useSequencer) {
          m_seqManager->checkSoundDriverStatus();
      }
    } catch (Rosegarden::Exception e) {
      KStartupLogo::hideIfStillThere();
      CurrentProgressDialog::freeze();
      KMessageBox::error(this, i18n("Sequencer startup failed: %1")
                     .arg(strtoqstr(e.getMessage())));
      CurrentProgressDialog::thaw();
    }

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

    // Make sure we get the sequencer status now
    //
    emit startupStatusMessage(i18n("Getting sound driver status..."));
    (void)m_seqManager->getSoundDriverStatus();

    if (m_seqManager->getSoundDriverStatus() & Rosegarden::AUDIO_OK) {
      slotStateChanged("got_audio", true);
    } else {
      slotStateChanged("got_audio", false);
    }

    // If we're restarting the gui then make sure any transient
    // studio objects are cleared away.
    emit startupStatusMessage(i18n("Clearing studio data..."));
    m_seqManager->reinitialiseSequencerStudio();

    // Send the transport control statuses for MMC and JACK
    //
    m_seqManager->sendTransportControlStatuses();

    // Now autoload
    //
    stateChanged("new_file");
    stateChanged("have_segments",    KXMLGUIClient::StateReverse);
    stateChanged("have_selection",   KXMLGUIClient::StateReverse);
    slotTestClipboard();

    // Check for lack of MIDI devices and disable Studio options accordingly
    //
    if (!m_doc->getStudio().haveMidiDevices())
        stateChanged("got_midi_devices", KXMLGUIClient::StateReverse);

    emit startupStatusMessage(i18n("Starting..."));

    setupFileDialogSpeedbar();
    readOptions();

    // All toolbars should be created before this is called
    setAutoSaveSettings(RosegardenGUIApp::MainWindowConfigGroup, true);
        
#ifdef HAVE_LIRC 
    try {
      m_lircClient = new LircClient();
    } catch (Rosegarden::Exception e) {
      RG_DEBUG << e.getMessage().c_str() << endl;
      // continue without
      m_lircClient = 0;
    }
    if (m_lircClient) {
      m_lircCommander = new LircCommander(m_lircClient, this);
    }
#endif

    stateChanged("have_project_packager", KXMLGUIClient::StateReverse);
    stateChanged("have_lilypondview", KXMLGUIClient::StateReverse);
    QTimer::singleShot(1000, this, SLOT(slotTestStartupTester()));
}


Generated by  Doxygen 1.6.0   Back to index