diff --git a/src/AudioControls.cpp b/src/AudioControls.cpp index 7c6fd14aa..525bfdd0d 100644 --- a/src/AudioControls.cpp +++ b/src/AudioControls.cpp @@ -70,6 +70,8 @@ AudioControls::AudioControls( QWidget* parent ) font.setPointSize( TomahawkUtils::defaultFontSize() - 2 ); + m_defaultSourceIcon = QPixmap( RESPATH "images/resolver-default.png" ); + ui->prevButton->setPixmap( RESPATH "images/back-rest.png" ); ui->prevButton->setPixmap( RESPATH "images/back-pressed.png", QIcon::Off, QIcon::Active ); ui->playPauseButton->setPixmap( RESPATH "images/play-rest.png" ); @@ -87,7 +89,7 @@ AudioControls::AudioControls( QWidget* parent ) ui->socialButton->setPixmap( RESPATH "images/share.png" ); ui->loveButton->setPixmap( RESPATH "images/not-loved.png" ); ui->loveButton->setCheckable( true ); - ui->ownerButton->setPixmap( RESPATH "images/resolver-default.png" ); + ui->ownerButton->setPixmap( m_defaultSourceIcon ); ui->socialButton->setFixedSize( QSize( 20, 20 ) ); ui->loveButton->setFixedSize( QSize( 20, 20 ) ); @@ -261,8 +263,16 @@ AudioControls::onPlaybackLoading( const Tomahawk::result_ptr& result ) ui->socialButton->setToolTip( tr( "Share" ) ); ui->loveButton->setToolTip( tr( "Love" ) ); ui->ownerButton->setToolTip( QString( tr( "Playing from %1" ) ).arg( result->friendlySource() ) ); + QPixmap sourceIcon = result->sourceIcon().scaled( ui->ownerButton->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation); - ui->ownerButton->setPixmap( sourceIcon ); + if ( !sourceIcon.isNull() ) + ui->ownerButton->setPixmap( sourceIcon ); + else + { + ui->ownerButton->clear(); + ui->ownerButton->setPixmap( m_defaultSourceIcon ); + } + if ( QUrl( result->linkUrl() ).isValid() || !result->collection().isNull() ) ui->ownerButton->setCursor( Qt::PointingHandCursor ); else @@ -366,7 +376,7 @@ AudioControls::onPlaybackStopped() m_sliderTimeLine.stop(); m_sliderTimeLine.setCurrentTime( 0 ); m_phononTickCheckTimer.stop(); - ui->ownerButton->setPixmap( RESPATH "images/resolver-default.png" ); + ui->ownerButton->setPixmap( m_defaultSourceIcon ); ui->stackedLayout->setCurrentWidget( ui->playPauseButton ); ui->loveButton->setEnabled( false ); diff --git a/src/AudioControls.h b/src/AudioControls.h index cd24157e6..35a0aa998 100644 --- a/src/AudioControls.h +++ b/src/AudioControls.h @@ -93,13 +93,15 @@ private: void setSocialActions(); Ui::AudioControls* ui; - + QWeakPointer m_socialWidget; Tomahawk::result_ptr m_currentTrack; Tomahawk::PlaylistModes::RepeatMode m_repeatMode; bool m_shuffled; + QPixmap m_defaultSourceIcon; + QTimer m_phononTickCheckTimer; QTimeLine m_sliderTimeLine; bool m_seeked; diff --git a/src/libtomahawk/widgets/ImageButton.cpp b/src/libtomahawk/widgets/ImageButton.cpp index e4696bf06..933043dfd 100644 --- a/src/libtomahawk/widgets/ImageButton.cpp +++ b/src/libtomahawk/widgets/ImageButton.cpp @@ -72,6 +72,12 @@ ImageButton::setPixmap( const QPixmap& pixmap ) } +void +ImageButton::clear() +{ + setIcon( QIcon() ); +} + void ImageButton::paintEvent( QPaintEvent* event ) { diff --git a/src/libtomahawk/widgets/ImageButton.h b/src/libtomahawk/widgets/ImageButton.h index b2f33f67c..d47384f18 100644 --- a/src/libtomahawk/widgets/ImageButton.h +++ b/src/libtomahawk/widgets/ImageButton.h @@ -1,5 +1,5 @@ /* === This file is part of Tomahawk Player - === - * + * * Copyright 2010-2011, Christian Muehlhaeuser * Copyright 2010-2011, Jeff Mitchell * @@ -35,18 +35,20 @@ public: explicit ImageButton( QWidget* parent = 0 ); explicit ImageButton( const QPixmap& pixmap, QWidget* parent = 0 ); explicit ImageButton( const QString& path, QWidget* parent = 0 ); - + void setPixmap( const QString& path ); void setPixmap( const QPixmap& pixmap ); void setPixmap( const QString&, const QIcon::State, QIcon::Mode = QIcon::Normal ); void setPixmap( const QPixmap&, const QIcon::State, QIcon::Mode = QIcon::Normal ); - + + void clear(); + virtual QSize sizeHint() const { return m_sizeHint; } - + protected: virtual void paintEvent( QPaintEvent* event ); - + private: void init( const QPixmap& );