void QmlView::clearPlaylist() { emit playlistCleared(); }
QmlView::QmlView(QUrl source, QWidget *parent, MafwRegistryAdapter *mafwRegistry ) : QMainWindow(parent), ui(new Ui::QmlView), mafwRegistry(mafwRegistry), mafwRenderer(mafwRegistry->renderer()) { ui->setupUi(this); ui->declarativeView->setSource(source); ui->declarativeView->setResizeMode(QDeclarativeView::SizeRootObjectToView); setAttribute(Qt::WA_DeleteOnClose); setAttribute(Qt::WA_Maemo5StackedWindow); setAttribute(Qt::WA_Maemo5NonComposited); QGLWidget *glWidget = new QGLWidget(this); ui->declarativeView->setViewport(glWidget); positionTimer = new QTimer(this); positionTimer->setInterval(1000); fmtx = new FMTXInterface(this); Rotator *rotator = Rotator::acquire(); savedPolicy = rotator->policy(); rotator->setPolicy(Rotator::Landscape); rootObject = dynamic_cast<QObject*>(ui->declarativeView->rootObject()); rootObject->setParent(this); connect(rootObject, SIGNAL(quitButtonClicked()), this, SLOT(close())); connect(rootObject, SIGNAL(prevButtonClicked()), mafwRenderer, SLOT(previous())); connect(rootObject, SIGNAL(playButtonClicked()), this, SLOT(onPlayClicked())); connect(rootObject, SIGNAL(nextButtonClicked()), mafwRenderer, SLOT(next())); connect(rootObject, SIGNAL(fmtxButtonClicked()), this, SLOT(onFmtxClicked())); connect(rootObject, SIGNAL(sliderValueChanged(int)), this, SLOT(onSliderValueChanged(int))); connect(rootObject, SIGNAL(playlistItemSelected(int)), this, SLOT(onPlaylistItemChanged(int))); connect(this, SIGNAL(titleChanged(QVariant)), rootObject, SLOT(setSongTitle(QVariant))); connect(this, SIGNAL(albumChanged(QVariant)), rootObject, SLOT(setSongAlbum(QVariant))); connect(this, SIGNAL(artistChanged(QVariant)), rootObject, SLOT(setSongArtist(QVariant))); connect(this, SIGNAL(albumArtChanged(QVariant)), rootObject, SLOT(setAlbumArt(QVariant))); connect(this, SIGNAL(durationTextChanged(QVariant)), rootObject, SLOT(setPosition(QVariant))); connect(this, SIGNAL(positionChanged(QVariant)), rootObject, SLOT(setSliderValue(QVariant))); connect(this, SIGNAL(durationChanged(QVariant)), rootObject, SLOT(setSliderMaximum(QVariant))); connect(this, SIGNAL(stateIconChanged(QVariant)), rootObject, SLOT(setPlayButtonIcon(QVariant))); connect(this, SIGNAL(rowChanged(QVariant)), rootObject, SLOT(onRowChanged(QVariant))); connect(this, SIGNAL(fmtxStateChanged(QVariant)), rootObject, SLOT(onFmtxStateChanged(QVariant))); connect(this, SIGNAL(playlistItemAppended(QVariant,QVariant,QVariant)), rootObject, SLOT(appendPlaylistItem(QVariant,QVariant,QVariant))); connect(this, SIGNAL(playlistItemInserted(QVariant,QVariant,QVariant,QVariant)), rootObject, SLOT(insertPlaylistItem(QVariant,QVariant,QVariant,QVariant))); connect(this, SIGNAL(playlistItemSet(QVariant,QVariant,QVariant,QVariant)), rootObject, SLOT(setPlaylistItem(QVariant,QVariant,QVariant,QVariant))); connect(this, SIGNAL(playlistItemRemoved(QVariant)), rootObject, SLOT(removePlaylistItem(QVariant))); connect(this, SIGNAL(playlistCleared()), rootObject, SLOT(clearPlaylist())); connect(mafwRenderer, SIGNAL(stateChanged(MafwPlayState)), this, SLOT(onStateChanged(MafwPlayState))); connect(mafwRenderer, SIGNAL(positionReceived(int,QString)), this, SLOT(onPositionChanged(int))); connect(mafwRenderer, SIGNAL(statusReceived(MafwPlaylist*,uint,MafwPlayState,QString,QString)), this, SLOT(onStatusReceived(MafwPlaylist*,uint,MafwPlayState))); connect(positionTimer, SIGNAL(timeout()), mafwRenderer, SLOT(getPosition())); connect(fmtx, SIGNAL(propertyChanged()), this, SLOT(onFmtxChanged())); onFmtxChanged(); positionTimer->start(); quint32 disable = {0}; Atom winPortraitModeSupportAtom = XInternAtom(QX11Info::display(), "_HILDON_PORTRAIT_MODE_SUPPORT", false); XChangeProperty(QX11Info::display(), winId(), winPortraitModeSupportAtom, XA_CARDINAL, 32, PropModeReplace, (uchar*) &disable, 1); this->setDNDAtom(true); mafwRenderer->getStatus(); mafwRenderer->getPosition(); }
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()) ); }