void ProfileWidget::changeUser( const lastfm::User& user ) { // Make sure we don't recieve any updates about the last session disconnect( this, SLOT(onGotLovedTracks()) ); disconnect( this, SLOT(onGotTopOverallArtists())); disconnect( this, SLOT(onGotTopWeeklyArtists())); disconnect( this, SLOT(onGotLibraryArtists())); ui->avatar->setAlignment( Qt::AlignCenter ); ui->avatar->setUser( user ); ui->avatar->loadUrl( user.imageUrl( User::LargeImage, true ), HttpImageWidget::ScaleNone ); ui->avatar->setHref( user.www() ); ui->infoString->setText( user.getInfoString() ); ui->scrobbles->setText( tr( "Scrobbles since %1" ).arg( user.dateRegistered().toString( "d MMMM yyyy" ) ) ); m_scrobbleCount = user.scrobbleCount(); setScrobbleCount(); ui->name->setText( unicorn::Label::boldLinkStyle( unicorn::Label::anchor( user.www().toString(), user.name() ), Qt::black ) ); connect( user.getLovedTracks( 1 ), SIGNAL(finished()), SLOT(onGotLovedTracks()) ); connect( user.getTopArtists( "overall", 5, 1 ), SIGNAL(finished()), SLOT(onGotTopOverallArtists())); connect( user.getTopArtists( "7day", 5, 1 ), SIGNAL(finished()), SLOT(onGotTopWeeklyArtists())); connect( lastfm::Library::getArtists( user.name(), 1 ), SIGNAL(finished()), SLOT(onGotLibraryArtists())); }
void ProfileWidget::changeUser( const QString& newUsername ) { if ( !newUsername.isEmpty() && newUsername != m_currentUsername ) { m_currentUsername = newUsername; // Make sure we don't recieve any updates about the last session disconnect( this, SLOT(onGotTopOverallArtists()) ); disconnect( this, SLOT(onGotTopWeeklyArtists()) ); layout()->removeWidget( m_main ); delete m_main; layout()->addWidget( m_main = new QWidget( this ) ); QVBoxLayout* layout = new QVBoxLayout( m_main ); layout->setContentsMargins( 0, 0, 0, 0 ); layout->setSpacing( 0 ); layout->addWidget( ui.user = new StylableWidget( this ) ); ui.user->setObjectName( "user" ); QHBoxLayout* hl = new QHBoxLayout( ui.user ); hl->setContentsMargins( 0, 0, 0, 0 ); hl->setSpacing( 0 ); hl->addWidget( ui.avatar = new AvatarWidget( this ) ); ui.avatar->setObjectName( "avatar" ); QVBoxLayout* vl = new QVBoxLayout(); vl->setContentsMargins( 0, 0, 0, 0 ); vl->setSpacing( 0 ); hl->addLayout( vl, 1 ); vl->addWidget( ui.name = new QLabel( newUsername, this) ); ui.name->setObjectName( "name" ); QGridLayout* grid = new QGridLayout; vl->addLayout( grid ); grid->addWidget( ui.scrobbleCount = new QLabel( "0" ), 0, 0 ); ui.scrobbleCount->setObjectName( "scrobbleCount" ); grid->addWidget( ui.scrobbles = new QLabel( tr( "Scrobbles" ) ), 1, 0 ); ui.scrobbleCount->setObjectName( "scrobbles" ); QFrame* splitter = new QFrame; splitter->setObjectName( "splitter" ); splitter->setFrameStyle( QFrame::VLine ); grid->addWidget( splitter, 0, 1, 2, 1, Qt::AlignLeft ); grid->addWidget( ui.lovedCount = new QLabel( "0" ), 0, 2 ); ui.lovedCount->setObjectName( "lovedCount" ); grid->addWidget( ui.loved = new QLabel( tr( "Loved tracks" ) ), 1, 2 ); ui.loved->setObjectName( "loved" ); { QFrame* splitter = new QFrame( this ); layout->addWidget( splitter ); splitter->setObjectName( "splitter" ); QLabel* title = new QLabel( tr("Top Artists This Week"), this ) ; layout->addWidget( title ); title->setObjectName( "title" ); layout->addWidget( ui.topWeeklyArtists = new StylableWidget( this ) ); ui.topWeeklyArtists->setObjectName( "section" ); } { QFrame* splitter = new QFrame( this ); layout->addWidget( splitter ); splitter->setObjectName( "splitter" ); QLabel* title = new QLabel( tr("Top Artists Overall"), this ) ; layout->addWidget( title ); title->setObjectName( "title" ); layout->addWidget( ui.topOverallArtists = new StylableWidget( this ) ); ui.topOverallArtists->setObjectName( "section" ); } layout->addStretch( 1 ); lastfm::User user = lastfm::User( newUsername ); connect( user.getLovedTracks( 1 ), SIGNAL(finished()), SLOT(onGotLovedTracks()) ); connect( user.getTopArtists( "overall", 5, 1 ), SIGNAL(finished()), SLOT(onGotTopOverallArtists())); connect( user.getTopArtists( "7day", 5, 1 ), SIGNAL(finished()), SLOT(onGotTopWeeklyArtists())); } }