Bug 222277

Summary: Lyrics applet font settings not saved properly
Product: [Applications] amarok Reporter: perrantrevan
Component: Context ViewAssignee: Amarok Developers <amarok-bugs-dist>
Status: RESOLVED FIXED    
Severity: normal CC: lfranchi, simon.esneault, stuffcorpse
Priority: NOR    
Version: 2.2.2   
Target Milestone: ---   
Platform: unspecified   
OS: Linux   
Latest Commit: Version Fixed In:

Description perrantrevan 2010-01-11 20:29:39 UTC
Version:           2.2.2 (using 4.3.90 (KDE 4.3.90 (KDE 4.4 RC1)), Kubuntu packages)
Compiler:          cc
OS:                Linux (x86_64) release 2.6.32-020632-generic

I changed the lyrics applet font from the system default (Liberation Sans) to Liberation Serif Italic.

The setting is applied successfully until I close and then restart the program. The font remains Liberation Serif but is the Normal rather than Italic version.
Comment 1 Myriam Schweingruber 2010-01-12 00:49:40 UTC
Confirmed with current git.
Comment 2 Rick W. Chen 2010-01-13 06:18:33 UTC
commit 112929450a0192a54353f52d5405f54c7cb399bd
Author: Rick W. Chen <stuffcorpse@archlinux.us>
Date:   Wed Jan 13 18:14:08 2010 +1300

    Fix lyrics applet settings not saving and restoring font styles
    
    BUG: 222277

diff --git a/src/context/applets/lyrics/LyricsApplet.cpp b/src/context/applets/lyrics/LyricsApplet.cpp
index b932f8f..0529b4c 100644
--- a/src/context/applets/lyrics/LyricsApplet.cpp
+++ b/src/context/applets/lyrics/LyricsApplet.cpp
@@ -148,9 +148,10 @@ void LyricsApplet::init()
 
     // Read config
     KConfigGroup config = Amarok::config("Lyrics Applet");
-    QFont font( config.readEntry( "Font", QString() ),
-                config.readEntry( "Size", -1 ) );
-    m_lyrics->setFont( font );
+    QFont font;
+    bool fontGood = font.fromString( config.readEntry( "Font", QString() ) );
+    if( fontGood )
+        m_lyrics->setFont( font );
 
     connect( m_suggested, SIGNAL( anchorClicked( const QUrl& ) ), this, SLOT( suggestionChosen( const QUrl& ) ) );
     connect( dataEngine( "amarok-lyrics" ), SIGNAL( sourceAdded( const QString& ) ), this, SLOT( connectSource( const QString& ) ) );
@@ -401,8 +402,7 @@ LyricsApplet::changeLyricsFont()
     m_lyrics->setFont( font );
 
     KConfigGroup config = Amarok::config("Lyrics Applet");
-    config.writeEntry( "Font", font.family() );
-    config.writeEntry( "Size", font.pointSize() );
+    config.writeEntry( "Font", font.toString() );
 
     debug() << "Setting Lyrics Applet font: " << font.family() << " " << font.pointSize();
     // resize with new font