示例#1
0
bool ShortcutsPlugin::processEvent(Event *e)
{
#ifdef WIN32
    if (e->type() == eEventInit){
        init();
        return false;
    } else
#endif
    if (e->type() == eEventCommandCreate){
        EventCommandCreate *ecc = static_cast<EventCommandCreate*>(e);
        CommandDef *cmd = ecc->cmd();
        if ((cmd->menu_id == MenuMain) ||
                (cmd->menu_id == MenuContact) ||
                (cmd->menu_id == MenuStatus) ||
                (cmd->menu_id == MenuGroup)){
            applyKey(cmd);
        }
    } else
    if (e->type() == eEventCommandRemove){
        EventCommandRemove *ecr = static_cast<EventCommandRemove*>(e);
        unsigned long id = ecr->id();
        MAP_STR::iterator it_key = oldKeys.find(id);
        if (it_key != oldKeys.end())
            oldKeys.erase(it_key);
        MAP_BOOL::iterator it_global = oldGlobals.find(id);
        if (it_global != oldGlobals.end())
            oldGlobals.erase(it_global);
        if (globalKeys){
            list<GlobalKey*>::iterator it;
            for (it = globalKeys->begin(); it != globalKeys->end();){
                if ((*it)->id() != id){
                    ++it;
                    continue;
                }
                delete *it;
                globalKeys->erase(it);
                it = globalKeys->begin();
            }
        }
        for (MAP_CMDS::iterator it = mouseCmds.begin(); it != mouseCmds.end();){
            if (it->second.id != id){
                ++it;
                continue;
            }
            mouseCmds.erase(it);
            it = mouseCmds.begin();
        }
        if (mouseCmds.size() == 0)
            qApp->removeEventFilter(this);
    }
	if(e->type() == eEventPluginLoadConfig)
	{
        PropertyHubPtr hub = ProfileManager::instance()->getPropertyHub("shortcut");
        if(!hub.isNull())
            setPropertyHub(hub);
	}
    return false;
}
示例#2
0
bool DockPlugin::processEvent(Event *e)
{
    switch (e->type()){
    case eEventInit:
        init();
        break;
    case eEventQuit:
        if (m_dock){
            delete m_dock;
            m_dock = NULL;
        }
        break;
    case eEventRaiseWindow: {
        EventRaiseWindow *w = static_cast<EventRaiseWindow*>(e);
        if (w->widget() == getMainWindow()){
            if (m_dock == NULL)
                init();
            if (!getShowMain())
                return (void*)1;
        }
        break;
    }
    case eEventCommandCreate: {
        EventCommandCreate *ecc = static_cast<EventCommandCreate*>(e);
        CommandDef *def = ecc->cmd();
        if (def->menu_id == MenuMain){
            CommandDef d = *def;
            if (def->flags & COMMAND_IMPORTANT){
                if (d.menu_grp == 0)
                    d.menu_grp = 0x1001;
            }else{
                d.menu_grp = 0;
            }
            d.menu_id = DockMenu;
            d.bar_id  = 0;
            EventCommandCreate(&d).process();
        }
        break;
    }
    case eEventCheckCommandState: {
        EventCheckCommandState *ecs = static_cast<EventCheckCommandState*>(e);
        CommandDef *def = ecs->cmd();
        if (def->id == CmdToggle){
            def->flags &= ~COMMAND_CHECKED;
            def->text = isMainShow() ?
                        I18N_NOOP("Hide main window") :
                        I18N_NOOP("Show main window");
            return (void*)1;
        }
        break;
    }
    case eEventCommandExec: {
        EventCommandExec *ece = static_cast<EventCommandExec*>(e);
        CommandDef *def = ece->cmd();
        if (def->id == CmdToggle){
            QWidget *main = getMainWindow();
            if(!main)
                return false;
            if (isMainShow()){
                setShowMain(false);
                main->hide();
            }else{
                m_inactiveTime = 0;
                setShowMain(true);
                raiseWindow(main,getDesktop());
            }
            return (void*)1;
        }
        if (def->id == CmdCustomize){
            EventMenu(DockMenu, EventMenu::eCustomize).process();
            return (void*)1;
        }
        if (def->id == CmdQuit)
            m_bQuit = true;
        break;
    }
    default:
        break;
    }
    return false;
}
示例#3
0
bool DockPlugin::processEvent(Event *e)
{
    switch (e->type())
    {
    case eEventInit:
        init();
        break;
    case eEventQuit:
        if (m_dock){
            delete m_dock;
            m_dock = NULL;
        }
        break;
    case eEventRaiseWindow: 
    {
        EventRaiseWindow *w = static_cast<EventRaiseWindow*>(e);
        if (w->widget() == getMainWindow()){
            if (!m_dock)
                init();
            if (!value("ShowMain").toBool())
                return true;
        }
        break;
    }
    case eEventCommandCreate: 
    {
        EventCommandCreate *ecc = static_cast<EventCommandCreate*>(e);
        CommandDef *def = ecc->cmd();
        if (def->menu_id == MenuMain)
        {
            CommandDef d = *def;
            if (def->flags & COMMAND_IMPORTANT)
            {
                if (d.menu_grp == 0)
                    d.menu_grp = 0x1001;
            }
            else
                d.menu_grp = 0;
            d.menu_id = DockMenu;
            d.bar_id  = 0;
            EventCommandCreate(&d).process();
        }
        break;
    }
    case eEventCheckCommandState: 
    {
        EventCheckCommandState *ecs = static_cast<EventCheckCommandState*>(e);
        CommandDef *def = ecs->cmd();
        if (def->id == CmdToggle)
        {
            def->flags &= ~COMMAND_CHECKED;
            def->text = isMainShow() ?
                        I18N_NOOP("Hide main window") :
                        I18N_NOOP("Show main window");
            return true;
        }
        break;
    }
    case eEventCommandExec: 
    {
        EventCommandExec *ece = static_cast<EventCommandExec*>(e);
        CommandDef *def = ece->cmd();
        if (def->id == CmdToggle)
        {
            QWidget *main = getMainWindow();
            if(!main)
                return false;
            if (isMainShow())
            {
                setValue("ShowMain", false);
                main->hide();
            }
            else
            {
                m_inactiveTime = QDateTime();
                setValue("ShowMain", true);
                raiseWindow(main, value("Desktop").toUInt());
            }
            return true;
        }
        if (def->id == CmdCustomize){
            EventMenu(DockMenu, EventMenu::eCustomize).process();
            return true;
        }
        if (def->id == CmdQuit)
            m_bQuit = true;
        break;
    }
    case eEventPluginLoadConfig:
    {
        PropertyHubPtr hub = ProfileManager::instance()->getPropertyHub("dock");
        if(!hub.isNull())
            setPropertyHub(hub);
        break;
    }
    default:
        break;
    }
    return false;
}