void WSliderComposed::setup(QDomNode node, const SkinContext& context) { // Setup pixmaps unsetPixmaps(); if (context.hasNode(node, "Slider")) { PixmapSource sourceSlider = context.getPixmapSource(context.selectNode(node, "Slider")); setSliderPixmap(sourceSlider); } PixmapSource sourceHandle = context.getPixmapSource(context.selectNode(node, "Handle")); bool h = context.selectBool(node, "Horizontal", false); setHandlePixmap(h, sourceHandle); if (context.hasNode(node, "EventWhileDrag")) { if (context.selectString(node, "EventWhileDrag").contains("no")) { m_bEventWhileDrag = false; } } if (!m_connections.isEmpty()) { ControlParameterWidgetConnection* defaultConnection = m_connections.at(0); if (defaultConnection) { if (defaultConnection->getEmitOption() & ControlParameterWidgetConnection::EMIT_DEFAULT) { // ON_PRESS means here value change on mouse move during press defaultConnection->setEmitOption( ControlParameterWidgetConnection::EMIT_ON_PRESS_AND_RELEASE); } } } }
void WPushButton::setup(QDomNode node, const SkinContext& context) { // Number of states int iNumStates = context.selectInt(node, "NumberStates"); setStates(iNumStates); // Set background pixmap if available if (context.hasNode(node, "BackPath")) { QString mode_str = context.selectAttributeString( context.selectElement(node, "BackPath"), "scalemode", "TILE"); setPixmapBackground(context.getSkinPath(context.selectString(node, "BackPath")), Paintable::DrawModeFromString(mode_str)); } // Load pixmaps for associated states QDomNode state = context.selectNode(node, "State"); while (!state.isNull()) { if (state.isElement() && state.nodeName() == "State") { int iState = context.selectInt(state, "Number"); if (iState < m_iNoStates) { if (context.hasNode(state, "Pressed")) { setPixmap(iState, true, context.getSkinPath(context.selectString(state, "Pressed"))); } if (context.hasNode(state, "Unpressed")) { setPixmap(iState, false, context.getSkinPath(context.selectString(state, "Unpressed"))); } m_text.replace(iState, context.selectString(state, "Text")); } } state = state.nextSibling(); } ControlParameterWidgetConnection* leftConnection = NULL; if (m_leftConnections.isEmpty()) { if (!m_connections.isEmpty()) { // If no left connection is set, the this is the left connection leftConnection = m_connections.at(0); } } else { leftConnection = m_leftConnections.at(0); } if (leftConnection) { bool leftClickForcePush = context.selectBool(node, "LeftClickIsPushButton", false); m_leftButtonMode = ControlPushButton::PUSH; if (!leftClickForcePush) { const ConfigKey& configKey = leftConnection->getKey(); ControlPushButton* p = dynamic_cast<ControlPushButton*>( ControlObject::getControl(configKey)); if (p) { m_leftButtonMode = p->getButtonMode(); } } if (leftConnection->getEmitOption() & ControlParameterWidgetConnection::EMIT_DEFAULT) { switch (m_leftButtonMode) { case ControlPushButton::PUSH: case ControlPushButton::LONGPRESSLATCHING: case ControlPushButton::POWERWINDOW: leftConnection->setEmitOption( ControlParameterWidgetConnection::EMIT_ON_PRESS_AND_RELEASE); break; default: leftConnection->setEmitOption( ControlParameterWidgetConnection::EMIT_ON_PRESS); break; } } if (leftConnection->getDirectionOption() & ControlParameterWidgetConnection::DIR_DEFAULT) { if (m_pDisplayConnection == leftConnection) { leftConnection->setDirectionOption(ControlParameterWidgetConnection::DIR_FROM_AND_TO_WIDGET); } else { leftConnection->setDirectionOption(ControlParameterWidgetConnection::DIR_FROM_WIDGET); if (m_pDisplayConnection->getDirectionOption() & ControlParameterWidgetConnection::DIR_DEFAULT) { m_pDisplayConnection->setDirectionOption(ControlParameterWidgetConnection::DIR_TO_WIDGET); } } } } if (!m_rightConnections.isEmpty()) { ControlParameterWidgetConnection* rightConnection = m_rightConnections.at(0); bool rightClickForcePush = context.selectBool(node, "RightClickIsPushButton", false); m_rightButtonMode = ControlPushButton::PUSH; if (!rightClickForcePush) { const ConfigKey configKey = rightConnection->getKey(); ControlPushButton* p = dynamic_cast<ControlPushButton*>( ControlObject::getControl(configKey)); if (p) { m_rightButtonMode = p->getButtonMode(); if (m_rightButtonMode != ControlPushButton::PUSH) { qWarning() << "WPushButton::setup: Connecting a Pushbutton not in PUSH mode is not implemented\n" << "Please set <RightClickIsPushButton>true</RightClickIsPushButton>"; } } } if (rightConnection->getEmitOption() & ControlParameterWidgetConnection::EMIT_DEFAULT) { switch (m_rightButtonMode) { case ControlPushButton::PUSH: case ControlPushButton::LONGPRESSLATCHING: case ControlPushButton::POWERWINDOW: leftConnection->setEmitOption( ControlParameterWidgetConnection::EMIT_ON_PRESS_AND_RELEASE); break; default: leftConnection->setEmitOption( ControlParameterWidgetConnection::EMIT_ON_PRESS); break; } } if (rightConnection->getDirectionOption() & ControlParameterWidgetConnection::DIR_DEFAULT) { rightConnection->setDirectionOption(ControlParameterWidgetConnection::DIR_FROM_WIDGET); } } }