diff --git a/src/libtomahawk/viewpages/CollectionViewPage.cpp b/src/libtomahawk/viewpages/CollectionViewPage.cpp index 3f366ebda..9be885792 100644 --- a/src/libtomahawk/viewpages/CollectionViewPage.cpp +++ b/src/libtomahawk/viewpages/CollectionViewPage.cpp @@ -124,6 +124,9 @@ CollectionViewPage::CollectionViewPage( const Tomahawk::collection_ptr& collecti { QAbstractButton* downloadButton = m_header->addButton( tr( "Download All" ) ); connect( downloadButton, SIGNAL( clicked() ), SLOT( onDownloadAll() ) ); + + m_header->setRefreshVisible( true ); + connect( m_header, SIGNAL( refresh() ), SLOT( onCollectionChanged() ) ); } layout()->addWidget( m_header ); diff --git a/src/libtomahawk/widgets/BasicHeader.cpp b/src/libtomahawk/widgets/BasicHeader.cpp index 35c307c1f..2863998b2 100644 --- a/src/libtomahawk/widgets/BasicHeader.cpp +++ b/src/libtomahawk/widgets/BasicHeader.cpp @@ -20,6 +20,7 @@ #include "BasicHeader.h" #include "ElidedLabel.h" +#include "utils/ImageRegistry.h" #include "utils/TomahawkStyle.h" #include "utils/TomahawkUtilsGui.h" #include "utils/Logger.h" @@ -43,6 +44,10 @@ BasicHeader::BasicHeader( QWidget* parent ) setAutoFillBackground( false ); BackgroundWidget::setBackgroundColor( TomahawkStyle::HEADER_BACKGROUND ); + ui->refreshButton->setPixmap( ImageRegistry::instance()->pixmap( RESPATH "images/refresh.svg", QSize( ui->captionLabel->height() - 8, ui->captionLabel->height() - 8 ) ) ); + connect( ui->refreshButton, SIGNAL( clicked() ), SIGNAL( refresh() ) ); + setRefreshVisible( false ); + { QFont f = ui->captionLabel->font(); f.setPointSize( TomahawkUtils::defaultFontSize() + 6 ); @@ -104,6 +109,13 @@ BasicHeader::setDescription( const QString& /* s */ ) } +void +BasicHeader::setRefreshVisible( bool visible ) +{ + ui->refreshButton->setVisible( visible ); +} + + void BasicHeader::setPixmap( const QPixmap& pixmap, bool tinted ) { @@ -136,6 +148,7 @@ BasicHeader::resizeEvent( QResizeEvent* event ) { BackgroundWidget::resizeEvent( event ); - ui->captionLabel->setFixedWidth( width() * 0.33 ); + QFontMetrics fm( ui->captionLabel->font() ); + ui->captionLabel->setFixedWidth( qMin( fm.width( ui->captionLabel->text() ) + 8, int( width() * 0.33 ) ) ); ui->balanceSpacer->changeSize( ui->captionLabel->width(), 1, QSizePolicy::Expanding, QSizePolicy::Fixed ); } diff --git a/src/libtomahawk/widgets/BasicHeader.h b/src/libtomahawk/widgets/BasicHeader.h index c5f4d16e5..063fe993b 100644 --- a/src/libtomahawk/widgets/BasicHeader.h +++ b/src/libtomahawk/widgets/BasicHeader.h @@ -46,6 +46,10 @@ public slots: virtual void setCaption( const QString& s ); virtual void setDescription( const QString& s ); virtual void setPixmap( const QPixmap& p, bool tinted = true ); + virtual void setRefreshVisible( bool visible ); + +signals: + void refresh(); protected: virtual void resizeEvent( QResizeEvent* event ); diff --git a/src/libtomahawk/widgets/HeaderWidget.ui b/src/libtomahawk/widgets/HeaderWidget.ui index 7d5644a16..364e4baf7 100644 --- a/src/libtomahawk/widgets/HeaderWidget.ui +++ b/src/libtomahawk/widgets/HeaderWidget.ui @@ -67,11 +67,21 @@ + + + + Refresh + + + Qt::Horizontal + + QSizePolicy::MinimumExpanding + 40 @@ -200,6 +210,11 @@ QLabel
widgets/ClickableLabel.h
+ + ImageButton + QPushButton +
widgets/ImageButton.h
+