diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/controllers/controllerlearningeventfilter.cpp | 2 | ||||
-rw-r--r-- | src/controllers/controllerlearningeventfilter.h | 14 | ||||
-rw-r--r-- | src/skin/legacyskinparser.cpp | 90 | ||||
-rw-r--r-- | src/widget/controlwidgetconnection.cpp | 36 | ||||
-rw-r--r-- | src/widget/controlwidgetconnection.h | 99 | ||||
-rw-r--r-- | src/widget/wbasewidget.cpp | 107 | ||||
-rw-r--r-- | src/widget/wbasewidget.h | 32 | ||||
-rw-r--r-- | src/widget/wpushbutton.cpp | 183 | ||||
-rw-r--r-- | src/widget/wpushbutton.h | 6 | ||||
-rw-r--r-- | src/widget/wslidercomposed.cpp | 8 | ||||
-rw-r--r-- | src/widget/wslidercomposed.h | 3 |
11 files changed, 265 insertions, 315 deletions
diff --git a/src/controllers/controllerlearningeventfilter.cpp b/src/controllers/controllerlearningeventfilter.cpp index 97b62995da..df389c9363 100644 --- a/src/controllers/controllerlearningeventfilter.cpp +++ b/src/controllers/controllerlearningeventfilter.cpp @@ -87,7 +87,7 @@ bool ControllerLearningEventFilter::eventFilter(QObject* pObject, QEvent* pEvent void ControllerLearningEventFilter::addWidgetClickInfo( QWidget* pWidget, Qt::MouseButton buttonState, ControlObject* pControl, - ControlWidgetConnection::EmitOption emitOption) { + ControlParameterWidgetConnection::EmitOption emitOption) { ControlInfo& info = m_widgetControlInfo[pWidget]; if (buttonState == Qt::LeftButton) { diff --git a/src/controllers/controllerlearningeventfilter.h b/src/controllers/controllerlearningeventfilter.h index 735de0c23f..2517b1f3e9 100644 --- a/src/controllers/controllerlearningeventfilter.h +++ b/src/controllers/controllerlearningeventfilter.h @@ -10,19 +10,19 @@ struct ControlInfo { ControlInfo() : clickControl(NULL), - emitOption(ControlWidgetConnection::EMIT_ON_PRESS_AND_RELEASE), + emitOption(ControlParameterWidgetConnection::EMIT_ON_PRESS_AND_RELEASE), leftClickControl(NULL), - leftEmitOption(ControlWidgetConnection::EMIT_ON_PRESS_AND_RELEASE), + leftEmitOption(ControlParameterWidgetConnection::EMIT_ON_PRESS_AND_RELEASE), rightClickControl(NULL), - rightEmitOption(ControlWidgetConnection::EMIT_ON_PRESS_AND_RELEASE) { + rightEmitOption(ControlParameterWidgetConnection::EMIT_ON_PRESS_AND_RELEASE) { } ControlObject* clickControl; - ControlWidgetConnection::EmitOption emitOption; + ControlParameterWidgetConnection::EmitOption emitOption; ControlObject* leftClickControl; - ControlWidgetConnection::EmitOption leftEmitOption; + ControlParameterWidgetConnection::EmitOption leftEmitOption; ControlObject* rightClickControl; - ControlWidgetConnection::EmitOption rightEmitOption; + ControlParameterWidgetConnection::EmitOption rightEmitOption; }; class ControllerLearningEventFilter : public QObject { @@ -35,7 +35,7 @@ class ControllerLearningEventFilter : public QObject { void addWidgetClickInfo(QWidget* pWidget, Qt::MouseButton buttonState, ControlObject* pControl, - ControlWidgetConnection::EmitOption emitOption); + ControlParameterWidgetConnection::EmitOption emitOption); public slots: void startListening(); diff --git a/src/skin/legacyskinparser.cpp b/src/skin/legacyskinparser.cpp index 104ecc7ff3..ec211bec36 100644 --- a/src/skin/legacyskinparser.cpp +++ b/src/skin/legacyskinparser.cpp @@ -454,10 +454,11 @@ QList<QWidget*> LegacySkinParser::parseNode(QDomElement node) { QWidget* LegacySkinParser::parseSplitter(QDomElement node) { WSplitter* pSplitter = new WSplitter(m_pParent); + setupConnections(node, pSplitter); setupBaseWidget(node, pSplitter); setupWidget(node, pSplitter); pSplitter->setup(node, *m_pContext); - setupConnections(node, pSplitter); + pSplitter->Init(); QDomNode childrenNode = m_pContext->selectNode(node, "Children"); QWidget* pOldParent = m_pParent; @@ -510,10 +511,11 @@ QWidget* LegacySkinParser::parseSplitter(QDomElement node) { QWidget* LegacySkinParser::parseWidgetGroup(QDomElement node) { WWidgetGroup* pGroup = new WWidgetGroup(m_pParent); + setupConnections(node, pGroup); setupBaseWidget(node, pGroup); setupWidget(node, pGroup); pGroup->setup(node, *m_pContext); - setupConnections(node, pGroup); + pGroup->Init(); QDomNode childrenNode = m_pContext->selectNode(node, "Children"); @@ -553,9 +555,11 @@ QWidget* LegacySkinParser::parseWidgetStack(QDomElement node) { WWidgetStack* pStack = new WWidgetStack(m_pParent, pNextControl, pPrevControl); pStack->setObjectName("WidgetStack"); pStack->setContentsMargins(0, 0, 0, 0); + setupConnections(node, pStack); setupBaseWidget(node, pStack); setupWidget(node, pStack); - setupConnections(node, pStack); + pStack->Init(); + if (createdNext && pNextControl) { pNextControl->setParent(pStack); @@ -669,13 +673,14 @@ QWidget* LegacySkinParser::parseStandardWidget(QDomElement element, if (timerListener) { WaveformWidgetFactory::instance()->addTimerListener(pWidget); } + setupConnections(element, pWidget); setupBaseWidget(element, pWidget); setupWidget(element, pWidget); pWidget->setup(element, *m_pContext); - setupConnections(element, pWidget); pWidget->installEventFilter(m_pKeyboard); pWidget->installEventFilter( m_pControllerManager->getControllerLearningEventFilter()); + pWidget->Init(); return pWidget; } @@ -693,12 +698,13 @@ void LegacySkinParser::setupLabelWidget(QDomElement element, WLabel* pLabel) { // set before the palette is set then the custom palette will not take // effect which breaks color scheme support. pLabel->setup(element, *m_pContext); + setupConnections(element, pLabel); setupBaseWidget(element, pLabel); setupWidget(element, pLabel); - setupConnections(element, pLabel); pLabel->installEventFilter(m_pKeyboard); pLabel->installEventFilter( m_pControllerManager->getControllerLearningEventFilter()); + pLabel->Init(); } QWidget* LegacySkinParser::parseOverview(QDomElement node) { @@ -724,12 +730,13 @@ QWidget* LegacySkinParser::parseOverview(QDomElement node) { connect(overviewWidget, SIGNAL(trackDropped(QString, QString)), m_pPlayerManager, SLOT(slotLoadToPlayer(QString, QString))); + setupConnections(node, overviewWidget); setupBaseWidget(node, overviewWidget); setupWidget(node, overviewWidget); overviewWidget->setup(node, *m_pContext); - setupConnections(node, overviewWidget); overviewWidget->installEventFilter(m_pKeyboard); overviewWidget->installEventFilter(m_pControllerManager->getControllerLearningEventFilter()); + overviewWidget->Init(); // Connect the player's load and unload signals to the overview widget. connect(pPlayer, SIGNAL(loadTrack(TrackPointer)), @@ -767,8 +774,10 @@ QWidget* LegacySkinParser::parseVisual(QDomElement node) { viewer->installEventFilter(m_pKeyboard); viewer->installEventFilter(m_pControllerManager->getControllerLearningEventFilter()); + setupConnections(node, viewer); setupBaseWidget(node, viewer); setupWidget(node, viewer); + viewer->Init(); // connect display with loading/unloading of tracks QObject::connect(pPlayer, SIGNAL(newTrackLoaded(TrackPointer)), @@ -776,8 +785,6 @@ QWidget* LegacySkinParser::parseVisual(QDomElement node) { QObject::connect(pPlayer, SIGNAL(unloadingTrack(TrackPointer)), viewer, SLOT(onTrackUnloaded(TrackPointer))); - setupConnections(node, viewer); - connect(viewer, SIGNAL(trackDropped(QString, QString)), m_pPlayerManager, SLOT(slotLoadToPlayer(QString, QString))); @@ -886,6 +893,7 @@ QWidget* LegacySkinParser::parseSpinny(QDomElement node) { dummy->setText(tr("No OpenGL\nsupport.")); return dummy; } + setupConnections(node, spinny); setupBaseWidget(node, spinny); setupWidget(node, spinny); @@ -894,9 +902,9 @@ QWidget* LegacySkinParser::parseSpinny(QDomElement node) { m_pPlayerManager, SLOT(slotLoadToPlayer(QString, QString))); spinny->setup(node, *m_pContext, pSafeChannelStr); - setupConnections(node, spinny); spinny->installEventFilter(m_pKeyboard); spinny->installEventFilter(m_pControllerManager->getControllerLearningEventFilter()); + spinny->Init(); return spinny; } @@ -1471,8 +1479,7 @@ void LegacySkinParser::setupConnections(QDomNode node, WBaseWidget* pWidget) { // For each connection QDomNode con = m_pContext->selectNode(node, "Connection"); - ControlWidgetConnection* pLastLeftOrNoButtonConnection = NULL; - ControlWidgetConnection* pLastRightButtonConnection = NULL; + ControlParameterWidgetConnection* pLastLeftOrNoButtonConnection = NULL; while (!con.isNull()) { // Check that the control exists @@ -1495,10 +1502,10 @@ void LegacySkinParser::setupConnections(QDomNode node, WBaseWidget* pWidget) { new ControlObjectSlave(control->getKey(), pWidget->toQWidget()); - ControlWidgetConnection* pConnection = + ControlWidgetPropertyConnection* pConnection = new ControlWidgetPropertyConnection(pWidget, pControlWidget, pTransformer, property); - pWidget->addConnection(pConnection); + pWidget->addPropertyConnection(pConnection); // If we created this control, bind it to the // ControlWidgetConnection so that it is deleted when the connection @@ -1510,51 +1517,66 @@ void LegacySkinParser::setupConnections(QDomNode node, WBaseWidget* pWidget) { bool nodeValue; Qt::MouseButton state = parseButtonState(con, *m_pContext); - int directionOption = pWidget->getDefaultDirectionOption(state); + bool directionOptionSet = false; + int directionOption = ControlParameterWidgetConnection::DIR_FROM_AND_TO_WIDGET; if(m_pContext->hasNodeSelectBool( con, "ConnectValueFromWidget", &nodeValue)) { if (nodeValue) { - directionOption = directionOption | ControlWidgetConnection::DIR_FROM_WIDGET; + directionOption = directionOption | ControlParameterWidgetConnection::DIR_FROM_WIDGET; } else { - directionOption = directionOption & ~ControlWidgetConnection::DIR_FROM_WIDGET; + directionOption = directionOption & ~ControlParameterWidgetConnection::DIR_FROM_WIDGET; } + directionOptionSet = true; } if(m_pContext->hasNodeSelectBool( con, "ConnectValueToWidget", &nodeValue)) { if (nodeValue) { - directionOption = directionOption | ControlWidgetConnection::DIR_TO_WIDGET; + directionOption = directionOption | ControlParameterWidgetConnection::DIR_TO_WIDGET; } else { - directionOption = directionOption & ~ControlWidgetConnection::DIR_TO_WIDGET; + directionOption = directionOption & ~ControlParameterWidgetConnection::DIR_TO_WIDGET; } + directionOptionSet = true; } - ControlWidgetConnection::EmitOption emitOption = - pWidget->getDefaultEmitOption(state); - if (m_pContext->hasNodeSelectBool( + if (!directionOptionSet) { + // default: + // no direction option is explicite set + // Set default flag to allow the widget to change this during setup + directionOption |= ControlParameterWidgetConnection::DIR_DEFAULT; + } + + int emitOption = + ControlParameterWidgetConnection::EMIT_ON_PRESS; + if(m_pContext->hasNodeSelectBool( con, "EmitOnDownPress", &nodeValue)) { if (nodeValue) { - emitOption = ControlWidgetConnection::EMIT_ON_PRESS; + emitOption = ControlParameterWidgetConnection::EMIT_ON_PRESS; } else { - emitOption = ControlWidgetConnection::EMIT_ON_RELEASE; + emitOption = ControlParameterWidgetConnection::EMIT_ON_RELEASE; } } else if(m_pContext->hasNodeSelectBool( con, "EmitOnPressAndRelease", &nodeValue)) { if (nodeValue) { - emitOption = ControlWidgetConnection::EMIT_ON_PRESS_AND_RELEASE; + emitOption = ControlParameterWidgetConnection::EMIT_ON_PRESS_AND_RELEASE; } else { qWarning() << "LegacySkinParser::setupConnections(): EmitOnPressAndRelease must not set false"; } + } else { + // default: + // no emit option is set + // Allow to change the emitOption from Widget + emitOption |= ControlParameterWidgetConnection::EMIT_DEFAULT; } // Connect control proxy to widget. Parented to pWidget so it is not // leaked. ControlObjectSlave* pControlWidget = new ControlObjectSlave( control->getKey(), pWidget->toQWidget()); - ControlWidgetConnection* pConnection = new ControlParameterWidgetConnection( + ControlParameterWidgetConnection* pConnection = new ControlParameterWidgetConnection( pWidget, pControlWidget, pTransformer, - static_cast<ControlWidgetConnection::DirectionOption>(directionOption), - emitOption); + static_cast<ControlParameterWidgetConnection::DirectionOption>(directionOption), + static_cast<ControlParameterWidgetConnection::EmitOption>(emitOption)); // If we created this control, bind it to the // ControlWidgetConnection so that it is deleted when the connection @@ -1566,21 +1588,18 @@ void LegacySkinParser::setupConnections(QDomNode node, WBaseWidget* pWidget) { switch (state) { case Qt::NoButton: pWidget->addConnection(pConnection); - if (directionOption & ControlWidgetConnection::DIR_TO_WIDGET) { + if (directionOption & ControlParameterWidgetConnection::DIR_TO_WIDGET) { pLastLeftOrNoButtonConnection = pConnection; } break; case Qt::LeftButton: pWidget->addLeftConnection(pConnection); - if (directionOption & ControlWidgetConnection::DIR_TO_WIDGET) { + if (directionOption & ControlParameterWidgetConnection::DIR_TO_WIDGET) { pLastLeftOrNoButtonConnection = pConnection; } break; case Qt::RightButton: pWidget->addRightConnection(pConnection); - if (directionOption & ControlWidgetConnection::DIR_TO_WIDGET) { - pLastRightButtonConnection = pConnection; - } break; default: break; @@ -1588,9 +1607,10 @@ void LegacySkinParser::setupConnections(QDomNode node, WBaseWidget* pWidget) { // We only add info for controls that this widget affects, not // controls that only affect the widget. - if (directionOption & ControlWidgetConnection::DIR_FROM_WIDGET) { + if (directionOption & ControlParameterWidgetConnection::DIR_FROM_WIDGET) { m_pControllerManager->getControllerLearningEventFilter() - ->addWidgetClickInfo(pWidget->toQWidget(), state, control, emitOption); + ->addWidgetClickInfo(pWidget->toQWidget(), state, control, + static_cast<ControlParameterWidgetConnection::EmitOption>(emitOption)); // Add keyboard shortcut info to tooltip string QString key = m_pContext->selectString(con, "ConfigKey"); @@ -1674,8 +1694,6 @@ void LegacySkinParser::setupConnections(QDomNode node, WBaseWidget* pWidget) { // display connection. if (pLastLeftOrNoButtonConnection != NULL) { pWidget->setDisplayConnection(pLastLeftOrNoButtonConnection); - } else if (pLastRightButtonConnection != NULL) { - pWidget->setDisplayConnection(pLastRightButtonConnection); } } diff --git a/src/widget/controlwidgetconnection.cpp b/src/widget/controlwidgetconnection.cpp index c51d88439f..39614a2b93 100644 --- a/src/widget/controlwidgetconnection.cpp +++ b/src/widget/controlwidgetconnection.cpp @@ -52,16 +52,17 @@ ControlParameterWidgetConnection::ControlParameterWidgetConnection(WBaseWidget* : ControlWidgetConnection(pBaseWidget, pControl, pTransformer), m_directionOption(directionOption), m_emitOption(emitOption) { - if (directionOption & DIR_TO_WIDGET) { - slotControlValueChanged(m_pControl->get()); - } } ControlParameterWidgetConnection::~ControlParameterWidgetConnection() { } +void ControlParameterWidgetConnection::Init() { + slotControlValueChanged(m_pControl->get()); +} + QString ControlParameterWidgetConnection::toDebugString() const { - const ConfigKey& key = m_pControl->getKey(); + const ConfigKey& key = getKey(); return QString("%1,%2 Parameter: %3 Direction: %4 Emit: %5") .arg(key.group, key.item, QString::number(m_pControl->getParameter()), @@ -84,19 +85,19 @@ void ControlParameterWidgetConnection::resetControl() { void ControlParameterWidgetConnection::setControlParameter(double v) { if (m_directionOption & DIR_FROM_WIDGET) { - m_pControl->setParameter(v); + ControlWidgetConnection::setControlParameter(v); } } void ControlParameterWidgetConnection::setControlParameterDown(double v) { if ((m_directionOption & DIR_FROM_WIDGET) && (m_emitOption & EMIT_ON_PRESS)) { - m_pControl->setParameter(v); + ControlWidgetConnection::setControlParameter(v); } } void ControlParameterWidgetConnection::setControlParameterUp(double v) { if ((m_directionOption & DIR_FROM_WIDGET) && (m_emitOption & EMIT_ON_RELEASE)) { - m_pControl->setParameter(v); + ControlWidgetConnection::setControlParameter(v); } } @@ -113,7 +114,7 @@ ControlWidgetPropertyConnection::~ControlWidgetPropertyConnection() { } QString ControlWidgetPropertyConnection::toDebugString() const { - const ConfigKey& key = m_pControl->getKey(); + const ConfigKey& key = getKey(); return QString("%1,%2 Parameter: %3 Property: %4 Value: %5").arg( key.group, key.item, QString::number(m_pControl->getParameter()), m_propertyName, m_pWidget->toQWidget()->property( @@ -129,22 +130,3 @@ void ControlWidgetPropertyConnection::slotControlValueChanged(double v) { << "to widget failed. Value:" << dParameter; } } - -void ControlWidgetPropertyConnection::resetControl() { - // Do nothing. -} - -void ControlWidgetPropertyConnection::setControlParameter(double v) { - // Do nothing. - Q_UNUSED(v); -} - -void ControlWidgetPropertyConnection::setControlParameterDown(double v) { - // Do nothing. - Q_UNUSED(v); -} - -void ControlWidgetPropertyConnection::setControlParameterUp(double v) { - // Do nothing. - Q_UNUSED(v); -} diff --git a/src/widget/controlwidgetconnection.h b/src/widget/controlwidgetconnection.h index cfa160646b..4ae74601c4 100644 --- a/src/widget/controlwidgetconnection.h +++ b/src/widget/controlwidgetconnection.h @@ -6,22 +6,55 @@ #include <QScopedPointer> #include <QByteArray> -class ControlObjectSlave; +#include "controlobjectslave.h" + class WBaseWidget; class ValueTransformer; class ControlWidgetConnection : public QObject { Q_OBJECT public: + // Takes ownership of pControl and pTransformer. + ControlWidgetConnection(WBaseWidget* pBaseWidget, + ControlObjectSlave* pControl, + ValueTransformer* pTransformer); + virtual ~ControlWidgetConnection(); + + double getControlParameter() const; + double getControlParameterForValue(double value) const; + + const ConfigKey& getKey() const { + return m_pControl->getKey(); + } + + virtual QString toDebugString() const = 0; + + protected slots: + virtual void slotControlValueChanged(double v) = 0; + + protected: + void setControlParameter(double v); + + WBaseWidget* m_pWidget; + QScopedPointer<ControlObjectSlave> m_pControl; + + private: + QScopedPointer<ValueTransformer> m_pValueTransformer; +}; + +class ControlParameterWidgetConnection : public ControlWidgetConnection { + Q_OBJECT + public: enum EmitOption { EMIT_NEVER = 0x00, EMIT_ON_PRESS = 0x01, EMIT_ON_RELEASE = 0x02, - EMIT_ON_PRESS_AND_RELEASE = 0x03 + EMIT_ON_PRESS_AND_RELEASE = 0x03, + EMIT_DEFAULT = 0x04 }; static QString emitOptionToString(EmitOption option) { - switch (option) { + switch (option & EMIT_ON_PRESS_AND_RELEASE) { case EMIT_NEVER: return "NEVER"; case EMIT_ON_PRESS: @@ -39,11 +72,12 @@ class ControlWidgetConnection : public QObject { DIR_NON = 0x00, DIR_FROM_WIDGET = 0x01, DIR_TO_WIDGET = 0x02, - DIR_FROM_AND_TO_WIDGET = 0x03 + DIR_FROM_AND_TO_WIDGET = 0x03, + DIR_DEFAULT = 0x04 }; static QString directionOptionToString(DirectionOption option) { - switch (option) { + switch (option & DIR_FROM_AND_TO_WIDGET) { case DIR_NON: return "NON"; case DIR_FROM_WIDGET: @@ -57,34 +91,6 @@ class ControlWidgetConnection : public QObject { } } - // Takes ownership of pControl and pTransformer. - ControlWidgetConnection(WBaseWidget* pBaseWidget, - ControlObjectSlave* pControl, - ValueTransformer* pTransformer); - virtual ~ControlWidgetConnection(); - - double getControlParameter() const; - void setControlParameter(double v); - double getControlParameterForValue(double value) const; - - virtual void resetControl() = 0; - virtual void setControlParameterDown(double v) = 0; - virtual void setControlParameterUp(double v) = 0; - - virtual QString toDebugString() const = 0; - - protected slots: - virtual void slotControlValueChanged(double v) = 0; - - protected: - WBaseWidget* m_pWidget; - QScopedPointer<ControlObjectSlave> m_pControl; - QScopedPointer<ValueTransformer> m_pValueTransformer; -}; - -class ControlParameterWidgetConnection : public ControlWidgetConnection { - Q_OBJECT - public: ControlParameterWidgetConnection(WBaseWidget* pBaseWidget, ControlObjectSlave* pControl, ValueTransformer* pTransformer, @@ -92,16 +98,23 @@ class ControlParameterWidgetConnection : public ControlWidgetConnection { EmitOption emitOption); virtual ~ControlParameterWidgetConnection(); + void Init(); + QString toDebugString() const; - protected: - virtual void resetControl(); - virtual void setControlParameter(double v); - virtual void setControlParameterDown(double v); - virtual void setControlParameterUp(double v); + int getDirectionOption() const { return m_directionOption; }; + int getEmitOption() const { return m_emitOption; }; + + void setDirectionOption(enum DirectionOption v) { m_directionOption = v; }; + void setEmitOption(enum EmitOption v) { m_emitOption = v; }; + + void resetControl(); + void setControlParameter(double v); + void setControlParameterDown(double v); + void setControlParameterUp(double v); private slots: - void slotControlValueChanged(double v); + virtual void slotControlValueChanged(double v); private: DirectionOption m_directionOption; @@ -119,14 +132,8 @@ class ControlWidgetPropertyConnection : public ControlWidgetConnection { QString toDebugString() const; - protected: - virtual void resetControl(); - virtual void setControlParameter(double v); - virtual void setControlParameterDown(double v); - virtual void setControlParameterUp(double v); - private slots: - void slotControlValueChanged(double v); + virtual void slotControlValueChanged(double v); private: QByteArray m_propertyName; diff --git a/src/widget/wbasewidget.cpp b/src/widget/wbasewidget.cpp index 585553e3e9..081863f47d 100644 --- a/src/widget/wbasewidget.cpp +++ b/src/widget/wbasewidget.cpp @@ -7,8 +7,8 @@ #include "util/debug.h" WBaseWidget::WBaseWidget(QWidget* pWidget) - : m_pWidget(pWidget), - m_pDisplayConnection(NULL) { + : m_pDisplayConnection(NULL), + m_pWidget(pWidget) { } WBaseWidget::~WBaseWidget() { @@ -22,45 +22,39 @@ WBaseWidget::~WBaseWidget() { while (!m_connections.isEmpty()) { delete m_connections.takeLast(); } + while (!m_propertyConnections.isEmpty()) { + delete m_propertyConnections.takeLast(); + } } -ControlWidgetConnection::EmitOption WBaseWidget::getDefaultEmitOption( - Qt::MouseButton state) { - Q_UNUSED(state); - return ControlWidgetConnection::EMIT_ON_PRESS; -} - -ControlWidgetConnection::DirectionOption WBaseWidget::getDefaultDirectionOption( - Qt::MouseButton state) { - Q_UNUSED(state); - return ControlWidgetConnection::DIR_FROM_AND_TO_WIDGET; +void WBaseWidget::Init() { + if (m_pDisplayConnection) { + m_pDisplayConnection->Init(); + } } - -void WBaseWidget::setDisplayConnection(ControlWidgetConnection* pConnection) { +void WBaseWidget::setDisplayConnection(ControlParameterWidgetConnection* pConnection) { //qDebug() << "WBaseWidget::setDisplayConnection()" << pConnection->toDebugString(); m_pDisplayConnection = pConnection; } -void WBaseWidget::addConnection(ControlWidgetConnection* pConnection) { +void WBaseWidget::addConnection(ControlParameterWidgetConnection* pConnection) { m_connections.append(pConnection); } -void WBaseWidget::addLeftConnection(ControlWidgetConnection* pConnection) { +void WBaseWidget::addLeftConnection(ControlParameterWidgetConnection* pConnection) { m_leftConnections.append(pConnection); } -void WBaseWidget::addRightConnection(ControlWidgetConnection* pConnection) { +void WBaseWidget::addRightConnection(ControlParameterWidgetConnection* pConnection) { m_rightConnections.append(pConnection); } +void WBaseWidget::addPropertyConnection(ControlWidgetPropertyConnection* pConnection) { + m_propertyConnections.append(pConnection); +} + double WBaseWidget::getControlParameter() const { - if (!m_leftConnections.isEmpty()) { - return m_leftConnections.at(0)->getControlParameter(); - } - if (!m_rightConnections.isEmpty()) { - return m_rightConnections.at(0)->getControlParameter(); - } if (!m_connections.isEmpty()) { return m_connections.at(0)->getControlParameter(); } @@ -81,9 +75,6 @@ double WBaseWidget::getControlParameterRight() const { if (!m_rightConnections.isEmpty()) { return m_rightConnections.at(0)->getControlParameter(); } - if (!m_connections.isEmpty()) { - return m_connections.at(0)->getControlParameter(); - } return 0.0; } @@ -95,85 +86,73 @@ double WBaseWidget::getControlParameterDisplay() const { } void WBaseWidget::resetControlParameter() { - foreach (ControlWidgetConnection* pControlConnection, m_leftConnections) { - pControlConnection->resetControl(); - } - foreach (ControlWidgetConnection* pControlConnection, m_rightConnections) { - pControlConnection->resetControl(); - } - foreach (ControlWidgetConnection* pControlConnection, m_connections) { + foreach (ControlParameterWidgetConnection* pControlConnection, m_connections) { pControlConnection->resetControl(); } } void WBaseWidget::setControlParameter(double v) { - foreach (ControlWidgetConnection* pControlConnection, m_leftConnections) { - pControlConnection->setControlParameter(v); - } - foreach (ControlWidgetConnection* pControlConnection, m_rightConnections) { - pControlConnection->setControlParameter(v); - } - foreach (ControlWidgetConnection* pControlConnection, m_connections) { + foreach (ControlParameterWidgetConnection* pControlConnection, m_connections) { pControlConnection->setControlParameter(v); } } void WBaseWidget::setControlParameterUp(double v) { - foreach (ControlWidgetConnection* pControlConnection, m_leftConnections) { + foreach (ControlParameterWidgetConnection* pControlConnection, m_leftConnections) { pControlConnection->setControlParameterUp(v); } - foreach (ControlWidgetConnection* pControlConnection, m_rightConnections) { + foreach (ControlParameterWidgetConnection* pControlConnection, m_rightConnections) { pControlConnection->setControlParameterUp(v); } - foreach (ControlWidgetConnection* pControlConnection, m_connections) { + foreach (ControlParameterWidgetConnection* pControlConnection, m_connections) { pControlConnection->setControlParameterUp(v); } } void WBaseWidget::setControlParameterDown(double v) { - foreach (ControlWidgetConnection* pControlConnection, m_leftConnections) { + foreach (ControlParameterWidgetConnection* pControlConnection, m_leftConnections) { pControlConnection->setControlParameterDown(v); } - foreach (ControlWidgetConnection* pControlConnection, m_rightConnections) { + foreach (ControlParameterWidgetConnection* pControlConnection, m_rightConnections) { pControlConnection->setControlParameterDown(v); } - foreach (ControlWidgetConnection* pControlConnection, m_connections) { + foreach (ControlParameterWidgetConnection* pControlConnection, m_connections) { pControlConnection->setControlParameterDown(v); } } void WBaseWidget::setControlParameterLeftDown(double v) { - foreach (ControlWidgetConnection* pControlConnection, m_leftConnections) { - pControlConnection->setControlParameterDown(v); - } - foreach (ControlWidgetConnection* pControlConnection, m_connections) { - pControlConnection->setControlParameterDown(v); + if (!m_leftConnections.isEmpty()) { + foreach (ControlParameterWidgetConnection* pControlConnection, m_leftConnections) { + pControlConnection->setControlParameterDown(v); + } + } else { + foreach (ControlParameterWidgetConnection* pControlConnection, m_connections) { + pControlConnection->setControlParameterDown(v); + } } } void WBaseWidget::setControlParameterLeftUp(double v) { - foreach (ControlWidgetConnection* pControlConnection, m_leftConnections) { - pControlConnection->setControlParameterUp(v); - } - foreach (ControlWidgetConnection* pControlConnection, m_connections) { - pControlConnection->setControlParameterUp(v); + if (!m_leftConnections.isEmpty()) { + foreach (ControlParameterWidgetConnection* pControlConnection, m_leftConnections) { + pControlConnection->setControlParameterUp(v); + } + } else { + foreach (ControlParameterWidgetConnection* pControlConnection, m_connections) { + pControlConnection->setControlParameterUp(v); + } } } void WBaseWidget::setControlParameterRightDown(double v) { - foreach (ControlWidgetConnection* pControlConnection, m_rightConnections) { - pControlConnection->setControlParameterDown(v); - } - foreach (ControlWidgetConnection* pControlConnection, m_connections) { + foreach (ControlParameterWidgetConnection* pControlConnection, m_rightConnections) { pControlConnection->setControlParameterDown(v); } } void WBaseWidget::setControlParameterRightUp(double v) { - foreach (ControlWidgetConnection* pControlConnection, m_rightConnections) { - pControlConnection->setControlParameterUp(v); - } - foreach (ControlWidgetConnection* pControlConnection, m_connections) { + foreach (ControlParameterWidgetConnection* pControlConnection, m_rightConnections) { pControlConnection->setControlParameterUp(v); } } diff --git a/src/widget/wbasewidget.h b/src/widget/wbasewidget.h index 413e2f899f..18951178c7 100644 --- a/src/widget/wbasewidget.h +++ b/src/widget/wbasewidget.h @@ -5,13 +5,16 @@ #include <QWidget> #include <QList> -#include "widget/controlwidgetconnection.h" +class ControlWidgetPropertyConnection; +class ControlParameterWidgetConnection; class WBaseWidget { public: WBaseWidget(QWidget* pWidget); virtual ~WBaseWidget(); + void Init(); + QWidget* toQWidget() { return m_pWidget; } @@ -25,25 +28,22 @@ class WBaseWidget { return m_baseTooltip; } - void addLeftConnection(ControlWidgetConnection* pConnection); - void addRightConnection(ControlWidgetConnection* pConnection); - void addConnection(ControlWidgetConnection* pConnection); + void addLeftConnection(ControlParameterWidgetConnection* pConnection); + void addRightConnection(ControlParameterWidgetConnection* pConnection); + void addConnection(ControlParameterWidgetConnection* pConnection); + + void addPropertyConnection(ControlWidgetPropertyConnection* pConnection); // Set a ControlWidgetConnection to be the display connection for the // widget. The connection should also be added via an addConnection method // or it will not be deleted or receive updates. - void setDisplayConnection(ControlWidgetConnection* pConnection); + void setDisplayConnection(ControlParameterWidgetConnection* pConnection); double getControlParameter() const; double getControlParameterLeft() const; double getControlParameterRight() const; double getControlParameterDisplay() const; - virtual ControlWidgetConnection::EmitOption getDefaultEmitOption( - Qt::MouseButton state); - virtual ControlWidgetConnection::DirectionOption getDefaultDirectionOption( - Qt::MouseButton state); - protected: |