1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-07-31 03:10:12 +02:00

* A few more QueryLabel fixes / design changes.

This commit is contained in:
Christian Muehlhaeuser
2011-01-13 11:12:11 +01:00
parent 6ebafa26a6
commit 05a919c16a
2 changed files with 27 additions and 27 deletions

View File

@@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>359</width> <width>359</width>
<height>58</height> <height>60</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
@@ -19,13 +19,13 @@
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>0</width> <width>0</width>
<height>58</height> <height>60</height>
</size> </size>
</property> </property>
<property name="maximumSize"> <property name="maximumSize">
<size> <size>
<width>16777215</width> <width>16777215</width>
<height>58</height> <height>60</height>
</size> </size>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@@ -196,16 +196,16 @@
<extends>QPushButton</extends> <extends>QPushButton</extends>
<header>imagebutton.h</header> <header>imagebutton.h</header>
</customwidget> </customwidget>
<customwidget>
<class>ElidedLabel</class>
<extends>QLabel</extends>
<header>elidedlabel.h</header>
</customwidget>
<customwidget> <customwidget>
<class>QueryLabel</class> <class>QueryLabel</class>
<extends>QLabel</extends> <extends>QLabel</extends>
<header>querylabel.h</header> <header>querylabel.h</header>
</customwidget> </customwidget>
<customwidget>
<class>ElidedLabel</class>
<extends>QLabel</extends>
<header>elidedlabel.h</header>
</customwidget>
</customwidgets> </customwidgets>
<resources/> <resources/>
<connections/> <connections/>

View File

@@ -9,7 +9,7 @@
#include "tomahawkutils.h" #include "tomahawkutils.h"
#define BOXMARGIN 2 #define BOXMARGIN 2
#define DASH " - "
QueryLabel::QueryLabel( QWidget* parent, Qt::WindowFlags flags ) QueryLabel::QueryLabel( QWidget* parent, Qt::WindowFlags flags )
: QFrame( parent, flags ) : QFrame( parent, flags )
@@ -165,7 +165,7 @@ QueryLabel::setResult( const Tomahawk::result_ptr& result )
if ( result.isNull() ) if ( result.isNull() )
return; return;
setContentsMargins( BOXMARGIN, 0, BOXMARGIN, 0 ); setContentsMargins( BOXMARGIN * 2, BOXMARGIN / 2, BOXMARGIN * 2, BOXMARGIN / 2);
if ( m_result.isNull() || m_result.data() != result.data() ) if ( m_result.isNull() || m_result.data() != result.data() )
{ {
@@ -190,7 +190,7 @@ QueryLabel::setQuery( const Tomahawk::query_ptr& query )
if ( query.isNull() ) if ( query.isNull() )
return; return;
setContentsMargins( BOXMARGIN, 0, BOXMARGIN, 0 ); setContentsMargins( BOXMARGIN * 2, BOXMARGIN / 2, BOXMARGIN * 2, BOXMARGIN / 2 );
if ( m_query.isNull() || m_query.data() != query.data() ) if ( m_query.isNull() || m_query.data() != query.data() )
{ {
@@ -254,7 +254,7 @@ QSize
QueryLabel::sizeHint() const QueryLabel::sizeHint() const
{ {
const QFontMetrics& fm = fontMetrics(); const QFontMetrics& fm = fontMetrics();
QSize size( fm.width( text() ) + contentsMargins().left() * 2, fm.height() ); QSize size( fm.width( text() ) + contentsMargins().left() * 2, fm.height() + contentsMargins().top() * 2 );
return size; return size;
} }
@@ -270,7 +270,7 @@ QueryLabel::minimumSizeHint() const
default: default:
{ {
const QFontMetrics& fm = fontMetrics(); const QFontMetrics& fm = fontMetrics();
QSize size( fm.width( "..." ), fm.height() ); QSize size( fm.width( "..." ), fm.height() + contentsMargins().top() * 2 );
return size; return size;
} }
} }
@@ -291,7 +291,7 @@ QueryLabel::paintEvent( QPaintEvent* event )
if ( elidedText == s && m_hoverArea.width() ) if ( elidedText == s && m_hoverArea.width() )
{ {
p.setPen( palette().highlight().color() ); p.setPen( palette().shadow().color() );
p.setBrush( palette().highlight() ); p.setBrush( palette().highlight() );
p.drawRoundedRect( m_hoverArea, 4.0, 4.0 ); p.drawRoundedRect( m_hoverArea, 4.0, 4.0 );
} }
@@ -305,7 +305,7 @@ QueryLabel::paintEvent( QPaintEvent* event )
else else
{ {
const QFontMetrics& fm = fontMetrics(); const QFontMetrics& fm = fontMetrics();
int dashX = fm.width( " - " ); int dashX = fm.width( DASH );
int artistX = m_type & Artist ? fm.width( artist() ) : 0; int artistX = m_type & Artist ? fm.width( artist() ) : 0;
int albumX = m_type & Album ? fm.width( album() ) : 0; int albumX = m_type & Album ? fm.width( album() ) : 0;
int trackX = m_type & Track ? fm.width( track() ) : 0; int trackX = m_type & Track ? fm.width( track() ) : 0;
@@ -331,7 +331,7 @@ QueryLabel::paintEvent( QPaintEvent* event )
if ( m_type & Artist ) if ( m_type & Artist )
{ {
p.drawText( r, align, " - " ); p.drawText( r, align, DASH );
r.adjust( dashX, 0, 0, 0 ); r.adjust( dashX, 0, 0, 0 );
} }
if ( m_hoverArea.width() && m_hoverArea.left() + contentsMargins().left() == r.left() ) if ( m_hoverArea.width() && m_hoverArea.left() + contentsMargins().left() == r.left() )
@@ -350,7 +350,7 @@ QueryLabel::paintEvent( QPaintEvent* event )
if ( m_type & Artist || m_type & Album ) if ( m_type & Artist || m_type & Album )
{ {
p.drawText( r, align, " - " ); p.drawText( r, align, DASH );
r.adjust( dashX, 0, 0, 0 ); r.adjust( dashX, 0, 0, 0 );
} }
if ( m_hoverArea.width() && m_hoverArea.left() + contentsMargins().left() == r.left() ) if ( m_hoverArea.width() && m_hoverArea.left() + contentsMargins().left() == r.left() )
@@ -419,7 +419,7 @@ QueryLabel::mouseMoveEvent( QMouseEvent* event )
} }
const QFontMetrics& fm = fontMetrics(); const QFontMetrics& fm = fontMetrics();
int dashX = fm.width( " - " ); int dashX = fm.width( DASH );
int artistX = m_type & Artist ? fm.width( artist() ) : 0; int artistX = m_type & Artist ? fm.width( artist() ) : 0;
int albumX = m_type & Album ? fm.width( album() ) : 0; int albumX = m_type & Album ? fm.width( album() ) : 0;
int trackX = m_type & Track ? fm.width( track() ) : 0; int trackX = m_type & Track ? fm.width( track() ) : 0;
@@ -437,26 +437,26 @@ QueryLabel::mouseMoveEvent( QMouseEvent* event )
QRect hoverArea; QRect hoverArea;
if ( m_type & Artist && x < artistX ) if ( m_type & Artist && x < artistX )
{ {
hoverArea.setLeft( 0 ); hoverArea.setLeft( 1 );
hoverArea.setRight( artistX + contentsMargins().left() ); hoverArea.setRight( artistX + contentsMargins().left() + 2 );
} }
else if ( m_type & Album && x < albumX ) else if ( m_type & Album && x < albumX )
{ {
int spacing = ( m_type & Artist ) ? dashX : 0; int spacing = ( m_type & Artist ) ? dashX : 0;
hoverArea.setLeft( artistX + spacing ); hoverArea.setLeft( artistX + spacing + 1 );
hoverArea.setRight( albumX + spacing + contentsMargins().left() ); hoverArea.setRight( albumX + spacing + contentsMargins().left() + 2 );
} }
else if ( m_type & Track && x < trackX ) else if ( m_type & Track && x < trackX )
{ {
int spacing = ( m_type & Album ) ? dashX : 0; int spacing = ( m_type & Album ) ? dashX : 0;
hoverArea.setLeft( albumX + spacing ); hoverArea.setLeft( albumX + spacing + 1 );
hoverArea.setRight( trackX + contentsMargins().left() ); hoverArea.setRight( trackX + contentsMargins().left() + 2 );
} }
if ( hoverArea.width() ) if ( hoverArea.width() )
{ {
hoverArea.setY( 0 ); hoverArea.setY( 1 );
hoverArea.setHeight( height() - 1 ); hoverArea.setHeight( height() - 2 );
} }
if ( hoverArea != m_hoverArea ) if ( hoverArea != m_hoverArea )
{ {
@@ -504,7 +504,7 @@ QueryLabel::smartAppend( QString& text, const QString& appendage ) const
{ {
QString s; QString s;
if ( !text.isEmpty() ) if ( !text.isEmpty() )
s = " - "; s = DASH;
text += s + appendage; text += s + appendage;
return text; return text;