1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-01 03:40:16 +02:00

* Make sure image on artist-page doesn't get squashed and reacts to resize events.

This commit is contained in:
Christian Muehlhaeuser
2014-10-02 18:00:53 +02:00
parent 5ce643850b
commit b09089773c
3 changed files with 42 additions and 8 deletions

View File

@@ -60,9 +60,6 @@ ArtistInfoWidget::ArtistInfoWidget( const Tomahawk::artist_ptr& artist, QWidget*
m_headerWidget = new BasicHeader; m_headerWidget = new BasicHeader;
ui->setupUi( m_widget ); ui->setupUi( m_widget );
m_pixmap = TomahawkUtils::defaultPixmap( TomahawkUtils::DefaultArtistImage, TomahawkUtils::Original, scaled( QSize( 48, 48 ) ) );
ui->cover->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::DefaultArtistImage, TomahawkUtils::Grid, ui->cover->size() ) );
{ {
ui->relatedArtists->setAutoResize( true ); ui->relatedArtists->setAutoResize( true );
ui->relatedArtists->setAutoFitItems( true ); ui->relatedArtists->setAutoFitItems( true );
@@ -95,7 +92,6 @@ ArtistInfoWidget::ArtistInfoWidget( const Tomahawk::artist_ptr& artist, QWidget*
ui->albums->proxyModel()->sort( -1 ); ui->albums->proxyModel()->sort( -1 );
ui->albums->setEmptyTip( tr( "Sorry, we could not find any albums for this artist!" ) ); ui->albums->setEmptyTip( tr( "Sorry, we could not find any albums for this artist!" ) );
ui->albums->setStyleSheet( QString( "QListView { background-color: white; }" ) );
TomahawkStyle::stylePageFrame( ui->albumFrame ); TomahawkStyle::stylePageFrame( ui->albumFrame );
TomahawkStyle::styleScrollBar( ui->albums->verticalScrollBar() ); TomahawkStyle::styleScrollBar( ui->albums->verticalScrollBar() );
TomahawkStyle::styleScrollBar( ui->albums->horizontalScrollBar() ); TomahawkStyle::styleScrollBar( ui->albums->horizontalScrollBar() );
@@ -116,7 +112,6 @@ ArtistInfoWidget::ArtistInfoWidget( const Tomahawk::artist_ptr& artist, QWidget*
ui->topHits->proxyModel()->sort( -1 ); ui->topHits->proxyModel()->sort( -1 );
ui->topHits->setEmptyTip( tr( "Sorry, we could not find any top hits for this artist!" ) ); ui->topHits->setEmptyTip( tr( "Sorry, we could not find any top hits for this artist!" ) );
ui->topHits->setStyleSheet( QString( "QListView { background-color: white; }" ) );
TomahawkStyle::stylePageFrame( ui->trackFrame ); TomahawkStyle::stylePageFrame( ui->trackFrame );
} }
@@ -238,9 +233,11 @@ ArtistInfoWidget::ArtistInfoWidget( const Tomahawk::artist_ptr& artist, QWidget*
m_plInterface = playlistinterface_ptr( mpl ); m_plInterface = playlistinterface_ptr( mpl );
onSliderValueChanged( 0 ); onSliderValueChanged( 0 );
load( artist );
TomahawkUtils::fixMargins( this ); TomahawkUtils::fixMargins( this );
m_pixmap = TomahawkUtils::defaultPixmap( TomahawkUtils::DefaultArtistImage, TomahawkUtils::Original, scaled( QSize( 48, 48 ) ) );
load( artist );
} }
@@ -559,3 +556,22 @@ ArtistInfoWidget::eventFilter( QObject* obj, QEvent* event )
else else
return QObject::eventFilter( obj, event ); return QObject::eventFilter( obj, event );
} }
void
ArtistInfoWidget::resizeEvent( QResizeEvent* event )
{
QWidget::resizeEvent( event );
const QSize coverSize = QSize( ui->cover->width(), ui->cover->width() );
if ( !m_artist || m_artist->cover( QSize( 0, 0 ) ).isNull() )
{
ui->cover->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::DefaultArtistImage, TomahawkUtils::Grid, coverSize ) );
}
else
{
ui->cover->setPixmap( m_artist->cover( coverSize ) );
}
ui->biography->setFixedHeight( ui->cover->width() );
}

View File

@@ -92,6 +92,7 @@ signals:
void pixmapChanged( const QPixmap& pixmap ); void pixmapChanged( const QPixmap& pixmap );
protected: protected:
void resizeEvent( QResizeEvent* event );
void changeEvent( QEvent* e ); void changeEvent( QEvent* e );
bool eventFilter( QObject* obj, QEvent* event ); bool eventFilter( QObject* obj, QEvent* event );

View File

@@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>796</width> <width>796</width>
<height>1132</height> <height>1455</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@@ -210,14 +210,26 @@
<item> <item>
<widget class="QLabel" name="cover"> <widget class="QLabel" name="cover">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding"> <sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="minimumSize">
<size>
<width>192</width>
<height>192</height>
</size>
</property>
<property name="text"> <property name="text">
<string notr="true">TextLabel</string> <string notr="true">TextLabel</string>
</property> </property>
<property name="scaledContents">
<bool>false</bool>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTop|Qt::AlignTrailing</set>
</property>
</widget> </widget>
</item> </item>
</layout> </layout>
@@ -281,6 +293,11 @@
</layout> </layout>
</widget> </widget>
<customwidgets> <customwidgets>
<customwidget>
<class>QWebView</class>
<extends>QWidget</extends>
<header>QtWebKit/QWebView</header>
</customwidget>
<customwidget> <customwidget>
<class>ClickableLabel</class> <class>ClickableLabel</class>
<extends>QLabel</extends> <extends>QLabel</extends>