Amarok::OSD::OSD() : OSDWidget( 0 ) { s_instance = this; EngineController* const engine = The::engineController(); if( engine->isPlaying() ) trackPlaying( engine->currentTrack() ); connect( engine, SIGNAL( trackPlaying( Meta::TrackPtr ) ), this, SLOT( trackPlaying( Meta::TrackPtr ) ) ); connect( engine, SIGNAL( stopped( qint64, qint64 ) ), this, SLOT( stopped() ) ); connect( engine, SIGNAL( paused() ), this, SLOT( paused() ) ); connect( engine, SIGNAL( trackMetadataChanged( Meta::TrackPtr ) ), this, SLOT( metadataChanged() ) ); connect( engine, SIGNAL( albumMetadataChanged( Meta::AlbumPtr ) ), this, SLOT( metadataChanged() ) ); connect( engine, SIGNAL( volumeChanged( int ) ), this, SLOT( volumeChanged( int ) ) ); connect( engine, SIGNAL( muteStateChanged( bool ) ), this, SLOT( muteStateChanged( bool ) ) ); }
TimecodeObserver::TimecodeObserver( QObject *parent ) : QObject( parent ) , m_trackTimecodeable ( false ) , m_currentTrack ( 0 ) , m_currPos ( 0 ) { EngineController *engine = The::engineController(); connect( engine, SIGNAL(stopped(qint64,qint64)), this, SLOT(stopped(qint64,qint64)) ); connect( engine, SIGNAL(trackPlaying(Meta::TrackPtr)), this, SLOT(trackPlaying(Meta::TrackPtr)) ); connect( engine, SIGNAL(trackPositionChanged(qint64,bool)), this, SLOT(trackPositionChanged(qint64,bool)) ); }
void PlayerWidget::sendCommand( const QString &command, const QString ¶meter ) { if( mpSocket->state() == QAbstractSocket::ConnectedState ) { QString cmd( command ); if( command == "start" ) { if( mpFSM->getState() == PlayerFSM::playing ) { mpDatabase->getTrackInfo( &mTrackInfo ); emit trackPlaying( mTrackInfo ); } } if( command != "preread" ) { cmd.append( ' ' ); cmd.append( '0' + mPlayer ); } if( !parameter.isEmpty() ) { cmd.append( ' ' ); cmd.append( parameter ); } cmd.append( '\n' ); QByteArray block( cmd.toLocal8Bit() ); if( mConsole ) { std::cout << mPlayer << '>' << block.data(); } mpSocket->write( block ); } }
void AudioPlayer::play(PModel playlistModel, const QModelIndex& index) { if (!index.isValid()) return; PTrack currentlyPlayingTrack = playingTrack_; setPlaying(playlistModel, index); setBuffering(PModel(), QModelIndex()); if (!playingTrack_) return; if (currentlyPlayingTrack && audioOutput_->state() == AudioState::Playing && currentlyPlayingTrack->isCueTrack() && playingTrack_->isCueTrack() && currentlyPlayingTrack->location == playingTrack_->location) { // Playing in the same cue file audioOutput_->seek(playingTrack_->cueOffset()); emit trackPlaying(playingTrack_); emit trackPositionChanged(0, true); } else { audioOutput_->clearQueue(); audioOutput_->setCurrentSource(playingTrack_->location); setVolume(volume_); if (playingTrack_->isCueTrack()) { audioOutput_->play(playingTrack_->cueOffset()); } else audioOutput_->play(); } }
ScrobblerAdapter::ScrobblerAdapter( QObject *parent, const QString &clientId ) : QObject( parent ), m_scrobbler( new lastfm::Audioscrobbler( clientId ) ), m_clientId( clientId ), m_lastSaved( 0 ) { DEBUG_BLOCK resetVariables(); //HACK work around a bug in liblastfm---it doesn't create its config dir, so when it // tries to write the track cache, it fails silently. until we have a fixed version, do this // path finding code taken from liblastfm/src/misc.cpp QString lpath = QDir::home().filePath( ".local/share/Last.fm" ); QDir ldir = QDir( lpath ); if( !ldir.exists() ) { ldir.mkpath( lpath ); } connect( The::mainWindow(), SIGNAL( loveTrack( Meta::TrackPtr) ), SLOT( loveTrack( Meta::TrackPtr ) ) ); connect( The::mainWindow(), SIGNAL( banTrack() ), SLOT( banTrack() ) ); EngineController *engine = The::engineController(); connect( engine, SIGNAL( stopped( qint64, qint64 ) ), this, SLOT( stopped( qint64, qint64 ) ) ); connect( engine, SIGNAL( trackPositionChanged( qint64, bool ) ), this, SLOT( trackPositionChanged( qint64, bool ) ) ); //Use trackChanged instead of trackPlaying to prevent reset of current track after Unpausing. connect( engine, SIGNAL( trackChanged( Meta::TrackPtr ) ), this, SLOT( trackPlaying( Meta::TrackPtr ) ) ); connect( engine, SIGNAL( trackMetadataChanged( Meta::TrackPtr ) ), this, SLOT( trackMetadataChanged( Meta::TrackPtr ) ) ); }
void AudioPlayer::metadataChanged(QString title, QString audioFormat, int sampleRate) { if (!playingTrack_) return; if (playingTrack_->updateMetadata(title, audioFormat, sampleRate)) { if (playingModel_) playingModel_->libraryChanged(LibraryEvent(playingTrack_, LibraryEventType::MODIFY)); // Update UI emit trackPlaying(playingTrack_); } }
void AudioPlayer::durationChanged(double duration) { if (!playingTrack_) return; if (playingTrack_->updateDuration(static_cast<int>(duration))) { if (playingModel_) playingModel_->libraryChanged(LibraryEvent(playingTrack_, LibraryEventType::MODIFY)); // Update UI emit trackPlaying(playingTrack_); } }
void AudioPlayer::currentSourceChanged() { // qDebug() << "currentSourceChanged() " << audioOutput_->currentTime() << " " << audioOutput_->totalTime(); if (queue_.peeked()) { auto p = queue_.peekTrack(); if (p.first == bufferingTrackPlaylist_ && p.second == bufferingIndex_) queue_.popPeekedTrack(); } if (bufferingTrackPlaylist_) { setPlaying(bufferingTrackPlaylist_, bufferingIndex_); setBuffering(PModel(), QModelIndex(), true); } if (playingTrack_) { setVolume(volume_); emit trackPlaying(playingTrack_); emit trackPositionChanged(0, true); } else { qDebug() << "Source changed to null track!"; } aboutToFinish(); }
ProgressWidget::ProgressWidget( QWidget *parent ) : QWidget( parent ) { QHBoxLayout *box = new QHBoxLayout( this ); setLayout( box ); box->setMargin( 0 ); box->setSpacing( 4 ); m_slider = new Amarok::TimeSlider( this ); m_slider->setToolTip( i18n( "Track Progress" ) ); m_slider->setMaximumSize( 600000, 20 ); m_timeLabelLeft = new TimeLabel( this ); m_timeLabelRight = new TimeLabel( this ); m_timeLabelRight->setAlignment( Qt::AlignRight ); updateTimeLabelTooltips(); m_timeLabelLeft->setShowTime( false ); m_timeLabelLeft->setAlignment( Qt::AlignRight ); m_timeLabelRight->setShowTime( false ); m_timeLabelRight->setAlignment( Qt::AlignLeft ); m_timeLabelLeft->show(); m_timeLabelRight->show(); box->addSpacing( 3 ); box->addWidget( m_timeLabelLeft ); box->addWidget( m_slider ); box->addWidget( m_timeLabelRight ); EngineController *engine = The::engineController(); if( engine->isPaused() ) paused(); else if( engine->isPlaying() ) trackPlaying(); else stopped(); connect( engine, SIGNAL(stopped(qint64,qint64)), this, SLOT(stopped()) ); connect( engine, SIGNAL(paused()), this, SLOT(paused()) ); connect( engine, SIGNAL(trackPlaying(Meta::TrackPtr)), this, SLOT(trackPlaying()) ); connect( engine, SIGNAL(trackLengthChanged(qint64)), this, SLOT(trackLengthChanged(qint64)) ); connect( engine, SIGNAL(trackPositionChanged(qint64,bool)), this, SLOT(trackPositionChanged(qint64)) ); connect( m_slider, SIGNAL(sliderReleased(int)), engine, SLOT(seekTo(int)) ); connect( m_slider, SIGNAL(valueChanged(int)), SLOT(drawTimeDisplay(int)) ); setBackgroundRole( QPalette::BrightText ); connect ( The::amarokUrlHandler(), SIGNAL(timecodesUpdated(const QString*)), this, SLOT(redrawBookmarks(const QString*)) ); connect ( The::amarokUrlHandler(), SIGNAL(timecodeAdded(QString,int)), this, SLOT(addBookmark(QString,int)) ); }
MainWindow::MainWindow(AudioPlayer &player, QWidget *parent) : QMainWindow(parent), statusBar_(this), player_(player), cursorFollowsPlayback_(false), saveTabs_(false) { setupUi(this); // Not saving a pointer to this QActionGroup *playbackOrderGroup = new QActionGroup(this); playbackOrderGroup->addAction(defaultAction); playbackOrderGroup->addAction(randomAction); playbackOrderGroup->addAction(repeatTrackAction); playbackOrderGroup->addAction(repeatPlaylistAction); installEventFilter(this); player.setMainWindow(this); QObject::connect(&player_, SIGNAL(playbackOrderChanged(PlaybackOrder)), this, SLOT(playbackOrderChanged(PlaybackOrder))); QObject::connect(&player_, SIGNAL(audioStateChanged(AudioState)), this, SLOT(slotAudioStateChanged(AudioState))); QObject::connect(&player_, SIGNAL(trackPlaying(PTrack)), this, SLOT(updateUI(PTrack))); playbackOrderChanged(player.playbackOrder()); QObject::connect(&player_, SIGNAL(tick(qint64)), this, SLOT(tick(qint64))); seekSlider_ = new SeekSlider(player_, this); volumeSlider_ = new QSlider(this); volumeSlider_->setOrientation(Qt::Horizontal); volumeSlider_->setMaximum(100); volumeSlider_->setMinimum(0); volumeSlider_->setValue(player_.volume() * 100); volumeSlider_->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum); QObject::connect(volumeSlider_, SIGNAL(valueChanged(int)), this, SLOT(volumeChanged(int))); mainToolBar->addWidget(seekSlider_); mainToolBar->addWidget(volumeSlider_); trayIcon_ = new QSystemTrayIcon(this); setTrayIcon(false); connect(trayIcon_, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(iconActivated(QSystemTrayIcon::ActivationReason))); trayIcon_->show(); setStatusBar(&statusBar_); QObject::connect(&statusBar_, SIGNAL(statusBarDoubleClicked()), this, SLOT(statusBarDoubleClicked())); lyricsDock_ = new QDockWidget("Lyrics", this); // Not setting an object name because we don't want save its state // since Qt doesn't restore it correctly // lyricsDock_->setObjectName("LyricsDock"); lyricsWidget_ = new QPlainTextEdit(lyricsDock_); // lyricsWidget_->setObjectName("LyricsWidget"); lyricsWidget_->setReadOnly(true); lyricsDock_->setWidget(lyricsWidget_); QObject::connect(lyricsDock_, SIGNAL(visibilityChanged(bool)), this, SLOT(dockVisibilityChanged(bool))); // playlistTabs->setTabsClosable(true); QObject::connect(playlistTabs, SIGNAL(tabCloseRequested(int)), this, SLOT(removePlaylistTab(int))); QObject::connect(playlistTabs, SIGNAL(newTabRequested()), this, SLOT(newTabRequested())); QObject::connect(menu_File, SIGNAL(aboutToShow()), this, SLOT(menuFileAboutToShow())); setWindowIcon(QIcon(":/icon/logo22.png")); instance = this; console_ = new ConsoleWindow(this); QObject::connect(console_, SIGNAL(visibilityChanged(bool)), this, SLOT(consoleVisibilityChanged(bool))); readSettings(); config_.set("mainwindow.save_tabs", QVariant(saveTabs_)); QObject::connect(&config_, SIGNAL(keySet(QString, QVariant)), this, SLOT(configChanged(QString, QVariant))); setShortcuts(); }
ControlWidget::ControlWidget( Database *database, PartymanConfigDialog *config, PartymanMainWindow *parent ) : QWidget( parent ) , mpConfig( config ) , mpPlaylist( parent ) , mpSatellite( Satellite::get() ) , mpGenericSatelliteHandler( 0 ) , mPartymanIcon( QIcon( ":/Partyman/Icon.png" ) ) , mStopIcon( QCommonStyle().standardIcon(QStyle::SP_MediaStop) /*QIcon(":/Stop.png")*/ ) , mPlayIcon( QCommonStyle().standardIcon(QStyle::SP_MediaPlay) /*QIcon(":/Play.png")*/ ) , mPauseIcon( QCommonStyle().standardIcon(QStyle::SP_MediaPause) /*QIcon(":/Pause.png")*/ ) , mSkipIcon( QCommonStyle().standardIcon(QStyle::SP_MediaSkipForward) /*QIcon(":/Skip.png")*/ ) , mLoadIcon( QIcon( ":/Partyman/Load.png" ) ) , mpSettingsButton( new QPushButton( tr("Settings"), this ) ) , mpStartButton( new QToolButton( /*tr("Connect"),*/ this ) ) , mpSkipButton( new QToolButton( /*mSkipIcon, tr("Next"),*/ this ) ) , mpTrayIcon( new QSystemTrayIcon( this ) ) , mpTrayIconStopMenu( new QMenu( this ) ) , mpTrayIconPlayMenu( new QMenu( this ) ) , mpStartButtonMenu( new QMenu( mpStartButton ) ) , mpPlayAction( mpTrayIconStopMenu->addAction( mPlayIcon, tr("Start" ) ) ) , mpSkipAction( mpTrayIconPlayMenu->addAction( mSkipIcon, tr("Next" ) ) ) , mpPauseAction( mpStartButtonMenu->addAction( mPauseIcon, tr("Pause" ) ) ) , mpStopAction( mpStartButtonMenu->addAction( mStopIcon, tr("Disconnect" ) ) ) , mpLoadAction( mpStartButtonMenu->addAction( mLoadIcon, tr("Load" ) ) ) , mpTrayIconClickTimer( new QTimer( this ) ) , mConnected( false ) , mPaused( false ) , mKioskMode( false ) , mpDerMixDprocess( new QProcess( this ) ) , mpLoggerProcess( new QProcess( this ) ) , mWaitForDerMixD( false ) , mDerMixDstarted( false ) , mLastP0p() { CrashCleanup::addObject( mpDerMixDprocess ); setAcceptDrops( true ); setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); mpSettingsButton->setObjectName( QString("SettingsButton") ); mpPlayer[0] = new PlayerWidget( 0, database, this ); mpPlayer[1] = new PlayerWidget( 1, database, this ); mpTrayIconClickTimer->setSingleShot( true ); QGridLayout *mainLayout = new QGridLayout( this ); mainLayout->setContentsMargins( 3, 3, 3 ,3 ); mainLayout->setSpacing( 5 ); mainLayout->addWidget( mpPlayer[0], 1, 0, 4, 1 ); mainLayout->addWidget( mpPlayer[1], 1, 2, 4, 1 ); mainLayout->addWidget( mpSettingsButton, 1, 1 ); mainLayout->addWidget( mpStartButton, 3, 1 ); mainLayout->addWidget( mpSkipButton, 4, 1 ); mainLayout->setColumnStretch( 0, 1 ); mainLayout->setColumnStretch( 2, 1 ); mainLayout->setRowStretch( 0, 1 ); mainLayout->setRowStretch( 5, 1 ); setLayout( mainLayout ); mpStartButton->setDefaultAction( mpPlayAction ); mpStartButton->setPopupMode( QToolButton::InstantPopup ); mpStartButton->setToolButtonStyle( Qt::ToolButtonTextBesideIcon ); mpStartButton->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Fixed ); mpPlayAction->setCheckable( true ); mpPlayAction->setDisabled( true ); mpSkipButton->setDefaultAction( mpSkipAction ); mpSkipButton->setPopupMode( QToolButton::InstantPopup ); mpSkipButton->setToolButtonStyle( Qt::ToolButtonTextBesideIcon ); mpSkipButton->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Fixed ); mpSkipAction->setCheckable( true ); mpSkipAction->setDisabled( true ); mpTrayIcon->setIcon( QIcon(":/Partyman/Icon.png") ); mpTrayIcon->setContextMenu( mpTrayIconStopMenu ); mpTrayIconPlayMenu->addAction( mpPauseAction ); mpTrayIconPlayMenu->addAction( mpStopAction ); connect( mpSettingsButton, SIGNAL(clicked()), mpConfig, SLOT(exec()) ); connect( mpStartButton, SIGNAL(clicked()), this, SLOT(initConnect()) ); connect( mpPlayAction, SIGNAL(triggered()), this, SLOT(initConnect()) ); connect( mpPauseAction, SIGNAL(triggered()), this, SLOT(handlePause()) ); connect( mpStopAction, SIGNAL(triggered()), this, SLOT(initDisconnect()) ); connect( mpLoadAction, SIGNAL(triggered()), this, SLOT(handleLoad()) ); connect( mpSkipAction, SIGNAL(triggered()), this, SLOT(handleSkipTrack()) ); connect( mpConfig, SIGNAL(configChanged()), this, SLOT(readConfig()) ); connect( mpPlayer[0], SIGNAL(trackPlaying(TrackInfo)), this, SLOT(handleTrackPlaying(TrackInfo)) ); connect( mpPlayer[1], SIGNAL(trackPlaying(TrackInfo)), this, SLOT(handleTrackPlaying(TrackInfo)) ); connect( mpTrayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(handleTrayIcon(QSystemTrayIcon::ActivationReason)) ); connect( mpTrayIconClickTimer, SIGNAL(timeout()), this, SLOT(handlePause()) ); connect( mpDerMixDprocess, SIGNAL(readyReadStandardError()), this, SLOT(handleDerMixDstartup()) ); connect( mpDerMixDprocess, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(handleDerMixDfinish(int,QProcess::ExitStatus)) ); connect( mpDerMixDprocess, SIGNAL(error(QProcess::ProcessError)), this, SLOT(handleDerMixDerror(QProcess::ProcessError)) ); if( mpSatellite ) { mpGenericSatelliteHandler = new GenericSatelliteHandler( mpSatellite, GenericSatelliteHandler::WithPingAndDialog, this ); connect( mpGenericSatelliteHandler, SIGNAL(updateConfig()), mpConfig, SLOT(readSettings()) ); connect( mpGenericSatelliteHandler, SIGNAL(anotherInstance()), this, SLOT(initDisconnect()) ); connect( mpSatellite, SIGNAL(received(QByteArray)), this, SLOT(handleSatellite(QByteArray)) ); } }