예제 #1
0
void TaskLMBMenu::fillMenu()
{
    setCheckable(true);

    Task::List::iterator itEnd = m_tasks.end();
    for (Task::List::iterator it = m_tasks.begin(); it != itEnd; ++it)
    {
        Task::Ptr t = (*it);

        QString text = t->visibleName().replace("&", "&&");

        TaskMenuItem *menuItem = new TaskMenuItem(text,
                                                  t->isActive(),
                                                  t->isIconified(),
                                                  t->demandsAttention());
        int id = insertItem(QIconSet(t->pixmap()), menuItem);
        connectItem(id, t, SLOT(activateRaiseOrIconify()));
        setItemChecked(id, t->isActive());

        if (t->demandsAttention())
        {
            m_attentionState = true;
            m_attentionMap.append(menuItem);
        }
    }

    if (m_attentionState)
    {
        m_attentionTimer = new QTimer(this, "AttentionTimer");
        connect(m_attentionTimer, SIGNAL(timeout()), SLOT(attentionTimeout()));
        m_attentionTimer->start(500, true);
    }
}
예제 #2
0
void KasGroupItem::paint(QPainter *p)
{
    KasItem::paint(p);

    //
    // Item summary info
    //
    int modCount = 0;
    for(Task::List::iterator it = items.begin(); it != items.end(); ++it)
    {
        if((*it)->isModified())
            modCount++;
    }

    KasResources *res = resources();

    p->setPen(isShowingPopup() ? res->activePenColor() : res->inactivePenColor());

    if(modCount)
    {
        QString modCountStr;
        modCountStr.setNum(modCount);
        p->drawText(extent() - fontMetrics().width(modCountStr) - 3, 15 + fontMetrics().ascent(), modCountStr);

        p->drawPixmap(extent() - 12, 29, res->modifiedIcon());
    }

    int microsPerCol;
    switch(kasbar()->itemSize())
    {
        default:
        case KasBar::Small:
            microsPerCol = 2;
            break;
        case KasBar::Medium:
            microsPerCol = 4;
            break;
        case KasBar::Large:
            microsPerCol = 7;
            break;
        case KasBar::Huge:
            microsPerCol = 9;
            break;
        case KasBar::Enormous:
            microsPerCol = 16;
            break;
    }

    int xpos = 3;
    int ypos = 16;

    for(int i = 0; (i < (int)items.count()) && (i < microsPerCol); i++)
    {
        Task::Ptr t = items.at(i);

        if(t->isIconified())
            p->drawPixmap(xpos, ypos, res->microMinIcon());
        else if(t->isShaded())
            p->drawPixmap(xpos, ypos, res->microShadeIcon());
        else
            p->drawPixmap(xpos, ypos, res->microMaxIcon());

        ypos += 7;
    }

    if(((int)items.count() > microsPerCol) && (kasbar()->itemSize() != KasBar::Small))
    {
        QString countStr;
        countStr.setNum(items.count());
        p->drawText(extent() - fontMetrics().width(countStr) - 3, extent() + fontMetrics().ascent() - 16, countStr);
    }
}