Element* Score::downAlt(Element* element) { Element* re = 0; if (element->type() == Element::REST) re = nextTrack(static_cast<Rest*>(element)); else if (element->type() == Element::NOTE) { Chord* chord = static_cast<Note*>(element)->chord(); const QList<Note*>& notes = chord->notes(); int idx = notes.indexOf(static_cast<Note*>(element)); if (idx > 0) { --idx; re = notes.value(idx); } else { re = nextTrack(chord); if (re->track() == chord->track()) re = element; } } if (re == 0) return 0; if (re->type() == Element::CHORD) re = static_cast<Chord*>(re)->notes().back(); return re; }
void scanSector(tDiskParm * d, tSearchParm * s, tSectorId givenSector) { searchParmCreate(s, d, givenSector); if (givenSector == CHS2Int(d->nSectors, d->trackPointer, d->sectorPointer)){ /* Si busco el sector donde estoy parado no hace falta buscar nada pero igual lo guardo en el historial para despues imprimirlo*/ historyAdd(s->history, CHS2Int(d->nSectors, d->trackPointer, d->sectorPointer)); return; } while (d->trackPointer != s->sTrack) { if (d->up == 1) { if (d->trackPointer == (d->nTracks)-1) { d->up = 0; lastTrack(d, s); } else nextTrack(d, s); } else { if (d->trackPointer == 0) { d->up = 1; nextTrack(d, s); } else lastTrack(d, s); } historyAdd(s->history, CHS2Int(d->nSectors, d->trackPointer, d->sectorPointer)); } if (d->sectorPointer != s->sSector) { gotoSector(d, s); historyAdd(s->history, CHS2Int(d->nSectors, d->trackPointer, d->sectorPointer)); } return; };
TrackInfo ITunesDevice::firstTrack( const QString& file ) { m_database = file; if ( !m_file ) { m_file = new QFile( file ); if ( !m_file->open( QIODevice::ReadOnly | QIODevice::Text ) ) { qDebug() << "Could not open iTunes Library" << m_database; return TrackInfo(); } m_totalSize = m_file->size(); m_xmlReader = new QXmlSimpleReader(); m_xmlInput = new QXmlInputSource(); m_handler = new ITunesParser(); m_xmlReader->setContentHandler( m_handler ); m_xmlInput->setData( m_file->read( 32768 ) ); if ( !m_xmlReader->parse( m_xmlInput, true ) ) { qDebug() << "Couldn't read file: " << m_database; return TrackInfo(); } } return nextTrack(); }
void K3bThreadJob::customEvent( QCustomEvent* e ) { if( K3bDataEvent* de = dynamic_cast<K3bDataEvent*>(e) ) { emit data( de->data(), de->length() ); } else { K3bProgressInfoEvent* be = static_cast<K3bProgressInfoEvent*>(e); switch( be->type() ) { case K3bProgressInfoEvent::Progress: emit percent( be->firstValue() ); break; case K3bProgressInfoEvent::SubProgress: emit subPercent( be->firstValue() ); break; case K3bProgressInfoEvent::ProcessedSize: emit processedSize( be->firstValue(), be->secondValue() ); break; case K3bProgressInfoEvent::ProcessedSubSize: emit processedSubSize( be->firstValue(), be->secondValue() ); break; case K3bProgressInfoEvent::InfoMessage: emit infoMessage( be->firstString(), be->firstValue() ); break; case K3bProgressInfoEvent::Started: jobStarted(); break; case K3bProgressInfoEvent::Canceled: emit canceled(); break; case K3bProgressInfoEvent::Finished: // we wait until the thred really finished // although this may be dangerous if some thread // emits the finished signal although it has not finished yet // but makes a lot stuff easier. kdDebug() << "(K3bThreadJob) waiting for the thread to finish." << endl; m_thread->wait(); kdDebug() << "(K3bThreadJob) thread finished." << endl; cleanupJob( be->firstValue() ); m_running = false; jobFinished( be->firstValue() ); break; case K3bProgressInfoEvent::NewTask: emit newTask( be->firstString() ); break; case K3bProgressInfoEvent::NewSubTask: emit newSubTask( be->firstString() ); break; case K3bProgressInfoEvent::DebuggingOutput: emit debuggingOutput( be->firstString(), be->secondString() ); break; case K3bProgressInfoEvent::NextTrack: emit nextTrack( be->firstValue(), be->secondValue() ); break; } } }
void MediaPlayer::chatKeyPressed(QKeyEvent *e, CustomInput *k, bool &handled) { Q_UNUSED(k) kdebugf(); if (handled) return; if (!m_configuration->deprecatedApi()->readBoolEntry("MediaPlayer", "chatShortcuts", true)) return; if (e->key() == SHORTCUT_KEY) winKeyPressed = true; // We want to handle LeftWinKey pressed state else if (!winKeyPressed) return; // If LeftWinKey isn't pressed then break function. if (!isActive()) return; handled = true; switch (e->key()) { case Qt::Key_Left: prevTrack(); break; case Qt::Key_Right: nextTrack(); break; case Qt::Key_Up: incrVolume(); break; case Qt::Key_Down: decrVolume(); break; case Qt::Key_Return: case Qt::Key_Enter: if (isPlaying()) pause(); else play(); break; case Qt::Key_Backspace: stop(); break; default: handled = false; } }
void SourceErrorHandler::handleSourceError (const QString& sourceText, SourceError error) { QString text; const auto& curSource = Source_->GetCurrentSource (); const auto& curPath = curSource.ToUrl ().path (); const auto& filename = "<em>" + QFileInfo { curPath }.fileName () + "</em>"; switch (error) { case SourceError::MissingPlugin: text = tr ("Cannot find a proper audio decoder for file %1. " "You probably don't have all the codec plugins installed.") .arg (filename); text += "<br/>" + sourceText; emit nextTrack (); break; case SourceError::SourceNotFound: text = tr ("Audio source %1 not found, playing next track...") .arg (filename); emit nextTrack (); break; case SourceError::CannotOpenSource: text = tr ("Cannot open source %1, playing next track...") .arg (filename); emit nextTrack (); break; case SourceError::InvalidSource: text = tr ("Audio source %1 is invalid, playing next track...") .arg (filename); emit nextTrack (); break; case SourceError::DeviceBusy: text = tr ("Cannot play %1 because the output device is busy.") .arg (filename); break; case SourceError::Other: text = sourceText; break; } IEM_->HandleEntity (Util::MakeNotification ("LMP", text, Priority::Critical)); }
void squeezeLiteGui::setupInterfaceConnections(void) { DEBUGF("Initialize Interface Connections"); QQuickItem *v = rootObject(); // interface signals to application connect(v,SIGNAL(play(int)), this,SLOT(playState(int))); connect(v,SIGNAL(nextTrack()), this,SLOT(nextTrackClicked())); connect(v,SIGNAL(prevTrack()), this,SLOT(prevTrackClicked())); connect(v,SIGNAL(volUp()), this,SLOT(volUp())); connect(v,SIGNAL(volDown()), this,SLOT(volDown())); connect(v,SIGNAL(setVolume(int)), this,SLOT(setVolume(int))); connect(v,SIGNAL(controlClicked(QString)), this,SLOT(controlViewClicked(QString))); connect(v,SIGNAL(shuffle(int)), this,SLOT(shuffleState(int))); connect(v,SIGNAL(repeat(int)), this,SLOT(repeatState(int))); // connect(v,SIGNAL(playButtonClicked()),this,SLOT(playPauseToggle())); // application signals to interface connect(this,SIGNAL(playlistIndexChange(QVariant)), v, SLOT(setControlViewListIndex(QVariant))); connect(this,SIGNAL(updateAlbumCover(QVariant)), v,SLOT(updateAlbumCover(QVariant))); connect(this,SIGNAL(playStatus(QVariant)), v, SLOT(updatePlayMode(QVariant))); connect(this,SIGNAL(VolumeChange(QVariant)), v,SLOT(setMainVolume(QVariant))); connect(this,SIGNAL(songDuration(QVariant)), v,SLOT(setSongDuration(QVariant))); connect(this,SIGNAL(progress(QVariant)), v,SLOT(updateProgress(QVariant))); connect(m_playerInfo,SIGNAL(PlayingTime(QVariant,QVariant)), v,SLOT(setupSongTimes(QVariant,QVariant))); connect(m_playerInfo,SIGNAL(TimeText(QVariant)),v,SLOT(setTimeText(QVariant))); connect(m_playerInfo,SIGNAL(NewSong()),this,SLOT(NewSong())); connect(&m_tick,SIGNAL(timeout()),m_playerInfo,SLOT(tick())); m_tick.start(1000); /* * messages from device that need to be connected to slots void playlistIndexChange(QVariant newidx); void NewSong(int newPlayListIndex); void NewPlaylist(void); void Mute(bool); void VolumeChange(int); void ModeChange(QString); */ }
void TrackListDBusHandler::aboutToFinish() { m_media->enqueue(nextTrack()); }
void TagDialog::init() { //NOTE We allocate on the stack in Playlist if( parent() != Playlist::instance()->qscrollview() ) setWFlags( getWFlags() | Qt::WDestructiveClose ); KConfig *config = amaroK::config( "TagDialog" ); kTabWidget->addTab( summaryTab, i18n( "Summary" ) ); kTabWidget->addTab( tagsTab, i18n( "Tags" ) ); kTabWidget->addTab( lyricsTab, i18n( "Lyrics" ) ); kTabWidget->addTab( statisticsTab, i18n( "Statistics" ) ); kTabWidget->setCurrentPage( config->readNumEntry( "CurrentTab", 0 ) ); const QStringList artists = CollectionDB::instance()->artistList(); kComboBox_artist->insertStringList( artists ); kComboBox_artist->completionObject()->insertItems( artists ); kComboBox_artist->completionObject()->setIgnoreCase( true ); kComboBox_artist->setCompletionMode( KGlobalSettings::CompletionPopup ); const QStringList albums = CollectionDB::instance()->albumList(); kComboBox_album->insertStringList( albums ); kComboBox_album->completionObject()->insertItems( albums ); kComboBox_album->completionObject()->setIgnoreCase( true ); kComboBox_album->setCompletionMode( KGlobalSettings::CompletionPopup ); const QStringList composers = CollectionDB::instance()->composerList(); kComboBox_composer->insertStringList( composers ); kComboBox_composer->completionObject()->insertItems( composers ); kComboBox_composer->completionObject()->setIgnoreCase( true ); kComboBox_composer->setCompletionMode( KGlobalSettings::CompletionPopup ); kComboBox_rating->insertStringList( MetaBundle::ratingList() ); // const QStringList genres = MetaBundle::genreList(); const QStringList genres = CollectionDB::instance()->genreList(); kComboBox_genre->insertStringList( genres ); kComboBox_genre->completionObject()->insertItems( genres ); kComboBox_genre->completionObject()->setIgnoreCase( true ); // looks better to have a blank label than 0, we can't do this in // the UI file due to bug in Designer kIntSpinBox_track->setSpecialValueText( " " ); kIntSpinBox_year->setSpecialValueText( " " ); kIntSpinBox_score->setSpecialValueText( " " ); kIntSpinBox_discNumber->setSpecialValueText( " " ); if( !AmarokConfig::useRatings() ) { kComboBox_rating->hide(); ratingLabel->hide(); } if( !AmarokConfig::useScores() ) { kIntSpinBox_score->hide(); scoreLabel->hide(); } //HACK due to deficiency in Qt that will be addressed in version 4 // QSpinBox doesn't emit valueChanged if you edit the value with // the lineEdit until you change the keyboard focus connect( kIntSpinBox_year->child( "qt_spinbox_edit" ), SIGNAL(textChanged( const QString& )), SLOT(checkModified()) ); connect( kIntSpinBox_track->child( "qt_spinbox_edit" ), SIGNAL(textChanged( const QString& )), SLOT(checkModified()) ); connect( kIntSpinBox_score->child( "qt_spinbox_edit" ), SIGNAL(textChanged( const QString& )), SLOT(checkModified()) ); connect( kIntSpinBox_discNumber->child( "qt_spinbox_edit" ), SIGNAL(textChanged( const QString& )), SLOT(checkModified()) ); // Connects for modification check connect( kLineEdit_title, SIGNAL(textChanged( const QString& )), SLOT(checkModified()) ); connect( kComboBox_composer, SIGNAL(activated( int )), SLOT(checkModified()) ); connect( kComboBox_artist, SIGNAL(activated( int )), SLOT(checkModified()) ); connect( kComboBox_artist, SIGNAL(textChanged( const QString& )), SLOT(checkModified()) ); connect( kComboBox_album, SIGNAL(activated( int )), SLOT(checkModified()) ); connect( kComboBox_album, SIGNAL(textChanged( const QString& )), SLOT(checkModified()) ); connect( kComboBox_genre, SIGNAL(activated( int )), SLOT(checkModified()) ); connect( kComboBox_genre, SIGNAL(textChanged( const QString& )), SLOT(checkModified()) ); connect( kComboBox_rating, SIGNAL(activated( int )), SLOT(checkModified()) ); connect( kComboBox_rating, SIGNAL(textChanged( const QString& )), SLOT(checkModified()) ); connect( kIntSpinBox_track,SIGNAL(valueChanged( int )), SLOT(checkModified()) ); connect( kIntSpinBox_year, SIGNAL(valueChanged( int )), SLOT(checkModified()) ); connect( kIntSpinBox_score,SIGNAL(valueChanged( int )), SLOT(checkModified()) ); connect( kTextEdit_comment,SIGNAL(textChanged()), SLOT(checkModified()) ); connect( kTextEdit_lyrics, SIGNAL(textChanged()), SLOT(checkModified()) ); // Remember original button text m_buttonMbText = pushButton_musicbrainz->text(); connect( pushButton_cancel, SIGNAL(clicked()), SLOT(cancelPressed()) ); connect( pushButton_ok, SIGNAL(clicked()), SLOT(accept()) ); connect( pushButton_open, SIGNAL(clicked()), SLOT(openPressed()) ); connect( pushButton_previous, SIGNAL(clicked()), SLOT(previousTrack()) ); connect( pushButton_next, SIGNAL(clicked()), SLOT(nextTrack()) ); connect( checkBox_perTrack, SIGNAL(clicked()), SLOT(perTrack()) ); // draw an icon onto the open-in-konqui button pushButton_open->setIconSet( kapp->iconLoader()->loadIconSet( "fileopen", KIcon::Small ) ); //Update lyrics on Context Browser connect( this, SIGNAL(lyricsChanged( const QString& )), ContextBrowser::instance(), SLOT( lyricsChanged( const QString& ) ) ); //Update cover connect( CollectionDB::instance(), SIGNAL( coverFetched( const QString&, const QString& ) ), this, SLOT( loadCover( const QString&, const QString& ) ) ); connect( CollectionDB::instance(), SIGNAL( coverChanged( const QString&, const QString& ) ), this, SLOT( loadCover( const QString&, const QString& ) ) ); #if HAVE_TUNEPIMP connect( pushButton_musicbrainz, SIGNAL(clicked()), SLOT(musicbrainzQuery()) ); #else QToolTip::add( pushButton_musicbrainz, i18n("Please install MusicBrainz to enable this functionality") ); #endif connect( pushButton_guessTags, SIGNAL(clicked()), SLOT( guessFromFilename() ) ); connect( pushButton_setFilenameSchemes, SIGNAL(clicked()), SLOT( setFileNameSchemes() ) ); if( m_urlList.count() ) { //editing multiple tracks m_perTrack = false; setMultipleTracksMode(); readMultipleTracks(); checkBox_perTrack->setChecked( m_perTrack ); if( m_urlList.count() == 1 ) { checkBox_perTrack->setEnabled( false ); pushButton_previous->setEnabled( false ); pushButton_next->setEnabled( false ); } else { checkBox_perTrack->setEnabled( true ); pushButton_previous->setEnabled( m_perTrack ); pushButton_next->setEnabled( m_perTrack ); } } else { m_perTrack = true; checkBox_perTrack->hide(); if( !m_playlistItem ) { pushButton_previous->hide(); pushButton_next->hide(); } loadLyrics( m_bundle.url() ); readTags(); } // make it as small as possible resize( sizeHint().width(), minimumSize().height() ); }
int JukeboxDS::player() { if( FAILED(CoInitialize(NULL)) ) return -1; IGraphBuilder * pGB = NULL; IMediaControl * pMC = NULL; IBasicAudio * pBA = NULL; IMediaEvent * pME = NULL; while( m_Active ) { // check the state of the music, if stopped move onto the next file if ( pME != NULL ) { long eventCode; if ( pME->WaitForCompletion( 0, &eventCode ) == S_OK ) nextTrack(); // current song has ended, next track } // check for a volume change if ( m_UpdateVolume.signaled() ) { m_UpdateVolume.clear(); if ( pBA != NULL ) { // set the volume long pv = (100 - m_Volume) * -100; pBA->put_Volume( pv ); } } if (! m_TrackEvent.wait( 250 ) ) { AutoLock lock( &m_Lock ); if ( m_PlayLists.isValid( m_ActiveList ) && m_PlayLists[ m_ActiveList ].files.isValid( m_CurrentTrack ) ) { // get the filename of the current track CharString file = m_PlayLists[ m_ActiveList ].files[ m_CurrentTrack ]; // release the previous interfaces RELEASEQI( pGB ); RELEASEQI( pMC ); RELEASEQI( pBA ); RELEASEQI( pME ); // Create DirectShow Graph if ( FAILED( CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC, IID_IGraphBuilder, (void **)&pGB) ) ) return -1; try { // load the first file if ( FAILED( pGB->RenderFile( String( file ), NULL ) ) ) return -1; } catch( ... ) { // driver failure, don't crash the game due to a bad codec.. return -1; } // Get the IMediaControl Interface if ( FAILED( pGB->QueryInterface(IID_IMediaControl, (void **)&pMC ) ) ) return -1; // Get the IBasicAudio interface if ( FAILED( pGB->QueryInterface(IID_IBasicAudio, (void **)&pBA) ) ) return -1; // Get the IBasicAudio interface if ( FAILED( pGB->QueryInterface(IID_IMediaEvent, (void **)&pME) ) ) return -1; // set the volume long pv = (100 - m_Volume) * -100; pBA->put_Volume( pv ); // play the music pMC->Run(); } } } RELEASEQI( pGB ); RELEASEQI( pMC ); RELEASEQI( pBA ); RELEASEQI( pME ); CoUninitialize(); return 0; }
/* Update playlist */ void bshAudioPlaylist::Update() { if(Mix_PlayingMusic() == 0) nextTrack(); }
CarPI::CarPI(QObject * parent): QObject(parent) { qDebug() << "CarPI: Starting"; _sourceCurrent = sourceUnknown; _sourcePaused = false; /* Kontroler płyty głównej urządzenia */ _mainboard = MainBoard::getInstance(); /* Emulator wyświetlacza radia */ _displayEmulator = DisplayEmulator::getInstance(); /* Emulator zmieniarki CD */ _changerEmulator = ChangerEmulator::getInstance(); /* Kontroler modułu bluetooth */ _bluetooth = Bluetooth::getInstance(); /* Odtwarzacz MP3 */ _mp3Player = MP3Player::getInstance(); /* Nawigacja */ _navit = Navit::getInstance(); /* Interfejs OBD II */ _elm327 = Elm327::getInstance(); _atmosphericPressure = 100; /* Zakładamy ciśnienie 1000hPa */ connect(_mainboard, SIGNAL(radioPowerChanged(bool)), _displayEmulator, SLOT(radioPowerChanged(bool))); connect(_mainboard, SIGNAL(keyStateChanged(int)), this, SLOT(_pilotKeyStateChanged(int))); connect(_mainboard, SIGNAL(ignitionChanged(bool)), this, SLOT(_ignitionStateChanged(bool))); connect(_mainboard, SIGNAL(shutdown()), this, SLOT(shutdown())); connect(_displayEmulator, SIGNAL(displayTextChanged(QString)), this, SLOT(_displayTextChanged(QString))); connect(_displayEmulator, SIGNAL(displayIconsChanged(int)), this, SLOT(_displayIconsChanged(int))); connect(_displayEmulator, SIGNAL(displayMenuShow(int)), this, SLOT(_displayMenuShow(int))); connect(_displayEmulator, SIGNAL(displayMenuHide()), this, SLOT(_displayMenuHide())); connect(_displayEmulator, SIGNAL(displayMenuItemUpdate(int,QString,bool)), this, SLOT(_displayMenuSetItem(int,QString,bool))); connect(this, SIGNAL(radioNewKeyEvent(int)), _displayEmulator, SLOT(sendKeyEvent(int))); connect(_bluetooth, SIGNAL(connectionStateChanged(bool)), this, SLOT(_bluetoothConnectionStateChanged(bool))); connect(_bluetooth, SIGNAL(callStateChanged(BluetoothCallState,QString)), this, SLOT(_bluetoothCallStateChanged(BluetoothCallState,QString))); connect(_changerEmulator, SIGNAL(playbackStarted()), _mp3Player, SLOT(play())); connect(_changerEmulator, SIGNAL(playbackPaused()), _mp3Player, SLOT(pause())); connect(_changerEmulator, SIGNAL(playbackStopped()), _mp3Player, SLOT(stop())); connect(_changerEmulator, SIGNAL(nextTrack()), _mp3Player, SLOT(nextTrack())); connect(_changerEmulator, SIGNAL(prevTrack()), _mp3Player, SLOT(prevTrack())); connect(_changerEmulator, SIGNAL(loadCD(int)), this, SLOT(_changerEmulatorLoadCD(int))); connect(_mp3Player, SIGNAL(textChanged(QString)), this, SLOT(_mp3PlayerTextChanged(QString))); connect(this, SIGNAL(mp3PlayerNextAlbum()), _mp3Player, SLOT(nextAlbum())); connect(this, SIGNAL(mp3PlayerPrevAlbum()), _mp3Player, SLOT(prevAlbum())); connect(this, SIGNAL(mp3PlayerSwitchDisplayMode()), _mp3Player, SLOT(switchDisplayMode())); connect(_elm327, SIGNAL(pidValueChanged(int,QVector<int>)), this, SLOT(_elm327PidChanged(int,QVector<int>))); connect(_elm327, SIGNAL(voltageChanged(double)), this, SLOT(_elm327VoltageChanged(double))); connect(this, SIGNAL(elm327addWatchPid(int)), _elm327, SLOT(addWatchPid(int))); connect(this, SIGNAL(elm327start()), _elm327, SLOT(start())); connect(this, SIGNAL(elm327stop()), _elm327, SLOT(stop())); _mainboard->readState(); emit elm327addWatchPid(0x05); /* Temperatura wody */ emit elm327addWatchPid(0x04); /* Obciążenie silnika */ emit elm327addWatchPid(0x0B); /* Ciśnienie absolutne w kolektorze dolotowym */ emit elm327addWatchPid(0x0F); /* Temperatura powietrza w dolocie */ emit elm327addWatchPid(0x23); /* Ciśnienie paliwa */ }
SmoozikSimplestClientWindow::SmoozikSimplestClientWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::SmoozikSimplestClientWindow) { ui->setupUi(this); // Initialize SmoozikManager smoozikManager = new SmoozikManager(APIKEY, SECRET, SmoozikManager::XML, false, this); smoozikPlaylist = new SmoozikPlaylist; connect(smoozikManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(processNetworkReply(QNetworkReply*))); // Initialize music directory #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) _dirName = QDesktopServices::storageLocation(QDesktopServices::MusicLocation); #else _dirName = QStandardPaths::writableLocation(QStandardPaths::MusicLocation); #endif // Initialize playlist filler ui->setupUi(this); smoozikPlaylistFillerThread = new QThread(); smoozikPlaylistFiller = new SmoozikPlaylistFiller(smoozikPlaylist); smoozikPlaylistFiller->moveToThread(smoozikPlaylistFillerThread); connect(smoozikPlaylistFiller, SIGNAL(trackFound(QString,QString,QString,QString,uint)), this, SLOT(addTrackToPlaylist(QString,QString,QString,QString,uint))); connect(smoozikPlaylistFiller, SIGNAL(tracksRetrieved()), this, SIGNAL(tracksRetrieved())); connect(smoozikPlaylistFiller, SIGNAL(noTrackRetrieved()), this, SLOT(noTrackRetrievedMessage())); connect(smoozikPlaylistFiller, SIGNAL(maxPlaylistSizeReached()), this, SLOT(maxPlaylistSizeReachedMessage())); connect(smoozikPlaylistFillerThread, SIGNAL(started()), smoozikPlaylistFiller, SLOT(fillPlaylist())); connect(smoozikPlaylistFiller, SIGNAL(finished()), smoozikPlaylistFillerThread, SLOT(quit()), Qt::DirectConnection); // Initialize player #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) player = new Phonon::MediaObject(this); Phonon::AudioOutput *audioOutput = new Phonon::AudioOutput(Phonon::MusicCategory, this); Phonon::createPath(player, audioOutput); connect(player, SIGNAL(currentSourceChanged(Phonon::MediaSource)), this, SLOT(updateTrackLabels())); connect(player, SIGNAL(stateChanged(Phonon::State,Phonon::State)), this, SLOT(playerStateChanged())); #else player = new QMediaPlayer(this); player->setPlaylist(new QMediaPlaylist(player)); player->playlist()->setPlaybackMode(QMediaPlaylist::Sequential); connect(player, SIGNAL(currentMediaChanged(QMediaContent)), this, SLOT(updateTrackLabels())); connect(player, SIGNAL(stateChanged(QMediaPlayer::State)), this, SLOT(playerStateChanged())); #endif connect(ui->playButton, SIGNAL(clicked()), player, SLOT(play())); connect(ui->pauseButton, SIGNAL(clicked()), player, SLOT(pause())); connect(this, SIGNAL(currentTrackSet()), this, SLOT(updateTrackLabels())); connect(this, SIGNAL(nextTrackSet()), this, SLOT(updateTrackLabels())); // Initialize main state machine which controls what is displayed QStateMachine *mainStateMachine = new QStateMachine(this); QState *mainState = new QState(mainStateMachine); QState *loginState = new QState(mainState); QState *startPartyState = new QState(mainState); QState *connectedState = new QState(mainState); QState *retrieveTracksState = new QState(connectedState); QState *sendPlaylistState = new QState(connectedState); QState *getTopTracksState = new QState(connectedState); QState *partyState = new QState(connectedState); QState *waitingState = new QState(partyState); QState *sendCurrentTrackState = new QState(partyState); QState *sendNextTrackState = new QState(partyState); QStateMachine *playerStateMachine = new QStateMachine(this); QState *playerState = new QState(playerStateMachine); QState *playingState = new QState(playerState); QState *pausedState = new QState(playerState); // Define state initial states and transitions mainStateMachine->setInitialState(mainState); mainState->setInitialState(loginState); connectedState->setInitialState(retrieveTracksState); partyState->setInitialState(waitingState); playerStateMachine->setInitialState(playerState); playerState->setInitialState(pausedState); mainState->addTransition(this, SIGNAL(disconnected()), loginState); loginState->addTransition(this, SIGNAL(loggedIn()), startPartyState); startPartyState->addTransition(this, SIGNAL(partyStarted()), connectedState); connectedState->addTransition(ui->changePlaylistButton, SIGNAL(clicked()), retrieveTracksState); retrieveTracksState->addTransition(this, SIGNAL(tracksRetrieved()), sendPlaylistState); sendPlaylistState->addTransition(this, SIGNAL(playlistSent()), getTopTracksState); getTopTracksState->addTransition(this, SIGNAL(currentTrackSet()), sendCurrentTrackState); sendCurrentTrackState->addTransition(this, SIGNAL(currentTrackSent()), getTopTracksState); getTopTracksState->addTransition(this, SIGNAL(nextTrackSet()), sendNextTrackState); sendNextTrackState->addTransition(this, SIGNAL(nextTrackSent()), waitingState); #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) waitingState->addTransition(player, SIGNAL(currentSourceChanged(Phonon::MediaSource)), sendCurrentTrackState); #else waitingState->addTransition(player, SIGNAL(currentMediaChanged(QMediaContent)), sendCurrentTrackState); #endif playerState->addTransition(this, SIGNAL(playing()), playingState); playerState->addTransition(this, SIGNAL(paused()), pausedState); // Define state properties loginState->assignProperty(this, "state", Login); loginState->assignProperty(ui->stackedWidget, "currentIndex", ui->stackedWidget->indexOf(ui->loginPage)); loginState->assignProperty(ui->loginButton, "enabled", true); loginState->assignProperty(ui->disconnectButton, "visible", false); loginState->assignProperty(ui->changePlaylistButton, "visible", false); loginState->assignProperty(ui->usernameLineEdit, "enabled", true); loginState->assignProperty(ui->passwordLineEdit, "enabled", true); loginState->assignProperty(ui->loginStateLabel, "text", QString()); startPartyState->assignProperty(this, "state", StartParty); startPartyState->assignProperty(ui->loginStateLabel, "text", tr("Starting party...")); startPartyState->assignProperty(ui->disconnectButton, "visible", false); startPartyState->assignProperty(ui->changePlaylistButton, "visible", false); connectedState->assignProperty(ui->disconnectButton, "visible", true); retrieveTracksState->assignProperty(ui->stackedWidget, "currentIndex", ui->stackedWidget->indexOf(ui->loadingPage)); retrieveTracksState->assignProperty(ui->loginStateLabel, "text", tr("Connected")); retrieveTracksState->assignProperty(ui->loadingLabel, "text", tr("Retrieving tracks...")); retrieveTracksState->assignProperty(ui->changePlaylistButton, "visible", false); sendPlaylistState->assignProperty(this, "state", SendPlaylist); sendPlaylistState->assignProperty(ui->loadingLabel, "text", tr("Sending playlist...")); sendPlaylistState->assignProperty(ui->changePlaylistButton, "visible", true); getTopTracksState->assignProperty(this, "state", GetTopTracks); getTopTracksState->assignProperty(ui->loadingLabel, "text", tr("Get top tracks...")); getTopTracksState->assignProperty(ui->nextButton, "enabled", false); getTopTracksState->assignProperty(ui->changePlaylistButton, "visible", true); partyState->assignProperty(ui->stackedWidget, "currentIndex", ui->stackedWidget->indexOf(ui->playerPage)); partyState->assignProperty(ui->changePlaylistButton, "visible", true); sendCurrentTrackState->assignProperty(this, "state", SendCurrentTrack); sendCurrentTrackState->assignProperty(ui->nextButton, "enabled", false); sendNextTrackState->assignProperty(this, "state", SendNextTrack); sendNextTrackState->assignProperty(ui->nextButton, "enabled", false); waitingState->assignProperty(ui->nextButton, "enabled", true); playingState->assignProperty(ui->playButton, "visible", false); playingState->assignProperty(ui->pauseButton, "visible", true); pausedState->assignProperty(ui->playButton, "visible", true); pausedState->assignProperty(ui->pauseButton, "visible", false); // Connect states and actions connect(startPartyState, SIGNAL(entered()), this, SLOT(startParty())); connect(retrieveTracksState, SIGNAL(entered()), this, SLOT(retrieveTracksDialog())); connect(sendPlaylistState, SIGNAL(entered()), this, SLOT(sendPlaylist())); connect(getTopTracksState, SIGNAL(entered()), this, SLOT(getTopTracks())); connect(sendCurrentTrackState, SIGNAL(entered()), this, SLOT(sendCurrentTrack())); connect(sendNextTrackState, SIGNAL(entered()), this, SLOT(sendNextTrack())); // Connect gui and actions connect(ui->usernameLineEdit, SIGNAL(returnPressed()), this, SLOT(submitLogin())); connect(ui->passwordLineEdit, SIGNAL(returnPressed()), this, SLOT(submitLogin())); connect(ui->loginButton, SIGNAL(clicked()), this, SLOT(submitLogin())); connect(ui->nextButton, SIGNAL(clicked()), this, SLOT(nextTrack())); connect(ui->disconnectButton, SIGNAL(clicked()), this, SLOT(disconnect())); // Start state machine mainStateMachine->start(); playerStateMachine->start(); }
void ttmexample ( char* inpDir = "", // MuDST directory char* inpFile = "ttm.lis", // MuDST file(s); char* outFile = "ttm.ndst.root",// output nano dst root file Int_t nFiles = 150, // # of MuDST file(s) Int_t nEvents = -1 // # of events ) // NOTES: // 1. EEmcTTMMaker main "product" is a list of EEmcTTMatch'es which in turn are // EEmcTower plus a list of StMuTrack's that fullfill certain criteria. // 2. Optionally the Maker created a nanoDst file [ or a 'Not-a-Dst' file :) ] // { // load root/root4star libraries gROOT->LoadMacro("$STAR/StRoot/StMuDSTMaker/COMMON/macros/loadSharedLibraries.C"); loadSharedLibraries(); // load more libraries :) gSystem->Load("libmysqlclient"); gSystem->Load("StDbLib"); gSystem->Load("StDbBroker"); gSystem->Load("St_db_Maker"); // load even more libraries (EEMC stuff) gSystem->Load("StEEmcUtil"); gSystem->Load("StEEmcDbMaker"); gSystem->Load("StEEmcPoolTTM"); // create the chain chain = new StChain("StChain"); // now we add Makers to the chain... some of that is black magic to me :) muDstMaker = new StMuDstMaker(0,0,inpDir,inpFile,"",nFiles); // muDST main chain StMuDbReader *db = StMuDbReader::instance(); // need the database St_db_Maker *dbMk = new St_db_Maker("StarDb", "MySQL:StarDb"); // need more db? StEEmcDbMaker *eemcDbMaker = new StEEmcDbMaker("eemcDb"); // need EEMC database // now comment in/out/change the below if you want it your way eemcDbMaker->setSectors(1,12); // request sectors you need (default:1-12) eemcDbMaker->setPreferedFlavor("onlped","eemcPMTped"); // request alternative db flavor // finally after so many lines we arrive at the good stuff ttm = new EEmcTTMMaker ("TTM",muDstMaker,eemcDbMaker); ttm->SetFileName(outFile); // output nanoDst file // have cuts your way (optional) ttm->SetMaxCTBSum(1000); ttm->SetMinTrackLength(20.0); ttm->SetMinTrackHits(5); ttm->SetMinTrackPt(0.5); ttm->SetMinTrackEta(0.7); ttm->SetMaxTrackEta(2.2); ttm->SetDeltaEtaCut(0.7); // ! note this is a fraction of tower width in eta ttm->SetDeltaPhiCut(0.7); // ! note this is a fraction of tower width in phi // this is even more optional :) // the lines here repeat the default // ttm->ResetZPositionsArray(); // ttm->AddZPosition("pres",kEEmcZPRE1+0.1); // ttm->AddZPosition("post",kEEmcZPOST-0.1); // ttm->AddZPosition("smd" ,kEEmcZSMD); ttm->Summary(cout); // prints cut summary StMuDebug::setLevel(0); chain->Init(); chain->ls(3); //--------------------------------------------------- int stat=0; int event=0; while(++event<nEvents) { stat=chain->Make(); // STAR intelligence: stat=2 EOF,stat=4 FATAL; if so break the loop // if not OK (and not EOF nor FATAL) !!! try another event if( stat==2 || stat==4) break; if( stat!=0 ) continue; // if no track to tower matches try another event if(ttm->GetMatchList()->IsEmpty()) continue; // set up iterator and pointers TIter nextMatch(ttm->GetMatchList()); EEmcTTMatch *tmatch; EEmcTower *tower; StMuTrack *track; //event info (for fun), it shows we like xml StEventInfo &evInfo = muDstMaker->muDst()->event()->eventInfo(); cerr << "<Event"; cerr << "Run=\"" << evInfo.runId() << "\"\t"; cerr << "Event=\""<< evInfo.id() << "\">\n"; // loop over all towers with track hits while ((tmatch = (EEmcTTMatch*) nextMatch())) { tmatch->Out(cerr); // prints all match info tower = tmatch->Tower(); // here's how to acces tower information const char *tLabel = tower->TowerLabel(); int sector = tower->Sec(); // 0..11 int subsec = tower->SubSec(); // 0..4 int etabin = tower->Eta(); // 0..11 float adc = tower->ADC(); // adc - pedestal float de = tower->dE(); // (adc - pedestal)/gain // int seclab = tower->SecLabel(); // 1..12 int sublab = tower->SubSecLabel(); // A..E int etalab = tower->EtaLabel(); // 1..12 // now more than one track may hit a tower TIter nextTrack(tmatch->Tracks()); while((track=(StMuTrack *)nextTrack())) { // how to access StMuTrack consult muDST manual (does not exist) TVector3 r; // for example one could extrapolate track to a given z-depth EEmcTTMatch::ExtrapolateToZ(track,290.0,r); double pt = track->pt(); double x = r.x(); } } cerr << "</Event>" << endl; } ttm->Summary(cerr); }