Bug 254029 - 'Scale Font' option in OSD settings has no effect on OSD preview
Summary: 'Scale Font' option in OSD settings has no effect on OSD preview
Status: RESOLVED FIXED
Alias: None
Product: amarok
Classification: Applications
Component: Notifications (show other bugs)
Version: 2.4-GIT
Platform: Ubuntu Linux
: NOR normal
Target Milestone: 2.4.0
Assignee: Amarok Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-10-13 06:23 UTC by Matt Howe
Modified: 2011-01-15 10:31 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Matt Howe 2010-10-13 06:23:38 UTC
Version:           2.4-GIT (using KDE 4.5.1) 
OS:                Linux

The Scale Font option in the OSD settings window has no effect on the OSD preview, it does however scale the font when playing tracks.

Reproducible: Always


Actual Results:  
Nothing.

Expected Results:  
Size of font in OSD preview should be larger.

OS: Linux (x86_64) release 2.6.35-22-generic
Compiler: cc
Comment 1 Myriam Schweingruber 2010-10-15 13:00:31 UTC

*** This bug has been marked as a duplicate of bug 195186 ***
Comment 2 Mathieu Roy 2010-12-30 22:07:02 UTC
Actually, this is not a duplicate. Bug 195186 was "OSD font uses absolute point size. should be relative". Bug 195186 is fixed. But this is one is not, as of today in the current 2.4beta1. This is a distinct bug that remains to be fixed (even if it was already mentioned in bug 195186. 'Scale Font' option in OSD settings still has no effect on OSD preview. 

You should reopen it.
Comment 3 Myriam Schweingruber 2011-01-04 03:59:22 UTC
Reopening.
Comment 4 Kevin Funk 2011-01-15 10:31:46 UTC
commit ba66192ba096bce6903abde422b7c919a0bd0edc
branch master
Author: Kevin Funk <krf@electrostorm.net>
Date:   Sat Jan 15 02:25:15 2011 +0100

    Fix OSD preview widget wrt scaling, clean up
    
    This is a follow-up on d9d27ca96e4a1e8c06aea03c8c4cddcbbd02daf7.
    
    CCBUG: 195186
    BUG: 254029

diff --git a/ChangeLog b/ChangeLog
index c7ab729..1d9a0c7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -9,11 +9,16 @@ VERSION 2.4.1
   CHANGES:
 
   BUGFIXES:
-    * Fixed issue with playlist tooltips that was shown independetly from "Show tooltip" option. (BR 263121)
-    * Fixed issues with multifiles cuesheet, when all tracks get metadata of last track
+    * Fixed 'Scale Font' option in OSD options for OSD preview widget.
+      (BR 254029)
+    * Fixed issue with playlist tooltips that was shown independetly from
+      "Show tooltip" option. (BR 263121)
+    * Fixed issues with multifiles cuesheet, when all tracks get metadata of
+      last track
       in cuesheet, and each file defined in sheet gets all tracks of this sheet.
       (BR 262668) (BR 209341)
-    * Fixed crash when trying to download a full size cover and the server redirects the request. (BR 262902)
+    * Fixed crash when trying to download a full size cover and the server
+      redirects the request. (BR 262902)
     * Fixed issue when breadcrumbs stayed not updated after service insert/remove.
       (BR 262780)
     * Fixed issue with TagDialog that make metadata fields stay editable if multiple
diff --git a/src/widgets/Osd.cpp b/src/widgets/Osd.cpp
index 05c16da..b843f5d 100644
--- a/src/widgets/Osd.cpp
+++ b/src/widgets/Osd.cpp
@@ -63,7 +63,6 @@ OSDWidget::OSDWidget( QWidget *parent, const char *name )
         , m_rating( 0 )
         , m_volume( 0 )
         , m_showVolume( false )
-        , m_fontScale( 1.15 )
 {
     Qt::WindowFlags flags;
     flags = Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint;
@@ -81,6 +80,9 @@ OSDWidget::OSDWidget( QWidget *parent, const char *name )
     setFocusPolicy( Qt::NoFocus );
     unsetColors();
 
+    QFont font("sans-serif");
+    setFont(font);
+
     #ifdef Q_WS_X11
     KWindowSystem::setType( winId(), NET::Notification );
     #endif
@@ -114,10 +116,6 @@ OSDWidget::show( const QString &text, QImage newImage )
     else
         m_cover = Amarok::icon();
 
-    QFont f = QFont( "sans-serif" );
-    f.setPointSizeF( f.pointSizeF() * m_fontScale );
-    setFont( f );
-
     m_text = text;
     show();
 }
@@ -299,8 +297,8 @@ OSDWidget::determineMetrics( const int M )
 void
 OSDWidget::paintEvent( QPaintEvent *e )
 {
-    int M = m_m;
-    QSize size = m_size;
+    const int& M = m_m;
+    const QSize& size = m_size;
 
     QPoint point;
     QRect rect( point, size );
@@ -381,6 +379,7 @@ OSDWidget::paintEvent( QPaintEvent *e )
 
         p.drawImage( rect.topLeft() - QPoint( 5, 5 ), ShadowEngine::makeShadow( pixmap, shadowColor ) );
     }
+    p.setFont( font() );
     p.setPen( palette().color( QPalette::Active, QPalette::WindowText ) );
     //p.setPen( Qt::white ); // This too.
     p.drawText( rect, align, m_text );
diff --git a/src/widgets/Osd.h b/src/widgets/Osd.h
index c261314..bda01df 100644
--- a/src/widgets/Osd.h
+++ b/src/widgets/Osd.h
@@ -21,17 +21,12 @@
 #include "core/meta/Meta.h"
 
 #include <QImage>
-#include <QList>
 #include <QPixmap>
 #include <QString>
 #include <QWidget> //baseclass
 
 #define OSD_WINDOW_OPACITY 0.74
 
-namespace Plasma
-{
-    class PanelSvg;
-}
 
 class OSDWidget : public QWidget
 {
@@ -77,7 +72,17 @@ class OSDWidget : public QWidget
         void setText( const QString &text ) { m_text = text; }
         void setRating( const short rating ) { if ( isEnabled() ) m_rating = rating; }
         void setTranslucent( bool enabled ) { setWindowOpacity( enabled ? OSD_WINDOW_OPACITY : 1.0 ); }
-        void setFontScale( int scale ) { m_fontScale = static_cast<double>(scale) / 100.0; }
+        void setFontScale( int scale ) {
+            double fontScale = static_cast<double>( scale ) / 100.0;
+
+            // update font, reuse old one
+            QFont newFont( font() );
+            newFont.setPointSizeF( defaultPointSize() * fontScale );
+            setFont( newFont );
+        }
+
+        // work-around to get default point size on this platform, Qt API does not offer this directly
+        static inline double defaultPointSize() { return QFont().pointSizeF(); }
 
     protected:
         virtual ~OSDWidget();
@@ -109,7 +114,6 @@ class OSDWidget : public QWidget
         QImage      m_cover;
         QPixmap     m_scaledCover;
         bool        m_paused;
-        double      m_fontScale;
 };
 
 
@@ -120,9 +124,9 @@ class OSDPreviewWidget : public OSDWidget
 public:
     OSDPreviewWidget( QWidget *parent );
 
-    int screen()    { return m_screen; }
-    int alignment() { return m_alignment; }
-    int y()         { return m_y; }
+    int screen() const    { return m_screen; }
+    int alignment() const { return m_alignment; }
+    int y() const         { return m_y; }
 
 public slots:
     void setTextColor( const QColor &color ) { OSDWidget::setTextColor( color ); doUpdate(); }