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

List:       kde-commits
Subject:    KDE/kdepim/kmail
From:       Torgny Nyblom <kde () nyblom ! org>
Date:       2010-12-16 20:04:09
Message-ID: 20101216200409.E4963AC8A8 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1207066 by tnyblom:

Fix the missing part of the unread message count in systemtray.
Text now scales to fit.

BUG: 250035



 M  +10 -30    kmsystemtray.cpp  


--- trunk/KDE/kdepim/kmail/kmsystemtray.cpp #1207065:1207066
@@ -174,8 +174,7 @@
     setIconByName( "kmail" );
     return;
   }
-//  int overlaySize = KIconLoader::SizeSmallMedium;
-  int overlaySize = KIconLoader::SizeMedium;
+  int overlaySize = KIconLoader::SizeSmallMedium;
 
   QString countString = QString::number( mCount );
   QFont countFont = KGlobalSettings::generalFont();
@@ -183,14 +182,14 @@
 
   // decrease the size of the font for the number of unread messages if the
   // number doesn't fit into the available space
-//   float countFontSize = countFont.pointSizeF();
-//   QFontMetrics qfm( countFont );
-//   int width = qfm.width( countString );
-//   if( width > (overlaySize - 2) )
-//   {
-//     countFontSize *= float( overlaySize - 2 ) / float( width );
-//     countFont.setPointSizeF( countFontSize );
-//   }
+  float countFontSize = countFont.pointSizeF();
+  QFontMetrics qfm( countFont );
+  int width = qfm.width( countString );
+  if( width > (overlaySize - 2) )
+  {
+    countFontSize *= float( overlaySize - 2 ) / float( width );
+    countFont.setPointSizeF( countFontSize );
+  }
 
   // Paint the number in a pixmap
   QPixmap overlayPixmap( overlaySize, overlaySize );
@@ -200,17 +199,6 @@
   p.setFont( countFont );
   KColorScheme scheme( QPalette::Active, KColorScheme::View );
 
-//   qfm = QFontMetrics( countFont );
-//   QRect boundingRect = qfm.tightBoundingRect( countString );
-//   boundingRect.adjust( 0, 0, 0, 2 );
-//   boundingRect.setHeight( qMin( boundingRect.height(), overlaySize ) );
-//   boundingRect.moveTo( (overlaySize - boundingRect.width()) / 2,
-//                         ((overlaySize - boundingRect.height()) / 2) - 1 );
-//   p.setOpacity( 0.7 );
-//   p.setBrush( scheme.background( KColorScheme::LinkBackground ) );
-//   p.setPen( scheme.background( KColorScheme::LinkBackground ).color() );
-//   p.drawRoundedRect( boundingRect, 2.0, 2.0 );
-
   p.setBrush( Qt::NoBrush );
   p.setPen( scheme.foreground( KColorScheme::LinkText ).color() );
   p.setOpacity( 1.0 );
@@ -218,20 +206,12 @@
   p.end();
 
   QPixmap iconPixmap = mIcon.pixmap(overlaySize, overlaySize);
-  //QPixmap overlayIcon = QIcon(overlayPixmap).pixmap(overlaySize/2, overlaySize/2);
 
   QPainter pp(&iconPixmap);
-  pp.drawPixmap(0,0 /*iconPixmap.width()-overlayIcon.width(), \
iconPixmap.height()-overlayIcon.height()*/, overlayPixmap); +  pp.drawPixmap(0, 0, \
overlayPixmap);  pp.end();
 
-  //QIcon countIcon = mIcon;
-
-  //countIcon.addPixmap(overlayPixmap);
-  //QPixmap overlayPixmap = overlayImage.pixmap(overlaySize/2, overlaySize/2);
-
   setIconByPixmap( iconPixmap );
-  //setIconByPixmap( iconPixmap );
-  kWarning() << "count:" << mCount;
 }
 
 


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

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