20 #include <KIconLoader>
21 #include <KGlobalSettings>
23 #include <KColorScheme>
31 setToolTipTitle( i18n(
"KNotes: Sticky notes for KDE" ) );
32 setToolTipIconByName( QLatin1String(
"knotes") );
33 setStatus( KStatusNotifierItem::Active );
34 setCategory( KStatusNotifierItem::ApplicationStatus );
35 setStandardActionsEnabled(
false);
36 mIcon = KIcon( QLatin1String(
"knotes") );
45 const int overlaySize = KIconLoader::SizeSmallMedium;
47 const QString countString = QString::number( value );
48 QFont countFont = KGlobalSettings::generalFont();
49 countFont.setBold(
true);
53 float countFontSize = countFont.pointSizeF();
54 QFontMetrics qfm( countFont );
55 const int width = qfm.width( countString );
56 if ( width > (overlaySize - 2) ) {
57 countFontSize *= float( overlaySize - 2 ) / float( width );
58 countFont.setPointSizeF( countFontSize );
62 QPixmap overlayPixmap( overlaySize, overlaySize );
63 overlayPixmap.fill( Qt::transparent );
65 QPainter p( &overlayPixmap );
66 p.setFont( countFont );
67 KColorScheme scheme( QPalette::Active, KColorScheme::View );
69 p.setBrush( Qt::NoBrush );
70 p.setPen( scheme.foreground( KColorScheme::LinkText ).color() );
72 p.drawText( overlayPixmap.rect(),Qt::AlignCenter, countString );
75 QPixmap iconPixmap = mIcon.pixmap(overlaySize, overlaySize);
77 QPainter pp(&iconPixmap);
78 pp.drawPixmap(0, 0, overlayPixmap);
81 setIconByPixmap( iconPixmap );
84 #include "knotestray.moc"
KNotesTray(QWidget *parent=0)
void updateNumberOfNotes(int value)