From c5eb71d0deb800e7f1aea049e06fe8b2299eb96f Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Wed, 11 Apr 2012 07:35:01 +0200 Subject: [PATCH] * Small tweaks to the SocialWidget. --- src/SocialWidget.cpp | 21 +++++++++++++-------- src/SocialWidget.h | 2 +- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/SocialWidget.cpp b/src/SocialWidget.cpp index 0b491e0cf..e5c2394da 100644 --- a/src/SocialWidget.cpp +++ b/src/SocialWidget.cpp @@ -92,6 +92,14 @@ SocialWidget::setOpacity( qreal opacity ) } +void +SocialWidget::setPosition( QPoint position ) +{ + m_position = position; + onGeometryUpdate(); +} + + void SocialWidget::show( int timeoutSecs ) { @@ -136,13 +144,6 @@ SocialWidget::paintEvent( QPaintEvent* event ) { Q_UNUSED( event ); - QPoint position( m_position - QPoint( size().width(), size().height() ) ); - if ( position != pos() ) - { - move( position ); - return; - } - QPainter p( this ); QRect r = contentsRect(); @@ -191,7 +192,10 @@ SocialWidget::paintEvent( QPaintEvent* event ) void SocialWidget::onShortLinkReady( const QUrl& longUrl, const QUrl& shortUrl, const QVariant& callbackObj ) { - ui->textEdit->setText( tr( "Listening to \"%1\" by %2 on \"%3\" and loving it! %4" ).arg( m_query->track() ).arg( m_query->artist() ).arg( m_query->album() ).arg( shortUrl.toString() ) ); + if ( m_query->album().isEmpty() ) + ui->textEdit->setText( tr( "Listening to \"%1\" by %2 and loving it! %4" ).arg( m_query->track() ).arg( m_query->artist() ).arg( shortUrl.toString() ) ); + else + ui->textEdit->setText( tr( "Listening to \"%1\" by %2 on \"%3\" and loving it! %4" ).arg( m_query->track() ).arg( m_query->artist() ).arg( m_query->album() ).arg( shortUrl.toString() ) ); } @@ -200,6 +204,7 @@ SocialWidget::setQuery( const Tomahawk::query_ptr& query ) { m_query = query; ui->coverImage->setPixmap( query->cover( ui->coverImage->size() ) ); + onShortLinkReady( QString(), QString(), QVariant() ); onChanged(); QUrl longUrl = GlobalActionManager::instance()->openLinkFromQuery( query ); diff --git a/src/SocialWidget.h b/src/SocialWidget.h index 57f57b2af..437bcd3ad 100644 --- a/src/SocialWidget.h +++ b/src/SocialWidget.h @@ -46,7 +46,7 @@ public: void setOpacity( qreal opacity ); QPoint position() const { return m_position; } - void setPosition( QPoint position ) { m_position = position; } + void setPosition( QPoint position ); bool shown() const;