Ejemplo n.º 1
0
void
FriendListWidget::onSessionChanged( const unicorn::Session& session )
{
    if ( session.user().name() != m_currentUser )
    {
        m_currentUser = session.user().name();

        if ( m_reply )
            m_reply->abort();

        ui->friends->clear();

        // add the refresh button
        FriendWidgetItem* item = new FriendWidgetItem( ui->friends );
        RefreshButton* refresh = new RefreshButton( this );
        refresh->setText( tr( "Refresh Friends" ) );
        ui->friends->setItemWidget( item, refresh );
        item->setSizeHint( refresh->sizeHint() );

        connect( refresh, SIGNAL(clicked()) , SLOT(refresh()));

        ui->stackedWidget->setCurrentWidget( ui->spinnerPage );
        m_movie->start();

        m_reply = session.user().getFriends( true, 50, 1 );
        connect( m_reply, SIGNAL(finished()), SLOT(onGotFriends()));
    }
}
void
ScrobblesListWidget::onSessionChanged( const unicorn::Session& session )
{
    if ( !session.user().name().isEmpty() )
    {
        QString path = lastfm::dir::runtimeData().filePath( session.user().name() + "_recent_tracks.xml" );

        if ( m_path != path )
        {
            m_path = path;
            read();
            refresh();
        }
    }
}
void
NothingPlayingWidget::onSessionChanged( const unicorn::Session& session )
{
    if ( !session.user().name().isEmpty() )
        ui->top->setText( tr(  "Hello, %1!" ).arg( session.user().name() ) );

    // leave them in their current state until the sessioninfo is valid
    // this stops them getting hidden and shown again when adding a new subscriber
    if ( session.isValid() )
    {
        ui->splitter->setVisible( session.youRadio() );
        ui->quickStart->setVisible( session.youRadio() );
        ui->start->setVisible( session.youRadio() );
    }
}
Ejemplo n.º 4
0
void
RadioWidget::refresh( const unicorn::Session& session )
{
    if ( session.isValid() )
    {
        m_movie->stop();

        if ( session.youRadio() )
        {
            unicorn::UserSettings us( session.user().name() );
            QString stationUrl = us.value( "lastStationUrl", "" ).toString();
            QString stationTitle = us.value( "lastStationTitle", tr( "A Radio Station" ) ).toString();

            ui->nowPlayingFrame->setVisible( !stationUrl.isEmpty() );

            RadioStation lastStation( stationUrl );
            lastStation.setTitle( stationTitle );

            ui->lastStation->setStation( lastStation, stationTitle );
            ui->lastStation->setObjectName( "station" );
            style()->polish( ui->lastStation );

            ui->library->setStation( RadioStation::library( session.user() ), tr( "My Library Radio" ), tr( "Music you know and love" ) );
            ui->mix->setStation( RadioStation::mix( session.user() ), tr( "My Mix Radio" ), tr( "Your library plus new music" ) );
            ui->rec->setStation( RadioStation::recommendations( session.user() ), tr( "My Recommended Radio" ), tr( "New music from Last.fm" ) );

            ui->friends->setStation( RadioStation::friends( session.user() ), tr( "My Friends' Radio" ), tr( "Music your friends like" ) );
            ui->neighbours->setStation( RadioStation::neighbourhood( session.user() ), tr( "My Neighbourhood Radio" ), tr ( "Music from listeners like you" ) );

            if ( m_currentUsername != session.user().name() )
            {
                m_currentUsername = session.user().name();

                // clear the recent stations
                QLayout* recentStationsLayout = ui->recentStations->layout();
                while ( recentStationsLayout->count() )
                {
                    QLayoutItem* item = recentStationsLayout->takeAt( 0 );
                    delete item->widget();
                    delete item;
                }

                // fetch recent stations
                connect( session.user().getRecentStations( MAX_RECENT_STATIONS ), SIGNAL(finished()), SLOT(onGotRecentStations()));
            }

            ui->stackedWidget->setCurrentWidget( ui->mainPage );
        }
        else
        {
            ui->listen->setVisible( session.registeredWebRadio() );

            ui->stackedWidget->setCurrentWidget( ui->nonSubPage );

            ui->title->setText( tr( "Subscribe to listen to radio, only %1 a month" ).arg( session.subscriptionPriceString() ) );
            ui->subscribe->setVisible( session.subscriberRadio() );
        }
    }
    else
    {
        ui->stackedWidget->setCurrentWidget( ui->spinnerPage );
        m_movie->start();
    }
}