Beispiel #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;
}
bool UserConfig::processEvent(Event *e)
{
    switch (e->type()){
    case eEventGroup:{
        EventGroup *ev = static_cast<EventGroup*>(e);
        Group *group = ev->group();
        switch(ev->action()) {
        case EventGroup::eDeleted:
            if (group == m_group)
                close();
            return false;
        case EventGroup::eChanged:
            if (group == m_group)
                setTitle();
            return false;
        case EventGroup::eAdded:
            return false;
        }
        break;
    }
    case eEventContact: {
        EventContact *ec = static_cast<EventContact*>(e);
        Contact *contact = ec->contact();
        if (contact != m_contact)
            break;
        switch(ec->action()) {
            case EventContact::eCreated:
                if (m_nUpdates)
                    m_nUpdates--;
                btnUpdate->setEnabled(m_nUpdates == 0);
                setTitle();
            case EventContact::eDeleted:
                close();
                break;
            case EventContact::eChanged:
                if (m_nUpdates)
                    m_nUpdates--;
                btnUpdate->setEnabled(m_nUpdates == 0);
                setTitle();
                break;
            case EventContact::eFetchInfoFailed:
                if (m_nUpdates){
                    if (--m_nUpdates == 0){
                        btnUpdate->setEnabled(true);
                        setTitle();
                    }
                }
                break;
            default:
                break;
        }
        break;
    }
    case eEventCommandRemove: {
        EventCommandRemove *ecr = static_cast<EventCommandRemove*>(e);
        removeCommand(ecr->id());
        return false;
    }
    case eEventLanguageChanged:
    case eEventPluginChanged:
    case eEventClientsChanged:
        fill();
        return false;
    default:
        break;
    }
    return false;
}