Ejemplo n.º 1
0
void TaskLMBMenu::mouseMoveEvent(QMouseEvent* e)
{
    if (m_dragStartPos.isNull())
    {
        QPopupMenu::mouseMoveEvent(e);
        return;
    }

    int delay = KGlobalSettings::dndEventDelay();
    QPoint newPos(e->pos());

    if ((m_dragStartPos - newPos).manhattanLength() > delay)
    {
        int index = indexOf(idAt(m_dragStartPos));
        if (index != -1)
        {
            bool ok = false;
            Task::Ptr task = m_tasks.at(index, &ok);
            if (ok)
            {
                Task::List tasks;
                tasks.append(task);
                TaskDrag* drag = new TaskDrag(tasks, this);
                drag->setPixmap(task->pixmap());
                drag->dragMove();
            }
        }
    }

    QPopupMenu::mouseMoveEvent(e);
}
Ejemplo n.º 2
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);
    }
}