summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/controllers/controllerlearningeventfilter.cpp2
-rw-r--r--src/controllers/controllerlearningeventfilter.h15
-rw-r--r--src/controlobjectthreadwidget.cpp59
-rw-r--r--src/controlobjectthreadwidget.h14
-rw-r--r--src/skin/legacyskinparser.cpp61
-rw-r--r--src/skin/legacyskinparser.h4
-rw-r--r--src/widget/knobeventhandler.h10
-rw-r--r--src/widget/wbasewidget.cpp150
-rw-r--r--src/widget/wbasewidget.h97
-rw-r--r--src/widget/wkey.cpp4
-rw-r--r--src/widget/wkey.h2
-rw-r--r--src/widget/wnumber.cpp4
-rw-r--r--src/widget/wnumber.h2
-rw-r--r--src/widget/woverview.cpp8
-rw-r--r--src/widget/woverview.h2
-rw-r--r--src/widget/wpushbutton.cpp18
-rw-r--r--src/widget/wpushbutton.h2
-rw-r--r--src/widget/wslidercomposed.cpp14
-rw-r--r--src/widget/wslidercomposed.h2
-rw-r--r--src/widget/wstatuslight.cpp2
-rw-r--r--src/widget/wstatuslight.h2
-rw-r--r--src/widget/wvumeter.cpp2
-rw-r--r--src/widget/wvumeter.h2
-rw-r--r--src/widget/wwaveformviewer.cpp8
-rw-r--r--src/widget/wwaveformviewer.h1
-rw-r--r--src/widget/wwidget.cpp27
-rw-r--r--src/widget/wwidget.h17
27 files changed, 355 insertions, 176 deletions
diff --git a/src/controllers/controllerlearningeventfilter.cpp b/src/controllers/controllerlearningeventfilter.cpp
index be29dd605a..97b62995da 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,
- ControlObjectThreadWidget::EmitOption emitOption) {
+ ControlWidgetConnection::EmitOption emitOption) {
ControlInfo& info = m_widgetControlInfo[pWidget];
if (buttonState == Qt::LeftButton) {
diff --git a/src/controllers/controllerlearningeventfilter.h b/src/controllers/controllerlearningeventfilter.h
index e0a69dcdf6..c3976bb5c4 100644
--- a/src/controllers/controllerlearningeventfilter.h
+++ b/src/controllers/controllerlearningeventfilter.h
@@ -6,23 +6,24 @@
#include "controlobject.h"
#include "controlobjectthreadwidget.h"
+#include "widget/wbasewidget.h"
struct ControlInfo {
ControlInfo()
: clickControl(NULL),
- emitOption(ControlObjectThreadWidget::EMIT_ON_PRESS_AND_RELEASE),
+ emitOption(ControlWidgetConnection::EMIT_ON_PRESS_AND_RELEASE),
leftClickControl(NULL),
- leftEmitOption(ControlObjectThreadWidget::EMIT_ON_PRESS_AND_RELEASE),
+ leftEmitOption(ControlWidgetConnection::EMIT_ON_PRESS_AND_RELEASE),
rightClickControl(NULL),
- rightEmitOption(ControlObjectThreadWidget::EMIT_ON_PRESS_AND_RELEASE) {
+ rightEmitOption(ControlWidgetConnection::EMIT_ON_PRESS_AND_RELEASE) {
}
ControlObject* clickControl;
- ControlObjectThreadWidget::EmitOption emitOption;
+ ControlWidgetConnection::EmitOption emitOption;
ControlObject* leftClickControl;
- ControlObjectThreadWidget::EmitOption leftEmitOption;
+ ControlWidgetConnection::EmitOption leftEmitOption;
ControlObject* rightClickControl;
- ControlObjectThreadWidget::EmitOption rightEmitOption;
+ ControlWidgetConnection::EmitOption rightEmitOption;
};
class ControllerLearningEventFilter : public QObject {
@@ -35,7 +36,7 @@ class ControllerLearningEventFilter : public QObject {
void addWidgetClickInfo(QWidget* pWidget, Qt::MouseButton buttonState,
ControlObject* pControl,
- ControlObjectThreadWidget::EmitOption emitOption);
+ ControlWidgetConnection::EmitOption emitOption);
public slots:
void startListening();
diff --git a/src/controlobjectthreadwidget.cpp b/src/controlobjectthreadwidget.cpp
index 493b45d0ea..d8bcb3875a 100644
--- a/src/controlobjectthreadwidget.cpp
+++ b/src/controlobjectthreadwidget.cpp
@@ -20,65 +20,6 @@ ControlObjectThreadWidget::ControlObjectThreadWidget(const QString& g, const QSt
ControlObjectThreadWidget::~ControlObjectThreadWidget() {
}
-void ControlObjectThreadWidget::setWidget(QWidget * widget, bool connectValueFromWidget,
- bool connectValueToWidget,
- EmitOption emitOption, Qt::MouseButton state) {
- if (connectValueFromWidget) {
- connect(widget, SIGNAL(valueReset()),
- this, SLOT(reset()));
-
- if (emitOption & EMIT_ON_PRESS) {
- switch (state) {
- case Qt::NoButton:
- connect(widget, SIGNAL(valueChangedDown(double)),
- this, SLOT(slotSet(double)));
- break;
- case Qt::LeftButton:
- connect(widget, SIGNAL(valueChangedLeftDown(double)),
- this, SLOT(slotSet(double)));
- break;
- case Qt::RightButton:
- connect(widget, SIGNAL(valueChangedRightDown(double)),
- this, SLOT(slotSet(double)));
- break;
- default:
- break;
- }
- }
-
- if (emitOption & EMIT_ON_RELEASE) {
- switch (state) {
- case Qt::NoButton:
- connect(widget, SIGNAL(valueChangedUp(double)),
- this, SLOT(slotSet(double)));
- break;
- case Qt::LeftButton:
- connect(widget, SIGNAL(valueChangedLeftUp(double)),
- this, SLOT(slotSet(double)));
- break;
- case Qt::RightButton:
- connect(widget, SIGNAL(valueChangedRightUp(double)),
- this, SLOT(slotSet(double)));
- break;
- default:
- break;
- }
- }
- }
-
- if (connectValueToWidget) {
- connect(this, SIGNAL(valueChanged(double)),
- widget, SLOT(slotConnectedValueChanged(double)));
- }
- emit(valueChanged(get()));
-}
-
-void ControlObjectThreadWidget::setWidgetOnOff(QWidget* widget) {
- connect(this, SIGNAL(valueChanged(double)),
- widget, SLOT(setOnOff(double)));
- emit(valueChanged(get()));
-}
-
double ControlObjectThreadWidget::get() {
return m_pControl ? m_pControl->getParameter() : 0.0;
}
diff --git a/src/controlobjectthreadwidget.h b/src/controlobjectthreadwidget.h
index 0af53e9478..a917dfe1eb 100644
--- a/src/controlobjectthreadwidget.h
+++ b/src/controlobjectthreadwidget.h
@@ -24,24 +24,10 @@
class ControlObjectThreadWidget : public ControlObjectThreadMain {
Q_OBJECT
public:
-
- enum EmitOption {
- EMIT_NEVER = 0x00,
- EMIT_ON_PRESS = 0x01,
- EMIT_ON_RELEASE = 0x02,
- EMIT_ON_PRESS_AND_RELEASE = 0x03
- };
-
ControlObjectThreadWidget(const ConfigKey& key, QObject* pParent = NULL);
ControlObjectThreadWidget(const char* g, const char* i, QObject* pParent = NULL);
ControlObjectThreadWidget(const QString& g, const QString& i, QObject* pParent = NULL);
virtual ~ControlObjectThreadWidget();
- // Associates a QWidget with the ControlObject.
- void setWidget(QWidget *widget,
- bool connectValueFromWidget=true, bool connectValueToWidget = true,
- EmitOption emitOption=EMIT_ON_PRESS, Qt::MouseButton state=Qt::NoButton);
- // Associates a the enabled/disabled state of a widget with the state of a ControlObject. */
- void setWidgetOnOff(QWidget *widget);
virtual double get();
diff --git a/src/skin/legacyskinparser.cpp b/src/skin/legacyskinparser.cpp
index 484ca9171c..ca61517757 100644
--- a/src/skin/legacyskinparser.cpp
+++ b/src/skin/legacyskinparser.cpp
@@ -731,11 +731,11 @@ QWidget* LegacySkinParser::parseVisual(QDomElement node) {
viewer->installEventFilter(m_pControllerManager->getControllerLearningEventFilter());
// Connect control proxy to widget, so delete can be handled by the QT object tree
- ControlObjectThreadWidget * p = new ControlObjectThreadWidget(
+ ControlObjectThreadWidget* p = new ControlObjectThreadWidget(
channelStr, "wheel", viewer);
-
- p->setWidget((QWidget *)viewer, true, false,
- ControlObjectThreadWidget::EMIT_ON_PRESS, Qt::RightButton);
+ ControlWidgetConnection* pConnection = new ValueControlWidgetConnection(
+ viewer, p, true, false, ControlWidgetConnection::EMIT_ON_PRESS);
+ viewer->addRightConnection(pConnection);
setupBaseWidget(node, viewer);
setupWidget(node, viewer);
@@ -1589,7 +1589,7 @@ void LegacySkinParser::setupWidget(QDomNode node,
}
}
-void LegacySkinParser::setupConnections(QDomNode node, QWidget* pWidget) {
+void LegacySkinParser::setupConnections(QDomNode node, WBaseWidget* pWidget) {
// For each connection
QDomNode con = m_pContext->selectNode(node, "Connection");
@@ -1610,7 +1610,7 @@ void LegacySkinParser::setupConnections(QDomNode node, QWidget* pWidget) {
// Bind this control to a property. Not leaked because it is
// parented to the widget and so it dies with it.
PropertyBinder* pBinder = new PropertyBinder(
- pWidget, property, control, m_pConfig);
+ pWidget->toQWidget(), property, control, m_pConfig);
// If we created this control, bind it to the PropertyBinder so that
// it is deleted when the binder is deleted.
if (created) {
@@ -1622,17 +1622,24 @@ void LegacySkinParser::setupConnections(QDomNode node, QWidget* pWidget) {
// leaked. OnOff controls do not use the value of the widget at all
// so we do not give this control's info to the
// ControllerLearningEventFilter.
- (new ControlObjectThreadWidget(control->getKey(), pWidget))->setWidgetOnOff(pWidget);
+ ControlObjectThreadWidget* pControlWidget =
+ new ControlObjectThreadWidget(control->getKey(),
+ pWidget->toQWidget());
+ ControlWidgetConnection* pConnection =
+ new DisabledControlWidgetConnection(pWidget,
+ pControlWidget);
+ pWidget->addConnection(pConnection);
} else {
// Default to emit on press
- ControlObjectThreadWidget::EmitOption emitOption = ControlObjectThreadWidget::EMIT_ON_PRESS;
+ ControlWidgetConnection::EmitOption emitOption =
+ ControlWidgetConnection::EMIT_ON_PRESS;
// Get properties from XML, or use defaults
if (m_pContext->selectBool(con, "EmitOnPressAndRelease", false))
- emitOption = ControlObjectThreadWidget::EMIT_ON_PRESS_AND_RELEASE;
+ emitOption = ControlWidgetConnection::EMIT_ON_PRESS_AND_RELEASE;
if (!m_pContext->selectBool(con, "EmitOnDownPress", true))
- emitOption = ControlObjectThreadWidget::EMIT_ON_RELEASE;
+ emitOption = ControlWidgetConnection::EMIT_ON_RELEASE;
bool connectValueFromWidget = m_pContext->selectBool(con, "ConnectValueFromWidget", true);
bool connectValueToWidget = m_pContext->selectBool(con, "ConnectValueToWidget", true);
@@ -1648,15 +1655,31 @@ void LegacySkinParser::setupConnections(QDomNode node, QWidget* pWidget) {
// Connect control proxy to widget. Parented to pWidget so it is not
// leaked.
- (new ControlObjectThreadWidget(control->getKey(), pWidget))->setWidget(
- pWidget, connectValueFromWidget, connectValueToWidget,
- emitOption, state);
+ ControlObjectThreadWidget* pControlWidget = new ControlObjectThreadWidget(
+ control->getKey(), pWidget->toQWidget());
+ ControlWidgetConnection* pConnection = new ValueControlWidgetConnection(
+ pWidget, pControlWidget, connectValueFromWidget,
+ connectValueToWidget, emitOption);
+
+ switch (state) {
+ case Qt::NoButton:
+ pWidget->addConnection(pConnection);
+ break;
+ case Qt::LeftButton:
+ pWidget->addLeftConnection(pConnection);
+ break;
+ case Qt::RightButton:
+ pWidget->addRightConnection(pConnection);
+ break;
+ default:
+ break;
+ }
// We only add info for controls that this widget affects, not
// controls that only affect the widget.
if (connectValueFromWidget) {
m_pControllerManager->getControllerLearningEventFilter()
- ->addWidgetClickInfo(pWidget, state, control, emitOption);
+ ->addWidgetClickInfo(pWidget->toQWidget(), state, control, emitOption);
}
// Add keyboard shortcut info to tooltip string
@@ -1667,7 +1690,7 @@ void LegacySkinParser::setupConnections(QDomNode node, QWidget* pWidget) {
const WSliderComposed* pSlider;
- if (qobject_cast<const WPushButton*>(pWidget)) {
+ if (qobject_cast<const WPushButton*>(pWidget->toQWidget())) {
// check for "_activate", "_toggle"
ConfigKey subkey;
QString shortcut;
@@ -1681,7 +1704,7 @@ void LegacySkinParser::setupConnections(QDomNode node, QWidget* pWidget) {
subkey.item += "_toggle";
shortcut = m_pKeyboard->getKeyboardConfig()->getValueString(subkey);
addShortcutToToolTip(pWidget, shortcut, tr("toggle"));
- } else if ((pSlider = qobject_cast<const WSliderComposed*>(pWidget))) {
+ } else if ((pSlider = qobject_cast<const WSliderComposed*>(pWidget->toQWidget()))) {
// check for "_up", "_down", "_up_small", "_down_small"
ConfigKey subkey;
QString shortcut;
@@ -1734,12 +1757,12 @@ void LegacySkinParser::setupConnections(QDomNode node, QWidget* pWidget) {
}
}
-void LegacySkinParser::addShortcutToToolTip(QWidget* pWidget, const QString& shortcut, const QString& cmd) {
+void LegacySkinParser::addShortcutToToolTip(WBaseWidget* pWidget, const QString& shortcut, const QString& cmd) {
if (shortcut.isEmpty()) {
return;
}
- QString tooltip = pWidget->toolTip();
+ QString tooltip = pWidget->baseTooltip();
// translate shortcut to native text
#if QT_VERSION >= 0x040700
@@ -1757,5 +1780,5 @@ void LegacySkinParser::addShortcutToToolTip(QWidget* pWidget, const QString& sho
}
tooltip += ": ";
tooltip += nativeShortcut;
- pWidget->setToolTip(tooltip);
+ pWidget->setBaseTooltip(tooltip);
}
diff --git a/src/skin/legacyskinparser.h b/src/skin/legacyskinparser.h
index dfe7da9947..691ce5bfba 100644
--- a/src/skin/legacyskinparser.h
+++ b/src/skin/legacyskinparser.h
@@ -84,8 +84,8 @@ class LegacySkinParser : public QObject, public SkinParser {
void setupBaseWidget(QDomNode node, WBaseWidget* pBaseWidget);
void setupWidget(QDomNode node, QWidget* pWidget,
bool setupPosition=true);
- void setupConnections(QDomNode node, QWidget* pWidget);
- void addShortcutToToolTip(QWidget* pWidget, const QString& shortcut, const QString& cmd);
+ void setupConnections(QDomNode node, WBaseWidget* pWidget);
+ void addShortcutToToolTip(WBaseWidget* pWidget, const QString& shortcut, const QString& cmd);
QString getLibraryStyle(QDomNode node);
QString getStyleFromNode(QDomNode node);
diff --git a/src/widget/knobeventhandler.h b/src/widget/knobeventhandler.h
index 4a47d69ecc..b67aab9eb1 100644
--- a/src/widget/knobeventhandler.h
+++ b/src/widget/knobeventhandler.h
@@ -38,8 +38,8 @@ class KnobEventHandler {
// Clamp to [0.0, 1.0]
value = math_max(0.0, math_min(1.0, value));
- pWidget->slotConnectedValueChanged(value);
- emit(pWidget->valueChangedLeftDown(value));
+ pWidget->onConnectedControlValueChanged(value);
+ pWidget->setConnectedControlLeftDown(value);
pWidget->update();
}
}
@@ -47,7 +47,7 @@ class KnobEventHandler {
void mousePressEvent(T* pWidget, QMouseEvent* e) {
switch (e->button()) {
case Qt::RightButton:
- emit(pWidget->valueReset());
+ pWidget->resetConnectedControls();
m_bRightButtonPressed = true;
break;
case Qt::LeftButton:
@@ -66,11 +66,11 @@ class KnobEventHandler {
case Qt::MidButton:
QCursor::setPos(m_startPos);
QApplication::restoreOverrideCursor();
- emit(pWidget->valueChangedLeftUp(pWidget->getValue()));
+ pWidget->setConnectedControlLeftUp(pWidget->getValue());
break;
case Qt::RightButton:
m_bRightButtonPressed = false;
- //emit(pWidget->valueChangedRightUp(m_fValue));
+ //pWidget->setConnectedControlRightUp(pWidget->getValue());
break;
default:
break;
diff --git a/src/widget/wbasewidget.cpp b/src/widget/wbasewidget.cpp
index 24ce9f4d0b..27c372ce4c 100644
--- a/src/widget/wbasewidget.cpp
+++ b/src/widget/wbasewidget.cpp
@@ -1,5 +1,91 @@
+#include <QtDebug>
+
#include "widget/wbasewidget.h"
+#include "controlobjectthreadwidget.h"
+
+ControlWidgetConnection::ControlWidgetConnection(WBaseWidget* pBaseWidget,
+ ControlObjectThreadWidget* pControl)
+ : m_pWidget(pBaseWidget),
+ m_pControl(pControl) {
+ connect(pControl, SIGNAL(valueChanged(double)),
+ this, SLOT(slotControlValueChanged(double)));
+}
+
+ControlWidgetConnection::~ControlWidgetConnection() {
+}
+
+ValueControlWidgetConnection::ValueControlWidgetConnection(WBaseWidget* pBaseWidget,
+ ControlObjectThreadWidget* pControl,
+ bool connectValueFromWidget,
+ bool connectValueToWidget,
+ EmitOption emitOption)
+ : ControlWidgetConnection(pBaseWidget, pControl),
+ m_bConnectValueFromWidget(connectValueFromWidget),
+ m_bConnectValueToWidget(connectValueToWidget),
+ m_emitOption(emitOption) {
+ if (m_bConnectValueToWidget) {
+ slotControlValueChanged(m_pControl->get());
+ }
+}
+
+ValueControlWidgetConnection::~ValueControlWidgetConnection() {
+}
+
+void ValueControlWidgetConnection::slotControlValueChanged(double v) {
+ if (m_bConnectValueToWidget) {
+ m_pWidget->onConnectedControlValueChanged(v);
+ // TODO(rryan): copied from WWidget. Keep?
+ //m_pWidget->toQWidget()->update();
+ }
+}
+
+void ValueControlWidgetConnection::reset() {
+ if (m_bConnectValueFromWidget) {
+ m_pControl->reset();
+ }
+}
+
+void ValueControlWidgetConnection::setDown(double v) {
+ if (m_bConnectValueFromWidget && m_emitOption & EMIT_ON_PRESS) {
+ m_pControl->slotSet(v);
+ }
+}
+
+void ValueControlWidgetConnection::setUp(double v) {
+ if (m_bConnectValueFromWidget && m_emitOption & EMIT_ON_RELEASE) {
+ m_pControl->slotSet(v);
+ }
+}
+
+DisabledControlWidgetConnection::DisabledControlWidgetConnection(WBaseWidget* pBaseWidget,
+ ControlObjectThreadWidget* pControl)
+ : ControlWidgetConnection(pBaseWidget, pControl) {
+ slotControlValueChanged(m_pControl->get());
+}
+
+DisabledControlWidgetConnection::~DisabledControlWidgetConnection() {
+}
+
+void DisabledControlWidgetConnection::slotControlValueChanged(double v) {
+ m_pWidget->setControlDisabled(v != 0.0);
+ m_pWidget->toQWidget()->update();
+}
+
+void DisabledControlWidgetConnection::reset() {
+ // Do nothing.
+}
+
+void DisabledControlWidgetConnection::setDown(double v) {
+ // Do nothing.
+ Q_UNUSED(v);
+}
+
+void DisabledControlWidgetConnection::setUp(double v) {
+ // Do nothing.
+ Q_UNUSED(v);
+}
+
WBaseWidget::WBaseWidget(QWidget* pWidget)
: m_pWidget(pWidget),
m_bDisabled(false) {
@@ -7,3 +93,67 @@ WBaseWidget::WBaseWidget(QWidget* pWidget)
WBaseWidget::~WBaseWidget() {
}
+
+void WBaseWidget::addConnection(ControlWidgetConnection* pConnection) {
+ m_connections.append(pConnection);
+}
+
+void WBaseWidget::addLeftConnection(ControlWidgetConnection* pConnection) {
+ m_leftConnections.append(pConnection);
+}
+
+void WBaseWidget::addRightConnection(ControlWidgetConnection* pConnection) {
+ m_rightConnections.append(pConnection);
+}
+
+void WBaseWidget::resetConnectedControls() {
+ foreach (ControlWidgetConnection* pControlConnection, m_leftConnections) {
+ pControlConnection->reset();
+ }
+ foreach (ControlWidgetConnection* pControlConnection, m_rightConnections) {
+ pControlConnection->reset();
+ }
+ foreach (ControlWidgetConnection* pControlConnection, m_connections) {
+ pControlConnection->reset();
+ }
+}
+
+void WBaseWidget::setConnectedControlDown(double v) {
+ foreach (ControlWidgetConnection* pControlConnection, m_connections) {
+ pControlConnection->setDown(v);
+ }
+}
+
+void WBaseWidget::setConnectedControlUp(double v) {
+ foreach (ControlWidgetConnection* pControlConnection, m_connections) {
+ pControlConnection->setUp(v);
+ }
+}
+
+void WBaseWidget::setConnectedControlLeftDown(double v) {
+ foreach (ControlWidgetConnection* pControlConnection, m_leftConnections) {
+ pControlConnection->setDown(v);
+ }
+ setConnectedControlDown(v);
+}
+
+void WBaseWidget::setConnectedControlLeftUp(double v) {
+ foreach (ControlWidgetConnection* pControlConnection, m_leftConnections) {
+ pControlConnection->setUp(v);
+ }
+ setConnectedControlUp(v);
+}
+
+void WBaseWidget::setConnectedControlRightDown(double v) {
+ foreach (ControlWidgetConnection* pControlConnection, m_rightConnections) {
+ pControlConnection->setDown(v);
+ }
+ setConnectedControlDown(v);
+}
+
+void WBaseWidget::setConnectedControlRightUp(double v) {
+ foreach (ControlWidgetConnection* pControlConnection, m_rightConnections) {
+ pControlConnection->setUp(v);
+ }
+ setConnectedControlUp(v);
+}
diff --git a/src/widget/wbasewidget.h b/src/widget/wbasewidget.h
index faa06cde8b..a29cb98922 100644
--- a/src/widget/wbasewidget.h
+++ b/src/widget/wbasewidget.h
@@ -3,6 +3,80 @@
#include <QString>
#include <QWidget>
+#include <QList>
+#include <QObject>
+#include <QScopedPointer>
+#include <QDomNode>
+
+class ControlObjectThreadWidget;
+
+class WBaseWidget;
+class ControlWidgetConnection : public QObject {
+ Q_OBJECT
+ public:
+ enum EmitOption {
+ EMIT_NEVER = 0x00,
+ EMIT_ON_PRESS = 0x01,
+ EMIT_ON_RELEASE = 0x02,
+ EMIT_ON_PRESS_AND_RELEASE = 0x03
+ };
+
+ // Takes ownership of pControl.
+ ControlWidgetConnection(WBaseWidget* pBaseWidget,
+ ControlObjectThreadWidget* pControl);
+ virtual ~ControlWidgetConnection();
+
+ virtual void reset() = 0;
+ virtual void setDown(double v) = 0;
+ virtual void setUp(double v) = 0;
+
+ protected slots:
+ virtual void slotControlValueChanged(double v) = 0;
+
+ protected:
+ WBaseWidget* m_pWidget;
+ QScopedPointer<ControlObjectThreadWidget> m_pControl;
+};
+
+class ValueControlWidgetConnection : public ControlWidgetConnection {
+ Q_OBJECT
+ public:
+ ValueControlWidgetConnection(WBaseWidget* pBaseWidget,
+ ControlObjectThreadWidget* pControl,
+ bool connectValueFromWidget,
+ bool connectValueToWidget,
+ EmitOption emitOption);
+ virtual ~ValueControlWidgetConnection();
+
+ protected:
+ void reset();
+ void setDown(double v);
+ void setUp(double v);
+
+ protected slots:
+ void slotControlValueChanged(double v);
+
+ private:
+ bool m_bConnectValueFromWidget;
+ bool m_bConnectValueToWidget;
+ EmitOption m_emitOption;
+};
+
+class DisabledControlWidgetConnection : public ControlWidgetConnection {
+ Q_OBJECT
+ public:
+ DisabledControlWidgetConnection(WBaseWidget* pBaseWidget,
+ ControlObjectThreadWidget* pControl);
+ virtual ~DisabledControlWidgetConnection();
+
+ protected:
+ void reset();
+ void setDown(double v);
+ void setUp(double v);
+
+ protected slots:
+ void slotControlValueChanged(double v);
+};
class WBaseWidget {
public:
@@ -30,10 +104,33 @@ class WBaseWidget {
return m_bDisabled;
}
+ void addLeftConnection(ControlWidgetConnection* pConnection);
+ void addRightConnection(ControlWidgetConnection* pConnection);
+ void addConnection(ControlWidgetConnection* pConnection);
+
+ protected:
+ virtual void onConnectedControlValueChanged(double v) {
+ Q_UNUSED(v);
+ }
+
+ void resetConnectedControls();
+ void setConnectedControlDown(double v);
+ void setConnectedControlUp(double v);
+ void setConnectedControlLeftDown(double v);
+ void setConnectedControlLeftUp(double v);
+ void setConnectedControlRightDown(double v);
+ void setConnectedControlRightUp(double v);
+
private:
QWidget* m_pWidget;
bool m_bDisabled;
QString m_baseTooltip;
+ QList<ControlWidgetConnection*> m_connections;
+ QList<ControlWidgetConnection*> m_leftConnections;
+ QList<ControlWidgetConnection*> m_rightConnections;
+
+ friend class ValueControlWidgetConnection;
+ friend class DisabledControlWidgetConnection;
};
#endif /* WBASEWIDGET_H */
diff --git a/src/widget/wkey.cpp b/src/widget/wkey.cpp
index 84fc6ab99d..b271e08283 100644
--- a/src/widget/wkey.cpp
+++ b/src/widget/wkey.cpp
@@ -15,6 +15,10 @@ WKey::WKey(QWidget* pParent)
WKey::~WKey() {
}
+void WKey::onConnectedControlValueChanged(double v) {
+ setValue(v);
+}
+
void WKey::setValue(double dValue) {
m_dOldValue = dValue;
mixxx::track::io::key::ChromaticKey key =
diff --git a/src/widget/wkey.h b/src/widget/wkey.h
index 88c828e9d8..5e58a01cae 100644
--- a/src/widget/wkey.h
+++ b/src/widget/wkey.h
@@ -12,6 +12,8 @@ class WKey : public WLabel {
WKey(QWidget* pParent=NULL);
virtual ~WKey();
+ virtual void onConnectedControlValueChanged(double v);
+
private slots:
void setValue(double dValue);
void preferencesUpdated(double dValue);
diff --git a/src/widget/wnumber.cpp b/src/widget/wnumber.cpp
index a3a862ab5b..45c4f34c02 100644
--- a/src/widget/wnumber.cpp
+++ b/src/widget/wnumber.cpp
@@ -47,6 +47,10 @@ void WNumber::setup(QDomNode node, const SkinContext& context) {
setValue(0.);
}
+void WNumber::onConnectedControlValueChanged(double v) {
+ setValue(v);
+}
+
void WNumber::setValue(double dValue) {
double v = dValue + m_dConstFactor;
int d1 = (int)floor((v-floor(v))*10.);
diff --git a/src/widget/wnumber.h b/src/widget/wnumber.h
index f3d7504342..c542473c83 100644
--- a/src/widget/wnumber.h
+++ b/src/widget/wnumber.h
@@ -31,6 +31,8 @@ class WNumber : public WLabel {
virtual void setup(QDomNode node, const SkinContext& context);
+ virtual void onConnectedControlValueChanged(double v);
+
public slots:
virtual void setValue(double dValue);
diff --git a/src/widget/woverview.cpp b/src/widget/woverview.cpp
index 4bb06f2529..5ece68ce72 100644
--- a/src/widget/woverview.cpp
+++ b/src/widget/woverview.cpp
@@ -120,14 +120,14 @@ void WOverview::setup(QDomNode node, const SkinContext& context) {
//qDebug() << "WOverview : m_markRanges" << m_markRanges.size();
}
-void WOverview::slotConnectedValueChanged(double dValue) {
+void WOverview::onConnectedControlValueChanged(double dValue) {
if (!m_bDrag)
{
// Calculate handle position
int iPos = valueToPosition(dValue);
if (iPos != m_iPos) {
m_iPos = iPos;
- //qDebug() << "WOverview::slotConnectedValueChanged" << dValue << ">>" << m_iPos;
+ //qDebug() << "WOverview::onConnectedControlValueChanged" << dValue << ">>" << m_iPos;
update();
}
}
@@ -252,9 +252,9 @@ void WOverview::mouseReleaseEvent(QMouseEvent* e) {
//qDebug() << "WOverview::mouseReleaseEvent" << e->pos() << m_iPos << ">>" << dValue;
if (e->button() == Qt::RightButton) {
- emit(valueChangedRightUp(dValue));
+ setConnectedControlRightUp(dValue);
} else {
- emit(valueChangedLeftUp(dValue));
+ setConnectedControlLeftUp(dValue);
}
m_bDrag = false;
}
diff --git a/src/widget/woverview.h b/src/widget/woverview.h
index 9ebe8b5b77..5ec505bf8c 100644
--- a/src/widget/woverview.h
+++ b/src/widget/woverview.h
@@ -40,7 +40,7 @@ class WOverview : public WWidget {
void setup(QDomNode node, const SkinContext& context);
public slots:
- void slotConnectedValueChanged(double);
+ void onConnectedControlValueChanged(double);
void slotLoadNewTrack(TrackPointer pTrack);
void slotTrackLoaded(TrackPointer pTrack);
void slotUnloadTrack(TrackPointer pTrack);
diff --git a/src/widget/wpushbutton.cpp b/src/widget/wpushbutton.cpp
index 566b26ac4e..7ca392f4ae 100644
--- a/src/widget/wpushbutton.cpp
+++ b/src/widget/wpushbutton.cpp
@@ -172,7 +172,7 @@ void WPushButton::setPixmapBackground(const QString &filename) {
}
}
-void WPushButton::slotConnectedValueChanged(double v) {