📄 rosegardenguiapp.cpp
字号:
pixmap.load(pixmapDir + "/toolbar/time-musical.png"); icon = QIconSet(pixmap); new KAction(i18n("Manage &Metronome"), 0, this, SLOT(slotManageMetronome()), actionCollection(), "manage_metronome"); new KAction(i18n("&Save Current Document as Default Studio"), 0, this, SLOT(slotSaveDefaultStudio()), actionCollection(), "save_default_studio"); new KAction(i18n("&Import Default Studio"), 0, this, SLOT(slotImportDefaultStudio()), actionCollection(), "load_default_studio"); new KAction(i18n("Im&port Studio from File..."), 0, this, SLOT(slotImportStudio()), actionCollection(), "load_studio"); new KAction(i18n("&Reset MIDI Network"), 0, this, SLOT(slotResetMidiNetwork()), actionCollection(), "reset_midi_network"); // // Marker Ruler popup menu //// new KAction(i18n("Insert Marker"), 0, 0, this,// SLOT(slotInsertMarkerHere()), actionCollection(),// "insert_marker_here");// // new KAction(i18n("Insert Marker at Playback Position"), 0, 0, this,// SLOT(slotInsertMarkerAtPointer()), actionCollection(),// "insert_marker_at_pointer");//// new KAction(i18n("Delete Marker"), 0, 0, this,// SLOT(slotDeleteMarker()), actionCollection(),// "delete_marker"); // // Transport menu // // Transport controls [rwb] // // We set some default key bindings - with numlock off // use 1 (End) and 3 (Page Down) for Rwd and Ffwd and // 0 (insert) and keypad Enter for Play and Stop // pixmap.load(pixmapDir + "/toolbar/transport-play.png"); icon = QIconSet(pixmap); m_playTransport = new KAction(i18n("&Play"), icon, Key_Enter, this, SLOT(slotPlay()), actionCollection(), "play"); m_playTransport->setGroup(TransportDialogConfigGroup); pixmap.load(pixmapDir + "/toolbar/transport-stop.png"); icon = QIconSet(pixmap); m_stopTransport = new KAction(i18n("&Stop"), icon, Key_Insert, this, SLOT(slotStop()), actionCollection(), "stop"); m_stopTransport->setGroup(TransportDialogConfigGroup); pixmap.load(pixmapDir + "/toolbar/transport-ffwd.png"); icon = QIconSet(pixmap); m_ffwdTransport = new KAction(i18n("&Fast Forward"), icon, Key_PageDown, this, SLOT(slotFastforward()), actionCollection(), "fast_forward"); m_ffwdTransport->setGroup(TransportDialogConfigGroup); pixmap.load(pixmapDir + "/toolbar/transport-rewind.png"); icon = QIconSet(pixmap); m_rewindTransport = new KAction(i18n("Re&wind"), icon, Key_End, this, SLOT(slotRewind()), actionCollection(), "rewind"); m_rewindTransport->setGroup(TransportDialogConfigGroup); pixmap.load(pixmapDir + "/toolbar/transport-record.png"); icon = QIconSet(pixmap); m_recordTransport = new KAction(i18n("P&unch in Record"), icon, Key_Space, this, SLOT(slotToggleRecord()), actionCollection(), "recordtoggle"); m_recordTransport->setGroup(TransportDialogConfigGroup); pixmap.load(pixmapDir + "/toolbar/transport-record.png"); icon = QIconSet(pixmap); m_recordTransport = new KAction(i18n("&Record"), icon, 0, this, SLOT(slotRecord()), actionCollection(), "record"); m_recordTransport->setGroup(TransportDialogConfigGroup); pixmap.load(pixmapDir + "/toolbar/transport-rewind-end.png"); icon = QIconSet(pixmap); m_rewindEndTransport = new KAction(i18n("Rewind to &Beginning"), icon, 0, this, SLOT(slotRewindToBeginning()), actionCollection(), "rewindtobeginning"); m_rewindEndTransport->setGroup(TransportDialogConfigGroup); pixmap.load(pixmapDir + "/toolbar/transport-ffwd-end.png"); icon = QIconSet(pixmap); m_ffwdEndTransport = new KAction(i18n("Fast Forward to &End"), icon, 0, this, SLOT(slotFastForwardToEnd()), actionCollection(), "fastforwardtoend"); m_ffwdEndTransport->setGroup(TransportDialogConfigGroup); pixmap.load(pixmapDir + "/toolbar/transport-tracking.png"); icon = QIconSet(pixmap); (new KToggleAction(i18n("Scro&ll to Follow Playback"), icon, Key_Pause, this, SLOT(slotToggleTracking()), actionCollection(), "toggle_tracking"))->setChecked(true); pixmap.load(pixmapDir + "/toolbar/transport-panic.png"); icon = QIconSet(pixmap); new KAction( i18n("Panic"), icon, Key_P + CTRL + ALT, this, SLOT(slotPanic()), actionCollection(), "panic"); // DEBUG FACILITY new KAction(i18n("Segment Debug Dump "), 0, this, SLOT(slotDebugDump()), actionCollection(), "debug_dump_segments"); // create main gui // createGUI("rosegardenui.rc", false); createAndSetupTransport(); // transport toolbar is hidden by default - TODO : this should be in options // //toolBar("Transport Toolbar")->hide(); QPopupMenu* setTrackInstrumentMenu = dynamic_cast<QPopupMenu*>(factory()->container("set_track_instrument", this)); if (setTrackInstrumentMenu) { connect(setTrackInstrumentMenu, SIGNAL(aboutToShow()), this, SLOT(slotPopulateTrackInstrumentPopup())); } else { RG_DEBUG << "RosegardenGUIApp::setupActions() : couldn't find set_track_instrument menu - check rosegardenui.rcn\n"; } setRewFFwdToAutoRepeat();}void RosegardenGUIApp::setRewFFwdToAutoRepeat(){ QWidget* transportToolbar = factory()->container("Transport Toolbar", this); if (transportToolbar) { QObjectList *l = transportToolbar->queryList(); QObjectListIt it(*l); // iterate over the buttons QObject *obj; while ( (obj = it.current()) != 0 ) { // for each found object... ++it; // RG_DEBUG << "obj name : " << obj->name() << endl; QString objName = obj->name(); if (objName.endsWith("rewind") || objName.endsWith("fast_forward")) { QButton* btn = dynamic_cast<QButton*>(obj); if (!btn) { RG_DEBUG << "Very strange - found widgets in transport_toolbar which aren't buttons\n"; continue; } btn->setAutoRepeat(true); } } delete l; } else { RG_DEBUG << "transportToolbar == 0\n"; }}void RosegardenGUIApp::initZoomToolbar(){ KToolBar *zoomToolbar = toolBar("Zoom Toolbar"); if (!zoomToolbar) { RG_DEBUG << "RosegardenGUIApp::initZoomToolbar() : " << "zoom toolbar not found" << endl; return ; } new QLabel(i18n(" Zoom: "), zoomToolbar, "kde toolbar widget"); std::vector<double> zoomSizes; // in units-per-pixel double defaultBarWidth44 = 100.0; double duration44 = TimeSignature(4, 4).getBarDuration(); static double factors[] = { 0.025, 0.05, 0.1, 0.2, 0.5, 1.0, 1.5, 2.5, 5.0, 10.0 , 20.0 }; for (unsigned int i = 0; i < sizeof(factors) / sizeof(factors[0]); ++i) { zoomSizes.push_back(duration44 / (defaultBarWidth44 * factors[i])); } // zoom labels QString minZoom = QString("%1%").arg(factors[0] * 100.0); QString maxZoom = QString("%1%").arg(factors[(sizeof(factors) / sizeof(factors[0])) - 1] * 100.0); m_zoomSlider = new ZoomSlider<double> (zoomSizes, -1, QSlider::Horizontal, zoomToolbar, "kde toolbar widget"); m_zoomSlider->setTracking(true); m_zoomSlider->setFocusPolicy(QWidget::NoFocus); m_zoomLabel = new QLabel(minZoom, zoomToolbar, "kde toolbar widget"); m_zoomLabel->setIndent(10); connect(m_zoomSlider, SIGNAL(valueChanged(int)), this, SLOT(slotChangeZoom(int))); // set initial zoom - we might want to make this a config option // m_zoomSlider->setToDefault();}void RosegardenGUIApp::initStatusBar(){ KTmpStatusMsg::setDefaultMsg(""); statusBar()->insertItem(KTmpStatusMsg::getDefaultMsg(), KTmpStatusMsg::getDefaultId(), 1); statusBar()->setItemAlignment(KTmpStatusMsg::getDefaultId(), AlignLeft | AlignVCenter); m_progressBar = new ProgressBar(100, true, statusBar()); // m_progressBar->setMinimumWidth(100); m_progressBar->setFixedWidth(60); m_progressBar->setFixedHeight(18); m_progressBar->setTextEnabled(false); statusBar()->addWidget(m_progressBar);}void RosegardenGUIApp::initView(){ //////////////////////////////////////////////////////////////////// // 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; 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 SegmentSelection &)), SIGNAL(segmentsSelected(const SegmentSelection &))); connect(m_swapView, SIGNAL(addAudioFile(AudioFileId)), SLOT(slotAddAudioFile(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(InstrumentId)), this, SIGNAL(instrumentParametersChanged(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(MappedEvent *)), m_view, SLOT(slotControllerDeviceEventReceived(MappedEvent *))); } // delete m_playList; // m_playList = 0; delete m_deviceManager; m_deviceManager = 0; delete m_synthManager;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -