1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-13 20:39:57 +01:00

* Fixed a few margin / spacing issues across all platforms (well, hopefully).

This commit is contained in:
Christian Muehlhaeuser 2011-01-13 14:09:15 +01:00
parent 05a919c16a
commit c0852e8871
7 changed files with 89 additions and 41 deletions

View File

@ -23,7 +23,6 @@ AudioControls::AudioControls( QWidget* parent )
ui->setupUi( this );
ui->buttonAreaLayout->setSpacing( 2 );
ui->trackLabelLayout->setSpacing( 3 );
QFont font( ui->artistTrackLabel->font() );
font.setPixelSize( 12 );

View File

@ -168,7 +168,7 @@
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
<number>8</number>
<number>4</number>
</property>
<property name="topMargin">
<number>6</number>
@ -177,14 +177,35 @@
<number>2</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<layout class="QHBoxLayout" name="horizontalLayout_2" stretch="1,0,0">
<property name="topMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<layout class="QVBoxLayout" name="trackLabelLayout">
<property name="topMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QueryLabel" name="artistTrackLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>16</height>
</size>
</property>
<property name="cursor">
<cursorShape>PointingHandCursor</cursorShape>
</property>
@ -195,6 +216,18 @@
</item>
<item>
<widget class="QueryLabel" name="albumLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>16</height>
</size>
</property>
<property name="cursor">
<cursorShape>PointingHandCursor</cursorShape>
</property>
@ -212,8 +245,8 @@
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
<width>4</width>
<height>8</height>
</size>
</property>
</spacer>
@ -246,13 +279,16 @@
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
<height>4</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="leftMargin">
<number>4</number>
</property>
<item>
<widget class="QLabel" name="timeLabel">
<property name="text">

View File

@ -23,6 +23,14 @@ SourceTreeItemWidget::SourceTreeItemWidget( const source_ptr& source, QWidget* p
ui->verticalLayout->setSpacing( 3 );
ui->activityLabel->setType( QueryLabel::ArtistAndTrack );
QFont font = ui->nameLabel->font();
// font.setPointSize( font.pointSize() - 1 );
ui->nameLabel->setFont( font );
font.setPointSize( font.pointSize() - 1 );
ui->infoLabel->setFont( font );
ui->activityLabel->setFont( font );
QString displayname;
if ( source.isNull() )
{
@ -59,6 +67,10 @@ SourceTreeItemWidget::SourceTreeItemWidget( const source_ptr& source, QWidget* p
ui->infoLabel->setForegroundRole( QPalette::Dark );
ui->activityLabel->setForegroundRole( QPalette::Dark );
ui->nameLabel->setContentsMargins( 4, 0, 0, 0 );
ui->infoLabel->setContentsMargins( 4, 0, 0, 0 );
ui->activityLabel->setContentsMargins( 4, 0, 0, 0 );
connect( ui->onOffButton, SIGNAL( clicked() ), SIGNAL( clicked() ) );
connect( ui->infoButton, SIGNAL( clicked() ), SLOT( onInfoButtonClicked() ) );

View File

@ -7,27 +7,15 @@
<x>0</x>
<y>0</y>
<width>359</width>
<height>60</height>
<height>56</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>60</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>60</height>
</size>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
@ -92,7 +80,7 @@
</property>
<property name="sizeHint" stdset="0">
<size>
<width>4</width>
<width>2</width>
<height>20</height>
</size>
</property>
@ -101,10 +89,10 @@
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="topMargin">
<number>4</number>
<number>2</number>
</property>
<property name="bottomMargin">
<number>4</number>
<number>2</number>
</property>
<item>
<widget class="ElidedLabel" name="nameLabel">

View File

@ -354,9 +354,6 @@ TomahawkApp::startServent()
qDebug() << "Failed to start listening with servent";
exit( 1 );
}
//QString key = m_servent.createConnectionKey();
//qDebug() << "Generated an offer key: " << key;
}

View File

@ -146,7 +146,7 @@ QueryLabel::track() const
void
QueryLabel::setText( const QString& text )
{
setContentsMargins( 0, 0, 0, 0 );
setContentsMargins( m_textMargins );
m_result.clear();
m_query.clear();
@ -165,6 +165,9 @@ QueryLabel::setResult( const Tomahawk::result_ptr& result )
if ( result.isNull() )
return;
if ( !m_text.isEmpty() && contentsMargins().left() != 0 ) // FIXME: hacky
m_textMargins = contentsMargins();
setContentsMargins( BOXMARGIN * 2, BOXMARGIN / 2, BOXMARGIN * 2, BOXMARGIN / 2);
if ( m_result.isNull() || m_result.data() != result.data() )
@ -291,7 +294,7 @@ QueryLabel::paintEvent( QPaintEvent* event )
if ( elidedText == s && m_hoverArea.width() )
{
p.setPen( palette().shadow().color() );
p.setPen( palette().mid().color() );
p.setBrush( palette().highlight() );
p.drawRoundedRect( m_hoverArea, 4.0, 4.0 );
}
@ -299,7 +302,7 @@ QueryLabel::paintEvent( QPaintEvent* event )
if ( elidedText != s || ( m_result.isNull() && m_query.isNull() ) )
{
p.setBrush( palette().window() );
p.setPen( palette().text().color() );
p.setPen( palette().color( foregroundRole() ) );
p.drawText( r, align, elidedText );
}
else
@ -313,7 +316,7 @@ QueryLabel::paintEvent( QPaintEvent* event )
if ( m_type & Artist )
{
p.setBrush( palette().window() );
p.setPen( palette().text().color() );
p.setPen( palette().color( foregroundRole() ) );
if ( m_hoverArea.width() && m_hoverArea.left() + contentsMargins().left() == r.left() )
{
@ -327,7 +330,7 @@ QueryLabel::paintEvent( QPaintEvent* event )
if ( m_type & Album )
{
p.setBrush( palette().window() );
p.setPen( palette().text().color() );
p.setPen( palette().color( foregroundRole() ) );
if ( m_type & Artist )
{
@ -346,14 +349,14 @@ QueryLabel::paintEvent( QPaintEvent* event )
if ( m_type & Track )
{
p.setBrush( palette().window() );
p.setPen( palette().text().color() );
p.setPen( palette().color( foregroundRole() ) );
if ( m_type & Artist || m_type & Album )
{
p.drawText( r, align, DASH );
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() )
{
p.setPen( palette().highlightedText().color() );
p.setBrush( palette().highlight() );
@ -418,39 +421,51 @@ QueryLabel::mouseMoveEvent( QMouseEvent* event )
return;
}
if ( m_query.isNull() && m_result.isNull() )
{
m_hoverArea = QRect();
return;
}
const QFontMetrics& fm = fontMetrics();
int dashX = fm.width( DASH );
int artistX = m_type & Artist ? fm.width( artist() ) : 0;
int albumX = m_type & Album ? fm.width( album() ) : 0;
int trackX = m_type & Track ? fm.width( track() ) : 0;
if ( m_type & Track )
{
trackX += contentsMargins().left();
}
if ( m_type & Album )
{
trackX += albumX + dashX;
albumX += contentsMargins().left();
}
if ( m_type & Artist )
{
albumX += artistX + dashX;
trackX += artistX + dashX;
artistX += contentsMargins().left();
}
QRect hoverArea;
if ( m_type & Artist && x < artistX )
{
hoverArea.setLeft( 1 );
hoverArea.setRight( artistX + contentsMargins().left() + 2 );
hoverArea.setLeft( 0 );
hoverArea.setRight( artistX + contentsMargins().left() );
}
else if ( m_type & Album && x < albumX )
else if ( m_type & Album && x < albumX && x > artistX )
{
int spacing = ( m_type & Artist ) ? dashX : 0;
hoverArea.setLeft( artistX + spacing + 1 );
hoverArea.setRight( albumX + spacing + contentsMargins().left() + 2 );
hoverArea.setLeft( artistX + spacing );
hoverArea.setRight( albumX + spacing + contentsMargins().left() );
}
else if ( m_type & Track && x < trackX )
else if ( m_type & Track && x < trackX && x > albumX )
{
int spacing = ( m_type & Album ) ? dashX : 0;
hoverArea.setLeft( albumX + spacing + 1 );
hoverArea.setRight( trackX + contentsMargins().left() + 2 );
hoverArea.setLeft( albumX + spacing );
hoverArea.setRight( trackX + contentsMargins().left() );
}
if ( hoverArea.width() )

View File

@ -88,6 +88,7 @@ private:
QRect m_hoverArea;
QPoint m_dragPos;
QMargins m_textMargins;
};
#endif // QUERYLABEL_H