Esempio n. 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;
}
Esempio n. 2
0
bool BackgroundPlugin::processEvent(Event *e)
{
    if (e->type() == eEventPaintView){
        EventPaintView *ev = static_cast<EventPaintView*>(e);
        EventPaintView::PaintView *pv = ev->paintView();;
        if (!bgImage.isNull()){
            unsigned w = bgImage.width();
            unsigned h = bgImage.height();
            int x = pv->pos.x();
            int y = pv->pos.y();
            bool bTiled = false;
            unsigned pos = value("Position").toUInt();
            switch(pos){
            case ContactLeft:
                h = pv->height;
                bTiled = true;
                break;
            case ContactScale:
                h = pv->height;
                w = pv->win->width();
                bTiled = true;
                break;
            case WindowTop:
                break;
            case WindowBottom:
                y += (bgImage.height() - pv->win->height());
                break;
            case WindowCenter:
                y += (bgImage.height() - pv->win->height()) / 2;
                break;
            case WindowScale:
                w = pv->win->width();
                h = pv->win->height();
                break;
            }
            const QPixmap &bg = makeBackground(w, h);
            if (bTiled){
                for (int py = 0; py < pv->size.height(); py += bg.height()){
                    pv->p->drawPixmap(QPoint(0, py), bgScale, QRect(x, 0, w, h));
                }
            }else{
                pv->p->drawPixmap(QPoint(0, 0), bgScale, QRect(x, y, pv->size.width(), pv->size.height()));
                pv->isStatic = true;
            }
        }
        pv->margin = pv->isGroup ? value("MarginGroup").toUInt() : value("MarginContact").toUInt();
    }
    else if(e->type() == eEventPluginLoadConfig)
    {
        PropertyHubPtr hub = ProfileManager::instance()->getPropertyHub("_core");
        if(!hub.isNull())
            setPropertyHub(hub);
        redraw();
    }
    return false;
}
Esempio n. 3
0
bool ReplacePlugin::processEvent(SIM::Event *e)
{
    if(e->type() == eEventPluginLoadConfig)
    {
        PropertyHubPtr hub = ProfileManager::instance()->getPropertyHub("replace");
        if(!hub.isNull())
            setPropertyHub(hub);
    }
    return false;
}
Esempio n. 4
0
bool IconsPlugin::processEvent(Event *e)
{
    switch (e->type())
    {
    case eEventPluginLoadConfig:
    {
        PropertyHubPtr hub = ProfileManager::instance()->getPropertyHub("icon");
        if(!hub.isNull())
            setPropertyHub(hub);
        setIcons(false);
        break;
    }
    default:
        break;
    }
    return false;
}
Esempio n. 5
0
bool NetmonitorPlugin::processEvent(Event *e)
{
    if (e->type() == eEventCommandExec){
        EventCommandExec *ece = static_cast<EventCommandExec*>(e);
        CommandDef *cmd = ece->cmd();
        if (cmd->id == CmdNetMonitor){
            showMonitor();
            return true;
        }
    }
    else if(e->type() == eEventPluginLoadConfig)
    {
        PropertyHubPtr hub = ProfileManager::instance()->getPropertyHub("netmonitor");
        if(!hub.isNull())
            setPropertyHub(hub);
    }
    return false;
}
Esempio n. 6
0
bool SoundPlugin::processEvent(SIM::Event *e)
{
    switch (e->type())
    {
    case eEventLoginStart:
        {
            playSound(value("StartUp").toString());
            break;
        }
    case eEventPluginLoadConfig:
        {
            PropertyHubPtr hub = ProfileManager::instance()->getPropertyHub("sound");
            if(!hub.isNull())
                setPropertyHub(hub);
            if(!value("StartUp").isValid())
                setValue("StartUp", "sounds/startup.ogg");
            if(!value("MessageSent").isValid())
                setValue("MessageSent", "sounds/msgsent.ogg");
            if(!value("FileDone").isValid())
                setValue("FileDone", "sounds/filedone.ogg");
            break;
        }
    case eEventContact:
        {
            EventContact *ec = static_cast<EventContact*>(e);
            if(ec->action() != EventContact::eOnline)
                break;
            Contact *contact = ec->contact();
            bool disable = contact->getUserData()->root()->value("sound/Disable").toBool();
            QString alert = contact->getUserData()->root()->value("sound/Alert").toString();
            if(alert.isEmpty())
                alert = getContacts()->userdata()->value("sound/Alert").toString();
            if (!alert.isEmpty() && !disable)
                EventPlaySound(alert).process();
            break;
        }
    case eEventMessageSent:
        {
            EventMessage *em = static_cast<EventMessage*>(e);
            Message *msg = em->msg();
            QString err = msg->getError();
            if (!err.isEmpty())
                return false;
            QString sound;
            if (msg->type() == MessageFile)
                sound = value("FileDone").toString();
            else if ((msg->getFlags() & MESSAGE_NOHISTORY) == 0)
            {
                if ((msg->getFlags() & MESSAGE_MULTIPLY) && ((msg->getFlags() & MESSAGE_LAST) == 0))
                    return false;
                sound = value("MessageSent").toString();
            }
            if (!sound.isEmpty())
                EventPlaySound(sound).process();
            break;
        }
    case eEventMessageReceived:
        {
            EventMessage *em = static_cast<EventMessage*>(e);
            Message *msg = em->msg();
            if(msg->type() == MessageStatus)
                return false;
            Contact *contact = getContacts()->contact(msg->contact());
            bool nosound, disable;
            if(contact)
            {
                nosound = contact->getUserData()->root()->value("sound/NoSoundIfActive").toBool();
                disable = contact->getUserData()->root()->value("sound/Disable").toBool();
            }
            else
            {
                nosound = getContacts()->userdata()->value("sound/NoSoundIfActive").toBool();
                disable = getContacts()->userdata()->value("sound/Disable").toBool();
            }
            if(!disable && nosound)
            {
                EventActiveContact e;
                e.process();
                if (e.contactID() == contact->id())
                    disable = true;
            }
            if(!disable)
            {
                QString sound = messageSound(msg->baseType(), contact->id());
                playSound(sound);
            }
            break;
        }
    case eEventPlaySound:
        {
            EventPlaySound *s = static_cast<EventPlaySound*>(e);
            playSound(s->sound());
            return true;
        }
    default:
        break;
    }
    return false;
}
Esempio n. 7
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;
}