Ejemplo n.º 1
0
void TrayIcon::startClock()
{
    kDebug(5970) << "Entering function";
    if ( _taskActiveTimer )
    {
        _taskActiveTimer->start(1000);
        setIconByPixmap( *(*icons)[_activeIcon] );
    }
    kDebug(5970) << "Leaving function";
}
Ejemplo n.º 2
0
void SysTrayIcon::updateUnreadCount( int changeOfUnreadPosts )
{
    kDebug();
    unread += changeOfUnreadPosts;

    if ( unread <= 0 ) {
        setIconByName(currentIconName());
        unread = 0;
    } else {
        // adapted from KMSystemTray::updateCount()
        int oldWidth = 22;

        QString countStr = QString::number( unread );
        QFont f = KGlobalSettings::generalFont();
        f.setBold( true );

        float pointSize = f.pointSizeF();
        QFontMetrics fm( f );
        int w = fm.width( countStr );
        if ( w > ( oldWidth - 2 ) ) {
            pointSize *= float( oldWidth - 2 ) / float( w );
            f.setPointSizeF( pointSize );
        }

        // overlay
        QPixmap overlayImg = KIcon(currentIconName()).pixmap(22,22);
        QPainter p( &overlayImg );
        p.setFont( f );
        KColorScheme scheme( QPalette::Active, KColorScheme::View );

        fm = QFontMetrics( f );
        QRect boundingRect = fm.tightBoundingRect( countStr );
        boundingRect.adjust( 0, 0, 0, 2 );
        boundingRect.setHeight( qMin( boundingRect.height(), oldWidth ) );
        boundingRect.moveTo(( oldWidth - boundingRect.width() ) / 2,
                            (( oldWidth - boundingRect.height() ) / 2 ) - 1 );
        p.setOpacity( 0.7 );
        QBrush br(QColor(255, 255, 255), Qt::SolidPattern);
        p.setBrush( br );
        p.setPen( QColor(255, 255, 255) );
        p.drawRoundedRect( boundingRect, 2.0, 2.0 );

        p.setBrush( Qt::NoBrush );
        p.setPen( QColor( 0, 0, 0 ) );
        p.setOpacity( 1.0 );
        p.drawText( overlayImg.rect(), Qt::AlignCenter, countStr );
        setIconByPixmap( overlayImg );
    }
    this->setToolTip( "choqok", i18n("Choqok"), i18np( "1 unread post", "%1 unread posts", unread ) );
}
Ejemplo n.º 3
0
void TrayIcon::resetClock()
{
    _activeIcon = 0;
    setIconByPixmap( *(*icons)[_activeIcon]);
}
Ejemplo n.º 4
0
void TrayIcon::advanceClock()
{
    _activeIcon = (_activeIcon+1) % 8;
    setIconByPixmap( *(*icons)[_activeIcon]);
}
Ejemplo n.º 5
0
void TrayIcon::slotSetUnread(int unread)
{
    m_unread = unread;

    this->setToolTip( m_defaultIcon.name(), i18n("Akregator"), i18np( "1 unread article", "%1 unread articles", unread ) );

    if (unread <= 0 || !Settings::enableTrayIconUnreadArticleCount())
    {
        setIconByName( m_defaultIcon.name() );
    }
    else
    {
        // adapted from KMSystemTray::updateCount()
        int oldWidth = KIconLoader::SizeSmallMedium;

        QString countStr = QString::number( unread );
        QFont f = KGlobalSettings::generalFont();
        f.setBold(true);

        float pointSize = f.pointSizeF();
        QFontMetrics fm(f);
        int w = fm.width(countStr);
        if( w > (oldWidth - 2) )
        {
            pointSize *= float(oldWidth - 2) / float(w);
            f.setPointSizeF(pointSize);
        }

        // overlay
        QPixmap overlayImg( oldWidth, oldWidth );
        overlayImg.fill( Qt::transparent );

        QPainter p(&overlayImg);
        p.setFont(f);
        KColorScheme scheme(QPalette::Active, KColorScheme::View);

        fm = QFontMetrics(f);
        QRect boundingRect = fm.tightBoundingRect(countStr);
        boundingRect.adjust(0, 0, 0, 2);
        boundingRect.setHeight(qMin(boundingRect.height(), oldWidth));
        boundingRect.moveTo((oldWidth - boundingRect.width()) / 2,
                            ((oldWidth - 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);
        p.drawText(overlayImg.rect(), Qt::AlignCenter, countStr);
        p.end();

        QPixmap iconPixmap = m_defaultIcon.pixmap( oldWidth, oldWidth );

        QPainter pp( &iconPixmap );
        pp.drawPixmap( 0, 0, overlayImg );
        pp.end();

        setIconByPixmap( iconPixmap );
    }
}