Version: 2.2.2 (using 4.3.4 (KDE 4.3.4), Gentoo) Compiler: x86_64-pc-linux-gnu-gcc OS: Linux (x86_64) release 2.6.30-gentoo-r6 When song metadata contains html-like tags, the metadata is not shown in the current track applet. For example this band http://www.myspace.com/codeblackmetal will show up as "The Rattle Of Black Teeth\n By\n On Fear Candy 69". It shows up correctly in all other places. The expected behaviour is that the metadata should be shown, with angle brackets, here as well.
Created attachment 39903 [details] Screenshot of the bug
commit bc32723df802bc6306c98ee4b2c4eddca733cebc Author: Nikolaj Hald Nielsen <nhn@kde.org> Date: Mon Mar 15 14:58:58 2010 +0100 Use Plaintext instead of html in TextScrollingWidget. This fixes issue with some strings getting shown inccorectly in the current track applet becuase of special characters ( like < and > ) being present. ChangeLog++ BUG: 222765 diff --git a/ChangeLog b/ChangeLog index a62dd94..8c15847 100644 --- a/ChangeLog +++ b/ChangeLog @@ -21,6 +21,9 @@ VERSION 2.3.1-Beta 1 some MySQL versions. (BR 225052) BUGFIXES: + * Fixed some artist/album/track names not getting shown or getting shown + incorrectly in the Current Track applet because of html encoding. + (BR 222765) * Fixed issue with the Albums applet not correctly updating when playing a track by an artist not present in the local collection. * Fixed Albums applet not getting updated if the artist of the currently diff --git a/src/context/widgets/TextScrollingWidget.cpp b/src/context/widgets/TextScrollingWidget.cpp index 6462b0f..4c85a4c 100644 --- a/src/context/widgets/TextScrollingWidget.cpp +++ b/src/context/widgets/TextScrollingWidget.cpp @@ -77,7 +77,7 @@ TextScrollingWidget::setScrollingText( const QString text, QRectF rect ) void TextScrollingWidget::setText( const QString &text ) { - setHtml( text ); + setPlainText( text ); } QString
commit 8faa6e1454524b604d4114a65b1f86d0e3ee01f3 Author: Rick W. Chen <stuffcorpse@archlinux.us> Date: Fri May 21 05:55:28 2010 +1200 Fix lyrics applet title and ampersands Commit bc32723 introduced a regression. While the current track applet will now correctly show special characters (which was broken by an even earlier commit 3d3a77f), the lyrics applet now suffers from the same issue. This fixes that by allowing a particular text format to be set for the TextScrollingWidget, with plain text as the default. CCBUG:220714 CCBUG:222765 diff --git a/src/context/applets/lyrics/LyricsApplet.cpp b/src/context/applets/lyrics/LyricsApplet.cpp index 3fcf3b2..c1944e4 100644 --- a/src/context/applets/lyrics/LyricsApplet.cpp +++ b/src/context/applets/lyrics/LyricsApplet.cpp @@ -78,6 +78,7 @@ void LyricsApplet::init() m_titleLabel = new TextScrollingWidget( this ); QFont bigger = m_titleLabel->font(); bigger.setPointSize( bigger.pointSize() + 2 ); + m_titleLabel->setTextFormat( Qt::RichText ); m_titleLabel->setFont( bigger ); m_titleLabel->setZValue( m_titleLabel->zValue() + 100 ); m_titleLabel->setText( i18n( "Lyrics" ) ); diff --git a/src/context/widgets/TextScrollingWidget.cpp b/src/context/widgets/TextScrollingWidget.cpp index 2d5d5e5..65def77 100644 --- a/src/context/widgets/TextScrollingWidget.cpp +++ b/src/context/widgets/TextScrollingWidget.cpp @@ -35,6 +35,7 @@ TextScrollingWidget::TextScrollingWidget( QGraphicsItem* parent ) : QGraphicsTextItem( parent ) , m_fm( 0 ) + , m_textFormat( Qt::PlainText ) , m_delta( 0 ) , m_currentDelta( 0. ) , m_animfor( 0 ) @@ -53,7 +54,7 @@ TextScrollingWidget::setBrush( const QBrush &brush ) } void -TextScrollingWidget::setScrollingText( const QString text, QRectF rect ) +TextScrollingWidget::setScrollingText( const QString &text, const QRectF &rect ) { // DEBUG_BLOCK if ( !m_fm ) @@ -67,22 +68,60 @@ TextScrollingWidget::setScrollingText( const QString text, QRectF rect ) Plasma::Animator::self()->stopCustomAnimation( m_animfor ); m_animating = false ; - const QRect textRect = m_fm->boundingRect( m_text ); - m_delta = textRect.width() + 5 > m_rect.width() - ? textRect.width() + 8 - m_rect.width() : 0; - setText( m_fm->elidedText ( m_text, Qt::ElideRight, (int)m_rect.width() ) ); + const int textWidth = m_fm->width( m_text ); + m_delta = textWidth + 5 > m_rect.width() ? textWidth + 8 - m_rect.width() : 0; + setText( m_fm->elidedText( m_text, Qt::ElideRight, (int)m_rect.width() ) ); } void TextScrollingWidget::setText( const QString &text ) { - setPlainText( text ); + if( requirePlainText() ) + setPlainText( text ); + else + setHtml( text ); +} + +void +TextScrollingWidget::setTextFormat( Qt::TextFormat fmt ) +{ + m_textFormat = fmt; } QString TextScrollingWidget::text() const { - return toPlainText(); + if( requirePlainText() ) + return toPlainText(); + else + return toHtml(); +} + +bool +TextScrollingWidget::requirePlainText() const +{ + bool plain; + switch( m_textFormat ) + { + case Qt::RichText: + plain = false; + break; + + case Qt::AutoText: + plain = !Qt::mightBeRichText( m_text ); + break; + + case Qt::PlainText: + default: + plain = true; + } + return plain; +} + +Qt::TextFormat +TextScrollingWidget::textFormat() const +{ + return m_textFormat; } void @@ -136,7 +175,7 @@ TextScrollingWidget::animationFinished( int id ) else { m_animating = false; - setText( m_fm->elidedText ( m_text, Qt::ElideRight, (int)( m_rect.width() ) ) ); + setText( m_fm->elidedText( m_text, Qt::ElideRight, (int)( m_rect.width() ) ) ); } } } diff --git a/src/context/widgets/TextScrollingWidget.h b/src/context/widgets/TextScrollingWidget.h index 0b1d6e3..6e41be8 100644 --- a/src/context/widgets/TextScrollingWidget.h +++ b/src/context/widgets/TextScrollingWidget.h @@ -51,11 +51,13 @@ class AMAROK_EXPORT TextScrollingWidget : public QGraphicsTextItem /** * Set the Text and more important the QRectF which will define the scrolling area */ - void setScrollingText( const QString, QRectF ); + void setScrollingText( const QString &text, const QRectF &rect ); void setText( const QString &text ); + void setTextFormat( Qt::TextFormat fmt ); QString text() const; + Qt::TextFormat textFormat() const; bool isAnimating(); @@ -83,11 +85,14 @@ class AMAROK_EXPORT TextScrollingWidget : public QGraphicsTextItem QRectF m_rect; // box size QFontMetrics *m_fm; // font metrics which will cut the text. QString m_text; // full sentence + Qt::TextFormat m_textFormat; // text format int m_delta; // complete delta float m_currentDelta; // current delta int m_animfor; // anim id for int m_animback; // anim id back bool m_animating; // boolean ! + + bool requirePlainText() const; }; #endif