Mpris2DBusHandler::Mpris2DBusHandler() : QObject( kapp ) { new Mpris2RootAdaptor( this ); new Mpris2PlayerAdaptor( this ); // amarok extensions: new Mpris2AmarokAppAdaptor( this ); new Mpris2AmarokPlayerAdaptor( this ); QDBusConnection::sessionBus().registerObject( MPRIS2_OBJECT_PATH, this ); connect( The::playlistActions(), SIGNAL( navigatorChanged() ), SLOT( updateTrackProgressionProperties() ) ); // changing the navigator may also affect whether there is a // next or previous track connect( The::playlistActions(), SIGNAL( navigatorChanged() ), SLOT( updatePlaylistProperties() ) ); connect( The::playlist()->qaim(), SIGNAL( rowsInserted(QModelIndex,int,int) ), SLOT( updatePlaylistProperties() ) ); connect( The::playlist()->qaim(), SIGNAL( rowsMoved(QModelIndex,int,int,QModelIndex,int) ), SLOT( updatePlaylistProperties() ) ); connect( The::playlist()->qaim(), SIGNAL( rowsRemoved(QModelIndex,int,int) ), SLOT( updatePlaylistProperties() ) ); connect( qobject_cast<Playlist::ProxyBase*>(The::playlist()->qaim()), SIGNAL( activeTrackChanged(const quint64) ), this, SLOT( playlistActiveTrackChanged(quint64) ) ); EngineController *engine = The::engineController(); connect( engine, SIGNAL( playbackStateChanged() ), this, SLOT( updatePlaybackStatusProperty() ) ); connect( engine, SIGNAL( trackChanged( Meta::TrackPtr ) ), this, SLOT( updatePlaylistProperties() ) ); connect( engine, SIGNAL( trackChanged( Meta::TrackPtr ) ), this, SLOT( updateTrackProperties() ) ); connect( engine, SIGNAL( trackPositionChanged( qint64, bool ) ), this, SLOT( trackPositionChanged( qint64, bool ) ) ); connect( engine, SIGNAL( seekableChanged( bool ) ), this, SLOT( seekableChanged( bool ) ) ); connect( engine, SIGNAL( volumeChanged( int ) ), this, SLOT( volumeChanged( int ) ) ); updateTrackProgressionProperties(); updatePlaybackStatusProperty(); updatePlaylistProperties(); updateTrackProperties(); setPropertyInternal( "Volume", static_cast<double>(The::engineController()->volume()) / 100.0 ); setPropertyInternal( "CanSeek", The::engineController()->phononMediaObject()->isSeekable() ); }
void DateSelector::setNavigator(QQuickItem *item) { if (m_navigator == item) return; if (m_navigator) m_navigator->setParentItem(nullptr); m_navigator = item; m_navigator->setParentItem(m_contentItem); updateLayout(); Q_EMIT navigatorChanged(); }
NavigatorConfigAction::NavigatorConfigAction( QWidget * parent ) : KAction( parent ) { KMenu * navigatorMenu = new KMenu( 0 ); setMenu( navigatorMenu ); setText( i18n( "Track Progression" ) ); QActionGroup * navigatorActions = new QActionGroup( navigatorMenu ); navigatorActions->setExclusive( true ); m_standardNavigatorAction = navigatorActions->addAction( i18n( "Standard" ) ); m_standardNavigatorAction->setIcon( KIcon( "media-standard-track-progression-amarok" ) ); m_standardNavigatorAction->setCheckable( true ); //action->setIcon( true ); m_onlyQueueNavigatorAction = navigatorActions->addAction( i18n( "Only Queue" ) ); m_onlyQueueNavigatorAction->setIcon( KIcon( "media-standard-track-progression-amarok" ) ); m_onlyQueueNavigatorAction->setCheckable( true ); QAction * action = new QAction( parent ); action->setSeparator( true ); navigatorActions->addAction( action ); m_repeatTrackNavigatorAction = navigatorActions->addAction( i18n( "Repeat Track" ) ); m_repeatTrackNavigatorAction->setIcon( KIcon( "media-repeat-track-amarok" ) ); m_repeatTrackNavigatorAction->setCheckable( true ); m_repeatAlbumNavigatorAction = navigatorActions->addAction( i18n( "Repeat Album" ) ); m_repeatAlbumNavigatorAction->setIcon( KIcon( "media-repeat-album-amarok" ) ); m_repeatAlbumNavigatorAction->setCheckable( true ); m_repeatPlaylistNavigatorAction = navigatorActions->addAction( i18n( "Repeat Playlist" ) ); m_repeatPlaylistNavigatorAction->setIcon( KIcon( "media-repeat-playlist-amarok" ) ); m_repeatPlaylistNavigatorAction->setCheckable( true ); action = new QAction( parent ); action->setSeparator( true ); navigatorActions->addAction( action ); m_randomTrackNavigatorAction = navigatorActions->addAction( i18n( "Random Tracks" ) ); m_randomTrackNavigatorAction->setIcon( KIcon( "media-random-tracks-amarok" ) ); m_randomTrackNavigatorAction->setCheckable( true ); m_randomAlbumNavigatorAction = navigatorActions->addAction( i18n( "Random Albums" ) ); m_randomAlbumNavigatorAction->setIcon( KIcon( "media-random-albums-amarok" ) ); m_randomAlbumNavigatorAction->setCheckable( true ); navigatorMenu->addActions( navigatorActions->actions() ); QMenu * favorMenu = navigatorMenu->addMenu( i18n( "Favor" ) ); QActionGroup * favorActions = new QActionGroup( favorMenu ); m_favorNoneAction = favorActions->addAction( i18n( "None" ) ); m_favorNoneAction->setCheckable( true ); m_favorScoresAction = favorActions->addAction( i18n( "Higher Scores" ) ); m_favorScoresAction->setCheckable( true ); m_favorRatingsAction = favorActions->addAction( i18n( "Higher Ratings" ) ); m_favorRatingsAction->setCheckable( true ); m_favorLastPlayedAction = favorActions->addAction( i18n( "Not Recently Played" ) ); m_favorLastPlayedAction->setCheckable( true ); favorMenu->addActions( favorActions->actions() ); //make sure the correct entry is selected from start: switch( AmarokConfig::trackProgression() ) { case AmarokConfig::EnumTrackProgression::OnlyQueue: m_onlyQueueNavigatorAction->setChecked( true ); setIcon( m_onlyQueueNavigatorAction->icon() ); break; case AmarokConfig::EnumTrackProgression::RepeatTrack: m_repeatTrackNavigatorAction->setChecked( true ); setIcon( m_repeatTrackNavigatorAction->icon() ); break; case AmarokConfig::EnumTrackProgression::RepeatAlbum: m_repeatAlbumNavigatorAction->setChecked( true ); setIcon( m_repeatAlbumNavigatorAction->icon() ); break; case AmarokConfig::EnumTrackProgression::RepeatPlaylist: m_repeatPlaylistNavigatorAction->setChecked( true ); setIcon( m_repeatPlaylistNavigatorAction->icon() ); break; case AmarokConfig::EnumTrackProgression::RandomTrack: m_randomTrackNavigatorAction->setChecked( true ); setIcon( m_randomTrackNavigatorAction->icon() ); break; case AmarokConfig::EnumTrackProgression::RandomAlbum: m_randomAlbumNavigatorAction->setChecked( true ); setIcon( m_randomAlbumNavigatorAction->icon() ); break; case AmarokConfig::EnumTrackProgression::Normal: default: m_standardNavigatorAction->setChecked( true ); setIcon( m_standardNavigatorAction->icon() ); break; } switch( AmarokConfig::favorTracks() ) { case AmarokConfig::EnumFavorTracks::HigherScores: m_favorScoresAction->setChecked( true ); break; case AmarokConfig::EnumFavorTracks::HigherRatings: m_favorRatingsAction->setChecked( true ); break; case AmarokConfig::EnumFavorTracks::LessRecentlyPlayed: m_favorLastPlayedAction->setChecked( true ); break; case AmarokConfig::EnumFavorTracks::Off: default: m_favorNoneAction->setChecked( true ); break; } connect( navigatorMenu, SIGNAL( triggered( QAction* ) ), this, SLOT( setActiveNavigator( QAction* ) ) ); connect( favorMenu, SIGNAL( triggered( QAction* ) ), this, SLOT( setFavored( QAction* ) ) ); connect( The::playlistActions(), SIGNAL( navigatorChanged() ), this, SLOT( navigatorChanged() ) ); }
PlaylistBrowserNS::DynamicCategory::DynamicCategory( QWidget* parent ) : BrowserCategory( "dynamic category", parent ) { setPrettyName( i18n( "Dynamic Playlists" ) ); setShortDescription( i18n( "Dynamically updating parameter based playlists" ) ); setIcon( KIcon( "dynamic-amarok" ) ); setLongDescription( i18n( "With a dynamic playlist, Amarok becomes your own personal dj, automatically selecting tracks for you, based on a number of parameters that you select." ) ); setImagePath( KStandardDirs::locate( "data", "amarok/images/hover_info_dynamic_playlists.png" ) ); // set background if( AmarokConfig::showBrowserBackgroundImage() ) setBackgroundImage( imagePath() ); bool enabled = AmarokConfig::dynamicMode(); setContentsMargins( 0, 0, 0, 0 ); KHBox* controls2Layout = new KHBox( this ); QLabel *label; label = new QLabel( i18n( "Previous:" ), controls2Layout ); label->setAlignment( Qt::AlignRight | Qt::AlignVCenter ); m_previous = new QSpinBox( controls2Layout ); m_previous->setMinimum( 0 ); m_previous->setToolTip( i18n( "Number of previous tracks to remain in the playlist." ) ); m_previous->setValue( AmarokConfig::previousTracks() ); QObject::connect( m_previous, SIGNAL(valueChanged(int)), this, SLOT(setPreviousTracks(int)) ); label = new QLabel( i18n( "Upcoming:" ), controls2Layout ); // label->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding ); label->setAlignment( Qt::AlignRight | Qt::AlignVCenter ); m_upcoming = new QSpinBox( controls2Layout ); m_upcoming->setMinimum( 1 ); m_upcoming->setToolTip( i18n( "Number of upcoming tracks to add to the playlist." ) ); m_upcoming->setValue( AmarokConfig::upcomingTracks() ); QObject::connect( m_upcoming, SIGNAL(valueChanged(int)), this, SLOT(setUpcomingTracks(int)) ); QObject::connect( (const QObject*)Amarok::actionCollection()->action( "playlist_clear" ), SIGNAL(triggered(bool)), this, SLOT(playlistCleared()) ); QObject::connect( (const QObject*)Amarok::actionCollection()->action( "disable_dynamic" ), SIGNAL(triggered(bool)), this, SLOT(playlistCleared()), Qt::DirectConnection ); // -- the tool bar KHBox* presetLayout = new KHBox( this ); KToolBar* presetToolbar = new KToolBar( presetLayout ); presetToolbar->setIconSize( QSize( 22, 22 ) ); presetToolbar->setToolButtonStyle( Qt::ToolButtonIconOnly ); presetToolbar->setMovable( false ); presetToolbar->setFloatable( false ); presetToolbar->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Preferred ); m_onOffButton = new QToolButton( presetToolbar ); m_onOffButton->setText( i18nc( "Turn dynamic mode on", "On") ); m_onOffButton->setCheckable( true ); m_onOffButton->setIcon( KIcon( "dynamic-amarok" ) ); m_onOffButton->setToolTip( i18n( "Turn dynamic mode on." ) ); presetToolbar->addWidget( m_onOffButton ); m_duplicateButton = new QToolButton( presetToolbar ); m_duplicateButton->setText( i18n("Duplicates") ); m_duplicateButton->setCheckable( true ); m_duplicateButton->setChecked( allowDuplicates() ); m_duplicateButton->setIcon( KIcon( "edit-copy" ) ); m_duplicateButton->setToolTip( i18n( "Allow duplicate songs in result" ) ); presetToolbar->addWidget( m_duplicateButton ); m_addButton = new QToolButton( presetToolbar ); m_addButton->setText( i18n("New") ); m_addButton->setIcon( KIcon( "document-new" ) ); m_addButton->setToolTip( i18n( "New playlist" ) ); presetToolbar->addWidget( m_addButton ); m_editButton = new QToolButton( presetToolbar ); m_editButton->setText( i18n("Edit") ); m_editButton->setIcon( KIcon( "document-properties-amarok" ) ); m_editButton->setToolTip( i18n( "Edit the selected playlist or bias" ) ); presetToolbar->addWidget( m_editButton ); m_deleteButton = new QToolButton( presetToolbar ); m_deleteButton->setText( i18n("Delete") ); m_deleteButton->setEnabled( false ); m_deleteButton->setIcon( KIcon( "edit-delete" ) ); m_deleteButton->setToolTip( i18n( "Delete the selected playlist or bias") ); presetToolbar->addWidget( m_deleteButton ); m_repopulateButton = new QPushButton( presetLayout ); m_repopulateButton->setText( i18n("Repopulate") ); m_repopulateButton->setToolTip( i18n("Replace the upcoming tracks with fresh ones.") ); m_repopulateButton->setIcon( KIcon( "view-refresh-amarok" ) ); m_repopulateButton->setEnabled( enabled ); // m_repopulateButton->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) ); QObject::connect( m_repopulateButton, SIGNAL(clicked(bool)), The::playlistActions(), SLOT(repopulateDynamicPlaylist()) ); // -- the tree view m_tree = new DynamicView( this ); connect( m_tree->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(selectionChanged()) ); connect( m_onOffButton, SIGNAL(toggled(bool)), The::playlistActions(), SLOT(enableDynamicMode(bool)) ); connect( m_duplicateButton, SIGNAL(toggled(bool)), this, SLOT(setAllowDuplicates(bool)) ); connect( m_addButton, SIGNAL(clicked(bool)), m_tree, SLOT(addPlaylist()) ); connect( m_editButton, SIGNAL(clicked(bool)), m_tree, SLOT(editSelected()) ); connect( m_deleteButton, SIGNAL(clicked(bool)), m_tree, SLOT(removeSelected()) ); navigatorChanged(); selectionChanged(); connect( The::playlistActions(), SIGNAL(navigatorChanged()), this, SLOT(navigatorChanged()) ); }