void GxSliderEdit::myUpdateValue(double value, bool emitEvent) { mySpinner->SetValue(value); value = mySpinner->GetValue(); if(myValue != value && emitEvent) { EmitEvent(eChanged(), value); myFlags.Set(F_CHANGED); } mySpinner->SetValue(value); mySlider->SetValue(value); myValue = value; }
void GxSliderAbstract::myUpdateValue(double value, bool emitEvent) { bool snap = myFlags[F_SNAPPING]; double min = GxMin(myBegin, myEnd); double max = GxMax(myBegin, myEnd); if(snap && abs(myTickInterval) >= 0.001 && value > min && value < max) { value -= myBegin; value = floor(value/myTickInterval + 0.5) * myTickInterval; value += myBegin; } value = GxClamp(value, min, max); if(myValue != value && emitEvent) { EmitEvent(eChanged(), value); myFlags.Set(F_CHANGED); } myValue = value; if(myVarPtr) *myVarPtr = value; }
void *SoundPlugin::processEvent(Event *e) { if (e->type() == EventSoundChanged){ Command cmd; cmd->id = CmdSoundDisable; SoundUserData *data = (SoundUserData*)(getContacts()->getUserData(user_data_id)); if (!data->Disable.bValue) cmd->flags |= COMMAND_CHECKED; m_bChanged = true; Event e(EventCommandChecked, cmd); e.process(); m_bChanged = false; return NULL; } if (e->type() == EventCheckState){ CommandDef *cmd = (CommandDef*)(e->param()); if (cmd->id == CmdSoundDisable){ cmd->flags &= ~COMMAND_CHECKED; SoundUserData *data = (SoundUserData*)(getContacts()->getUserData(user_data_id)); if (!data->Disable.bValue) cmd->flags |= COMMAND_CHECKED; return e->param(); } return NULL; } if (e->type() == EventCommandExec){ CommandDef *cmd = (CommandDef*)(e->param()); if (!m_bChanged && (cmd->id == CmdSoundDisable)){ SoundUserData *data = (SoundUserData*)(getContacts()->getUserData(user_data_id)); data->Disable.bValue = !data->Disable.bValue; Event eChanged(EventSoundChanged); eChanged.process(); return e->param(); } return NULL; } if (e->type() == EventContactOnline){ Contact *contact = (Contact*)(e->param()); SoundUserData *data = (SoundUserData*)(contact->getUserData(user_data_id)); if (data && data->Alert.ptr && *data->Alert.ptr && !data->Disable.bValue){ Event eSound(EventPlaySound, data->Alert.ptr); eSound.process(); } return NULL; } if (e->type() == EventMessageSent){ Message *msg = (Message*)(e->param()); const char *err = msg->getError(); if (err && *err) return NULL; const char *sound = NULL; if (msg->type() == MessageFile){ sound = getFileDone(); }else if ((msg->getFlags() & MESSAGE_NOHISTORY) == 0){ if ((msg->getFlags() & MESSAGE_MULTIPLY) && ((msg->getFlags() & MESSAGE_LAST) == 0)) return NULL; sound = getMessageSent(); } if (sound && *sound){ Event eSound(EventPlaySound, (void*)sound); eSound.process(); } return NULL; } if (e->type() == EventMessageReceived){ Message *msg = (Message*)(e->param()); if (msg->type() == MessageStatus) return NULL; if (msg->getFlags() & MESSAGE_LIST) return NULL; Contact *contact = getContacts()->contact(msg->contact()); SoundUserData *data; if (contact){ data = (SoundUserData*)(contact->getUserData(user_data_id)); }else{ data = (SoundUserData*)(getContacts()->getUserData(user_data_id)); } bool bEnable = !data->Disable.bValue; if (bEnable && data->NoSoundIfActive.bValue){ Event e(EventActiveContact); if ((unsigned)(e.process()) == contact->id()) bEnable = false; } if (bEnable){ string sound = messageSound(msg->baseType(), data); if (!sound.empty()) playSound(sound.c_str()); } return NULL; } if (e->type() == EventPlaySound){ char *name = (char*)(e->param()); playSound(name); return e->param(); } return NULL; }
void *UserView::processEvent(Event *e) { switch (e->type()){ case EventInit: m_bInit = true; fill(); break; case EventContactOnline: if (m_bInit){ Contact *contact = (Contact*)(e->param()); bool bStart = blinks.empty(); list<BlinkCount>::iterator it; for (it = blinks.begin(); it != blinks.end(); ++it){ if ((*it).id == contact->id()) break; } if (it != blinks.end()){ (*it).count = BLINK_COUNT; return NULL; } BlinkCount bc; bc.id = contact->id(); bc.count = BLINK_COUNT; blinks.push_back(bc); if (bStart) blinkTimer->start(BLINK_TIMEOUT); return NULL; } break; case EventMessageDeleted: case EventMessageRead: case EventMessageReceived:{ Message *msg = (Message*)(e->param()); addContactForUpdate(msg->contact()); break; } case EventCommandExec:{ CommandDef *cmd = (CommandDef*)(e->param()); if (cmd->menu_id == MenuContact){ Contact *contact = getContacts()->contact((unsigned)(cmd->param)); if (contact){ if (cmd->id == CmdContactDelete){ QListViewItem *item = findContactItem(contact->id()); if (item){ ensureItemVisible(item); QRect rc = itemRect(item); QPoint p = viewport()->mapToGlobal(rc.topLeft()); rc = QRect(p.x(), p.y(), rc.width(), rc.height()); BalloonMsg::ask((void*)contact->id(), i18n("Delete \"%1\"?") .arg(contact->getName()), this, SLOT(deleteContact(void*)), NULL, &rc); } return e->param(); } if (cmd->id == CmdContactRename){ QListViewItem *item = findContactItem(contact->id()); if (item){ setCurrentItem(item); renameContact(); } return e->param(); } if (cmd->id == CmdShowAlways){ ListUserData *data = (ListUserData*)(contact->getUserData(CorePlugin::m_plugin->list_data_id, true)); if (data){ bool bShow = false; if (cmd->flags & COMMAND_CHECKED) bShow = true; if ((data->ShowAlways != 0) != bShow){ data->ShowAlways = bShow; Event e(EventContactChanged, contact); e.process(); } } return e->param(); } if (cmd->id == CmdClose){ UserWnd *wnd = NULL; QWidgetList *list = QApplication::topLevelWidgets(); QWidgetListIt it(*list); QWidget * w; while ((w = it.current()) != NULL){ if (w->inherits("Container")){ Container *c = static_cast<Container*>(w); wnd = c->wnd((unsigned)(cmd->param)); if (wnd) break; } ++it; } delete list; if (wnd){ delete wnd; return e->param(); } } if (cmd->id > CmdSendMessage){ Command c; c->id = cmd->id - CmdSendMessage; c->menu_id = MenuMessage; c->param = (void*)(contact->id()); Event eCmd(EventCommandExec, c); if (eCmd.process()) return e->param(); } } } if (cmd->menu_id == MenuContactGroup){ Contact *contact = getContacts()->contact((unsigned)(cmd->param)); if (contact){ Group *grp = getContacts()->group(cmd->id - CmdContactGroup); if (grp && (grp->id() != contact->getGroup())){ contact->setGroup(grp->id()); Event eChanged(EventContactChanged, contact); eChanged.process(); return e->param(); } } } if (cmd->menu_id == MenuContainer){ Contact *contact = getContacts()->contact((unsigned)(cmd->param)); if (contact){ Container *from = NULL; Container *to = NULL; QWidgetList *list = QApplication::topLevelWidgets(); QWidgetListIt it(*list); QWidget * w; unsigned max_id = 0; while ((w = it.current()) != NULL){ if (w->inherits("Container")){ Container *c = static_cast<Container*>(w); if (c->getId() == cmd->id) to = c; if (c->wnd(contact->id())) from = c; if (!(c->getId() & CONTAINER_GRP)){ if (max_id < c->getId()) max_id = c->getId(); } } ++it; } if (from && to && (from == to)) return e->param(); UserWnd *userWnd = NULL; if (from){ userWnd = from->wnd(contact->id()); from->removeUserWnd(userWnd); } if (userWnd == NULL) userWnd = new UserWnd(contact->id(), NULL, true); if (to == NULL) to = new Container(max_id + 1); to->addUserWnd(userWnd); to->setNoSwitch(); raiseWindow(to); } return e->param(); } if (cmd->id == CmdOnline){ CorePlugin::m_plugin->setShowOnLine((cmd->flags & COMMAND_CHECKED) != 0); m_bShowOnline = (cmd->flags & COMMAND_CHECKED); if (cmd->menu_id){ CommandDef c = *cmd; c.bar_id = ToolBarMain; c.bar_grp = 0x4000; Event eCmd(EventCommandChange, &c); eCmd.process(); } fill(); } if (cmd->id == CmdGrpOff) setGroupMode(0); if (cmd->id == CmdGrpMode1) setGroupMode(1); if (cmd->id == CmdGrpMode2) setGroupMode(2); if (cmd->id == CmdGrpCreate){ if (CorePlugin::m_plugin->getGroupMode()){ Group *g = getContacts()->group(0, true); drawUpdates(); QListViewItem *item = findGroupItem(g->id()); if (item){ setCurrentItem(item); QTimer::singleShot(0, this, SLOT(renameGroup())); } } return e->param(); } if (cmd->id == CmdGrpRename){ QListViewItem *item = findGroupItem((unsigned)(cmd->param)); if (item){ setCurrentItem(item); renameGroup(); } return e->param(); } if (cmd->id == CmdGrpUp){ unsigned grp_id = (unsigned)(cmd->param); getContacts()->moveGroup(grp_id, true); QListViewItem *item = findGroupItem(grp_id); if (item){ ensureItemVisible(item); setCurrentItem(item); } return e->param(); } if (cmd->id == CmdGrpDown){ unsigned grp_id = (unsigned)(cmd->param); getContacts()->moveGroup(grp_id, false); QListViewItem *item = findGroupItem(grp_id); if (item){ ensureItemVisible(item); setCurrentItem(item); } return e->param(); } if (cmd->id == CmdGrpDelete){ unsigned grp_id = (unsigned)(cmd->param); QListViewItem *item = findGroupItem(grp_id); Group *g = getContacts()->group(grp_id); if (item && g){ ensureItemVisible(item); QRect rc = itemRect(item); QPoint p = viewport()->mapToGlobal(rc.topLeft()); rc = QRect(p.x(), p.y(), rc.width(), rc.height()); BalloonMsg::ask((void*)grp_id, i18n("Delete \"%1\"?") .arg(g->getName()), this, SLOT(deleteGroup(void*)), NULL, &rc); }