void PanelDelegate::on_modelChanged(
        iscore::MaybeDocument oldm,
        iscore::MaybeDocument newm)
{
    disconnect(m_con);
    if(!newm)
    {
        setEmptyView();
        return;
    }

    auto netplug = newm->findPlugin<NetworkDocumentPlugin>();

    if(netplug)
    {
        if(!netplug->policy())
            return;

        m_con = connect(netplug, &NetworkDocumentPlugin::sessionChanged,
                this, [=] () {
            auto currentManager = netplug->groupManager();
            auto currentSession = netplug->policy()->session();

            if(currentManager)
            {
                setView(currentManager, currentSession);
            }
            else
            {
                setEmptyView();
            }
        });

        auto currentManager = netplug->groupManager();
        auto currentSession = netplug->policy()->session();
        if(currentManager)
        {
            setView(currentManager, currentSession);
        }
        else
        {
            setEmptyView();
        }
    }


}
Esempio n. 2
0
bool WindowList::eventFilter(QObject *object, QEvent *event)
{
    if (event->type() == QEvent::ContextMenu) {
        KMenu *menu = qobject_cast<KMenu*>(object);

        if (menu && menu->activeAction() && menu->activeAction()->data().type() == QVariant::ULongLong) {
            QContextMenuEvent *cmEvent = static_cast<QContextMenuEvent *>(event);
            QList<QAction*> actionList;
            TaskManager::TaskItem item(this, TaskManager::TaskManager::self()->findTask((WId)menu->activeAction()->data().toULongLong()));
            TaskManager::GroupManager groupManager(this);
            TaskManager::BasicMenu taskMenu(NULL, &item, &groupManager, actionList);
            if (taskMenu.exec(cmEvent->globalPos())) {
                m_listMenu->hide();
            }
            return true;
        }
    } else if (event->type() == QEvent::MouseButtonPress) {
        QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event);

        if (mouseEvent->button() != Qt::LeftButton) {
            return false;
        }

        KMenu *menu = static_cast<KMenu*>(object);

        if (menu && menu->activeAction() && menu->activeAction()->data().type() == QVariant::ULongLong) {
            m_dragStartPosition = mouseEvent->pos();
        }
    } else if (event->type() == QEvent::MouseMove) {
        QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event);

        if (!(mouseEvent->buttons() & Qt::LeftButton) || (mouseEvent->pos() - m_dragStartPosition).manhattanLength() < QApplication::startDragDistance()) {
            return false;
        }

        KMenu *menu = static_cast<KMenu*>(object);

        if (menu && menu->activeAction() && menu->activeAction()->data().type() == QVariant::ULongLong) {
            QDrag *drag = new QDrag(menu);
            QMimeData *mimeData = new QMimeData;
            QByteArray data;
            WId window = (WId)menu->activeAction()->data().toULongLong();

            data.resize(sizeof(WId));

            memcpy(data.data(), &window, sizeof(WId));

            mimeData->setData("windowsystem/winid", data);

            drag->setMimeData(mimeData);
            drag->setPixmap(menu->activeAction()->icon().pixmap(32, 32));

            m_listMenu->hide();

            drag->exec();
            return true;
        }
    }

    return QObject::eventFilter(object, event);
}
Esempio n. 3
0
bool Backend::anyTaskNeedsAttention() const
{
    return groupManager()->rootGroup()->demandsAttention();
}