diff --git a/src/libtomahawk/playlist/ColumnViewPreviewWidget.cpp b/src/libtomahawk/playlist/ColumnViewPreviewWidget.cpp index 0750f015c..56290a8cc 100644 --- a/src/libtomahawk/playlist/ColumnViewPreviewWidget.cpp +++ b/src/libtomahawk/playlist/ColumnViewPreviewWidget.cpp @@ -74,6 +74,7 @@ ColumnViewPreviewWidget::ColumnViewPreviewWidget( ColumnView* parent ) font.setBold( true ); m_trackLabel->setFont( font ); m_trackLabel->setFixedHeight( QFontMetrics( font ).height() + 6 ); + m_trackLabel->setAlignment( Qt::AlignCenter ); mainLayout->addWidget( m_trackLabel ); m_artistLabel = new QueryLabel( this ); diff --git a/src/libtomahawk/widgets/ScrollingLabel.cpp b/src/libtomahawk/widgets/ScrollingLabel.cpp index 86881da05..33f2efd0f 100644 --- a/src/libtomahawk/widgets/ScrollingLabel.cpp +++ b/src/libtomahawk/widgets/ScrollingLabel.cpp @@ -24,13 +24,12 @@ ScrollingLabel::ScrollingLabel( QWidget* parent) - : QWidget( parent ) + : QLabel( parent ) , m_scrollPos( 0 ) , m_isMouseOver( false ) { m_staticText.setTextFormat( Qt::PlainText ); - setFixedHeight( fontMetrics().height() ); m_leftMargin = height() / 3; m_separator = QString::fromUtf8( " \u26AB " ); @@ -40,17 +39,10 @@ ScrollingLabel::ScrollingLabel( QWidget* parent) } -QString -ScrollingLabel::text() const -{ - return m_text; -} - - void -ScrollingLabel::setText( QString text ) +ScrollingLabel::setText( const QString& text ) { - m_text = text; + QLabel::setText( text ); updateText(); update(); } @@ -61,18 +53,18 @@ ScrollingLabel::updateText() { m_timer.stop(); - m_singleTextWidth = fontMetrics().width( m_text ); + m_singleTextWidth = fontMetrics().width( text() ); m_scrollEnabled = ( m_singleTextWidth > width() - m_leftMargin ); m_scrollPos = -64; if ( m_scrollEnabled && m_isMouseOver ) { - m_staticText.setText( m_text + m_separator ); + m_staticText.setText( text() + m_separator ); m_timer.start(); } else - m_staticText.setText( m_text ); + m_staticText.setText( text() ); m_staticText.prepare( QTransform(), font() ); m_wholeTextSize = QSize( fontMetrics().width( m_staticText.text() ), @@ -125,9 +117,24 @@ ScrollingLabel::paintEvent( QPaintEvent* ) } else { - p.drawStaticText( QPointF( ( width() - m_wholeTextSize.width() ) / 2., - ( height() - m_wholeTextSize.height() ) / 2. ), - m_staticText ); + //Horizontal alignment matters here + if ( alignment().testFlag( Qt::AlignLeft ) ) + { + p.drawStaticText( QPointF( indent(), ( height() - m_wholeTextSize.height() ) / 2 ), + m_staticText ); + } + else if ( alignment().testFlag( Qt::AlignRight ) ) + { + p.drawStaticText( QPointF( width() - m_wholeTextSize.width(), + ( height() - m_wholeTextSize.height() ) / 2 ), + m_staticText ); + } + else //center! + { + p.drawStaticText( QPointF( ( width() - m_wholeTextSize.width() ) / 2., + ( height() - m_wholeTextSize.height() ) / 2. ), + m_staticText ); + } } } } diff --git a/src/libtomahawk/widgets/ScrollingLabel.h b/src/libtomahawk/widgets/ScrollingLabel.h index 513b1e2f9..d9cdedda4 100644 --- a/src/libtomahawk/widgets/ScrollingLabel.h +++ b/src/libtomahawk/widgets/ScrollingLabel.h @@ -19,22 +19,20 @@ #ifndef SCROLLINGLABEL_H #define SCROLLINGLABEL_H -#include +#include #include #include -class ScrollingLabel : public QWidget +class ScrollingLabel : public QLabel { Q_OBJECT - Q_PROPERTY( QString text READ text WRITE setText ) public: explicit ScrollingLabel( QWidget* parent = 0 ); public slots: - QString text() const; - void setText( QString text ); + void setText( const QString& text ); protected: virtual void paintEvent( QPaintEvent* ); diff --git a/src/libtomahawk/widgets/infowidgets/TrackInfoWidget.ui b/src/libtomahawk/widgets/infowidgets/TrackInfoWidget.ui index 7f7131a40..394484d77 100644 --- a/src/libtomahawk/widgets/infowidgets/TrackInfoWidget.ui +++ b/src/libtomahawk/widgets/infowidgets/TrackInfoWidget.ui @@ -6,8 +6,8 @@ 0 0 - 989 - 832 + 1276 + 830 @@ -59,7 +59,7 @@ 0 - + 0 @@ -293,7 +293,7 @@ GridView QListView -
playlist/GridView.h
+
playlist/GridView.h
PlayableCover @@ -305,6 +305,11 @@ QLabel
widgets/QueryLabel.h
+ + ScrollingLabel + QLabel +
widgets/ScrollingLabel.h
+