[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    kdeextragear-2/konversation/konversation
From:       Max Howell <max.howell () methylblue ! com>
Date:       2005-04-30 21:34:24
Message-ID: 20050430213424.30E48629 () office ! kde ! org
[Download RAW message or body]

CVS commit by mhowell: 

This makes the OSD corners the same roundedness whatever the size of the OSD. No more \
square corners for large texts! Ported from amaroK. I can also port the \
shadow/translucency code if people like, but the shadow code is slow so I'd suggest a \
no for that. The translucency though is very useful.


  M +14 -8     osd.cpp   1.18


--- kdeextragear-2/konversation/konversation/osd.cpp  #1.17:1.18
@@ -53,6 +53,9 @@ void OSDWidget::renderOSDText( const QSt
     static QBitmap mask;
 
+    //This is various spacings and margins, based on the font to look "just right"
+    const uint METRIC = fontMetrics().width( 'x' );
+
     // Set a sensible maximum size, don't cover the whole desktop or cross the \
                screen
-    QSize max = QApplication::desktop() ->screen( m_screen ) ->size() - QSize( \
MARGIN*2 + 20, 100 ); +    QSize max = QApplication::desktop()->screen( m_screen \
)->size() - QSize( MARGIN*2 + METRIC*2, 100 );  QFont titleFont( "Arial", 12, \
QFont::Bold );  QFontMetrics titleFm( titleFont );
@@ -60,5 +63,5 @@ void OSDWidget::renderOSDText( const QSt
     // The title cannnot be taller than one line
     // AlignAuto = align Arabic to the right, etc.
-    QRect titleRect = titleFm.boundingRect( 0, 0, max.width(), titleFm.height(), \
AlignAuto, m_appName ); +    QRect titleRect = titleFm.boundingRect( 0, 0, \
max.width() - METRIC, titleFm.height(), AlignAuto, m_appName );  // The osd cannot be \
                larger than the screen
     QRect textRect = fontMetrics().boundingRect( 0, 0, max.width(), max.height(), \
AlignAuto | WordBreak, text ); @@ -68,5 +71,5 @@ void OSDWidget::renderOSDText( const \
QSt  
     //this should still be within the screen bounds
-    textRect.addCoords( 0, 0, 20, titleRect.height() );
+    textRect.addCoords( 0, 0, METRIC*2, titleRect.height() + METRIC );
 
     osdBuffer.resize( textRect.size() );
@@ -78,7 +81,10 @@ void OSDWidget::renderOSDText( const QSt
 
     // Draw backing rectangle
+    const uint xround = (METRIC * 200) / textRect.width();
+    const uint yround = (METRIC * 200) / textRect.height();
+
     bufferPainter.setPen( Qt::black );
     bufferPainter.setBrush( backgroundColor() );
-    bufferPainter.drawRoundRect( textRect, 1500 / textRect.width(), 1500 / \
textRect.height() ); +    bufferPainter.drawRoundRect( textRect, xround, yround );
     bufferPainter.setFont( font() );
 
@@ -89,19 +95,19 @@ void OSDWidget::renderOSDText( const QSt
     if ( m_shadow ) {
         bufferPainter.setPen( backgroundColor().dark( 175 ) );
-        bufferPainter.drawText( 13, titleFm.height() + 1, w, h, AlignLeft | \
WordBreak, text ); +        bufferPainter.drawText( METRIC + 3, (METRIC/2) + \
titleFm.height() + 1, w, h, AlignLeft | WordBreak, text );  }
 
     // Draw the text
     bufferPainter.setPen( foregroundColor() );
-    bufferPainter.drawText( 10, titleFm.height() - 1, w, h, AlignLeft | WordBreak, \
text ); +    bufferPainter.drawText( METRIC, (METRIC/2) + titleFm.height() - 1, w, h, \
AlignLeft | WordBreak, text );  
     // Draw the title text
     bufferPainter.setFont( titleFont );
-    bufferPainter.drawText( 10, 3, w, h, AlignLeft, m_appName );
+    bufferPainter.drawText( METRIC * 2, (METRIC/2), w, h, AlignLeft, m_appName );
 
     // Masking for transparency
     mask.fill( Qt::black );
     maskPainter.setBrush( Qt::white );
-    maskPainter.drawRoundRect( textRect, 1500 / textRect.width(), 1500 / \
textRect.height() ); +    maskPainter.drawRoundRect( textRect, xround, yround );
     setMask( mask );
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic