From c7318649f344028b18348d30790db67876558535 Mon Sep 17 00:00:00 2001 From: Teo Mrnjavac Date: Thu, 9 Jan 2014 17:22:04 +0100 Subject: [PATCH] Do not elide artist name when there's enough space. --- src/libtomahawk/playlist/ColumnViewPreviewWidget.cpp | 10 ++++++++-- src/libtomahawk/playlist/ColumnViewPreviewWidget.h | 3 ++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/libtomahawk/playlist/ColumnViewPreviewWidget.cpp b/src/libtomahawk/playlist/ColumnViewPreviewWidget.cpp index 2d40db1d7..fbd2793e1 100644 --- a/src/libtomahawk/playlist/ColumnViewPreviewWidget.cpp +++ b/src/libtomahawk/playlist/ColumnViewPreviewWidget.cpp @@ -1,6 +1,7 @@ /* === This file is part of Tomahawk Player - === * - * Copyright 2013, Christian Muehlhaeuser + * Copyright 2013, Christian Muehlhaeuser + * Copyright 2013-2014, Teo Mrnjavac * * Tomahawk is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -68,7 +69,6 @@ ColumnViewPreviewWidget::ColumnViewPreviewWidget( ColumnView* parent ) #endif m_trackLabel = new ScrollingLabel( this ); - //m_trackLabel->setAlignment( Qt::AlignCenter ); QFont font; font.setPointSize( TomahawkUtils::defaultFontSize() + 9 ); font.setBold( true ); @@ -87,6 +87,7 @@ ColumnViewPreviewWidget::ColumnViewPreviewWidget( ColumnView* parent ) QHBoxLayout* artistLayout = new QHBoxLayout; artistLayout->addStretch(); artistLayout->addWidget( m_artistLabel ); + m_artistLabel->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Preferred ); artistLayout->addStretch(); mainLayout->addLayout( artistLayout ); @@ -197,6 +198,11 @@ ColumnViewPreviewWidget::setQuery( const Tomahawk::query_ptr& query ) m_trackLabel->setText( query->track()->track() ); m_artistLabel->setArtist( query->track()->artistPtr() ); + m_artistLabel->setMinimumWidth( qMin( m_artistLabel->fontMetrics().width( query->track()->artist() ) + + m_artistLabel->contentsMargins().left() + + m_artistLabel->contentsMargins().right() + + 2 * m_artistLabel->lineWidth(), + width() ) ); m_artistLabel->setElideMode( Qt::ElideRight ); m_composerValue->setText( query->track()->composer() ); diff --git a/src/libtomahawk/playlist/ColumnViewPreviewWidget.h b/src/libtomahawk/playlist/ColumnViewPreviewWidget.h index 3935fedcc..523532968 100644 --- a/src/libtomahawk/playlist/ColumnViewPreviewWidget.h +++ b/src/libtomahawk/playlist/ColumnViewPreviewWidget.h @@ -1,6 +1,7 @@ /* === This file is part of Tomahawk Player - === * - * Copyright 2013, Christian Muehlhaeuser + * Copyright 2013, Christian Muehlhaeuser + * Copyright 2013-2014, Teo Mrnjavac * * Tomahawk is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by