Summary: | [PATCH] If album keyword is empty, show "unknown album" in context window | ||
---|---|---|---|
Product: | [Applications] amarok | Reporter: | Mikael Lammentausta <mikael.lammentausta> |
Component: | Context View/Current Track | Assignee: | Amarok Developers <amarok-bugs-dist> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | kfunk, lfranchi, nsm.nikhil, simon.esneault, vianasw |
Priority: | NOR | ||
Version: | 2.3-GIT | ||
Target Milestone: | 2.4.0 | ||
Platform: | Compiled Sources | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | 2.4 | |
Sentry Crash Report: | |||
Attachments: | Patch to show unknown album/artist as an inactive text field |
Description
Mikael Lammentausta
2009-08-25 04:19:25 UTC
This is the case for all fields in the current track applet. We should fix this. I have a fix ready, but I'm not sure if we're in string freeze right now. I can commit once that is clarified Created attachment 51786 [details]
Patch to show unknown album/artist as an inactive text field
Nikhil, string freeze is over since version 2.3.2 has been tagged commit 68672153b8474cd66d49cb50e3180690d1f40b1f Author: Nikhil Marathe <nsm.nikhil@gmail.com> Date: Mon Sep 27 15:04:01 2010 +0530 Fixed bug 205038 for CurrentTrackInfo applet If the album/artist is empty, "Unknown Album/Artist" is displayed using the disabled palette. This patch does have code repetition due to the requirement to have various things like geometry information and more around which makes putting the unknown information checking into a seperate function unwieldy. BUG: 205038 diff --git a/ChangeLog b/ChangeLog index 9a48538..2622a99 100644 --- a/ChangeLog +++ b/ChangeLog @@ -17,6 +17,7 @@ VERSION NEXT pressing SHIFT while clicking the action will bypass trash. BUGFIXES: + * If album keyword is empty, show "unknown album" in context window (BR 205038) * Ampache wouldn't connect to servers placed in a subdirectory. * Fixed an initialization bug which affected all context applets. * Fix bug where users could drag applets around indiscriminately diff --git a/src/context/applets/currenttrack/CurrentTrack.cpp b/src/context/applets/currenttrack/CurrentTrack.cpp index 7c70890..e6526f5 100644 --- a/src/context/applets/currenttrack/CurrentTrack.cpp +++ b/src/context/applets/currenttrack/CurrentTrack.cpp @@ -275,13 +275,33 @@ void CurrentTrack::constraintsEvent( Plasma::Constraints constraints ) m_title->setPos( artistPos.x(), artistPos.y() - lineSpacing ); const QString title = m_currentInfo[ Meta::Field::TITLE ].toString(); - const QString artist = m_currentInfo.contains( Meta::Field::ARTIST ) ? m_currentInfo[ Meta::Field::ARTIST ].toString() : QString(); - const QString album = m_currentInfo.contains( Meta::Field::ALBUM ) ? m_currentInfo[ Meta::Field::ALBUM ].toString() : QString(); + QString artist = m_currentInfo.contains( Meta::Field::ARTIST ) ? m_currentInfo[ Meta::Field::ARTIST ].toString() : QString(); + + if( artist.isNull() ) { + QBrush brush = KColorScheme( QPalette::Disabled ).foreground( KColorScheme::NormalText ); + m_artist->setBrush( brush ); + artist = i18n( "Unknown Artist" ); + } + else { + QBrush brush = KColorScheme( QPalette::Active ).foreground( KColorScheme::NormalText ); + m_artist->setBrush( brush ); + } + + QString album = m_currentInfo.contains( Meta::Field::ALBUM ) ? m_currentInfo[ Meta::Field::ALBUM ].toString() : QString(); + + if( album.isNull() ) { + QBrush brush = KColorScheme( QPalette::Disabled ).foreground( KColorScheme::NormalText ); + m_album->setBrush( brush ); + album = i18n( "Unknown Album" ); + } + else { + QBrush brush = KColorScheme( QPalette::Active ).foreground( KColorScheme::NormalText ); + m_album->setBrush( brush ); + } m_title->setScrollingText( title, QRectF( m_title->pos().x(), textY, textWidth, 30 ) ); m_artist->setScrollingText( artist, QRectF( artistPos.x(), textY, textWidth, 30 ) ); m_album->setScrollingText( album, QRectF( albumPos.x(), textY, textWidth, 30 ) ); - if( !m_trackActions.isEmpty() ) { QPointF iconPos = albumPos; @@ -376,10 +396,34 @@ CurrentTrack::dataUpdated( const QString& name, const Plasma::DataEngine::Data& m_favoriteTracks.clear(); m_currentInfo = data[ "current" ].toMap(); - m_title->setScrollingText( m_currentInfo[ Meta::Field::TITLE ].toString(), textRect ); - const QString artist = m_currentInfo.contains( Meta::Field::ARTIST ) ? m_currentInfo[ Meta::Field::ARTIST ].toString() : QString(); + + const QString title = m_currentInfo[ Meta::Field::TITLE ].toString(); + QString artist = m_currentInfo.contains( Meta::Field::ARTIST ) ? m_currentInfo[ Meta::Field::ARTIST ].toString() : QString(); + + if( artist.isNull() ) { + QBrush brush = KColorScheme( QPalette::Disabled ).foreground( KColorScheme::NormalText ); + m_artist->setBrush( brush ); + artist = i18n( "Unknown Artist" ); + } + else { + QBrush brush = KColorScheme( QPalette::Active ).foreground( KColorScheme::NormalText ); + m_artist->setBrush( brush ); + } + + QString album = m_currentInfo.contains( Meta::Field::ALBUM ) ? m_currentInfo[ Meta::Field::ALBUM ].toString() : QString(); + + if( album.isNull() ) { + QBrush brush = KColorScheme( QPalette::Disabled ).foreground( KColorScheme::NormalText ); + m_album->setBrush( brush ); + album = i18n( "Unknown Album" ); + } + else { + QBrush brush = KColorScheme( QPalette::Active ).foreground( KColorScheme::NormalText ); + m_album->setBrush( brush ); + } + + m_title->setScrollingText( title, textRect ); m_artist->setScrollingText( artist, textRect ); - const QString album = m_currentInfo.contains( Meta::Field::ALBUM ) ? m_currentInfo[ Meta::Field::ALBUM ].toString() : QString(); m_album->setScrollingText( album, textRect ); m_rating = m_currentInfo[ Meta::Field::RATING ].toInt(); |