diff --git a/res/skins/QMLDemo/ControlKnob.qml b/res/skins/QMLDemo/ControlKnob.qml index ceac6e6abb1..68080708085 100644 --- a/res/skins/QMLDemo/ControlKnob.qml +++ b/res/skins/QMLDemo/ControlKnob.qml @@ -1,5 +1,6 @@ import "." as Skin import Mixxx 0.1 as Mixxx +import QtQuick 2.12 Skin.Knob { id: root @@ -14,4 +15,8 @@ Skin.Knob { id: control } + TapHandler { + onDoubleTapped: control.reset() + } + } diff --git a/res/skins/QMLDemo/ControlSlider.qml b/res/skins/QMLDemo/ControlSlider.qml index c38c74e098e..add929ffc9a 100644 --- a/res/skins/QMLDemo/ControlSlider.qml +++ b/res/skins/QMLDemo/ControlSlider.qml @@ -1,5 +1,6 @@ import "." as Skin import Mixxx 0.1 as Mixxx +import QtQuick 2.12 Skin.Slider { property alias group: control.group @@ -12,4 +13,8 @@ Skin.Slider { id: control } + TapHandler { + onDoubleTapped: control.reset() + } + } diff --git a/res/skins/QMLDemo/CrossfaderRow.qml b/res/skins/QMLDemo/CrossfaderRow.qml index 5996d47c7ca..1c1c106c7e5 100644 --- a/res/skins/QMLDemo/CrossfaderRow.qml +++ b/res/skins/QMLDemo/CrossfaderRow.qml @@ -18,7 +18,7 @@ Item { anchors.bottom: parent.bottom } - Skin.ResettableControlSlider { + Skin.ControlSlider { id: crossfaderSlider orientation: Qt.Horizontal diff --git a/res/skins/QMLDemo/Deck.qml b/res/skins/QMLDemo/Deck.qml index e6c993e3145..7f04d1a0263 100644 --- a/res/skins/QMLDemo/Deck.qml +++ b/res/skins/QMLDemo/Deck.qml @@ -22,7 +22,7 @@ Item { group: root.group } - Skin.ResettableControlSlider { + Skin.ControlSlider { id: rateSlider visible: !root.minimized diff --git a/res/skins/QMLDemo/EqKnob.qml b/res/skins/QMLDemo/EqKnob.qml index 9119980e8ce..e3102de6237 100644 --- a/res/skins/QMLDemo/EqKnob.qml +++ b/res/skins/QMLDemo/EqKnob.qml @@ -16,7 +16,7 @@ Rectangle { height: 56 radius: 5 - Skin.ResettableControlKnob { + Skin.ControlKnob { id: knob anchors.centerIn: root diff --git a/res/skins/QMLDemo/MixerColumn.qml b/res/skins/QMLDemo/MixerColumn.qml index 6f838f56834..8ddb5be466f 100644 --- a/res/skins/QMLDemo/MixerColumn.qml +++ b/res/skins/QMLDemo/MixerColumn.qml @@ -18,7 +18,7 @@ Item { color: Theme.knobBackgroundColor radius: 5 - Skin.ResettableControlKnob { + Skin.ControlKnob { id: gainKnob anchors.centerIn: parent @@ -57,7 +57,7 @@ Item { key: "VuMeterR" } - Skin.ResettableControlSlider { + Skin.ControlSlider { id: volumeSlider anchors.fill: parent diff --git a/res/skins/QMLDemo/ResettableControlKnob.qml b/res/skins/QMLDemo/ResettableControlKnob.qml deleted file mode 100644 index 94c79f1165b..00000000000 --- a/res/skins/QMLDemo/ResettableControlKnob.qml +++ /dev/null @@ -1,25 +0,0 @@ -import "." as Skin -import Mixxx 0.1 as Mixxx -import QtQuick 2.12 - -Skin.ControlKnob { - id: root - - property string resetGroup: group - property string resetKey: key + "_set_default" - - Mixxx.ControlProxy { - id: resetControl - - group: root.resetGroup - key: root.resetKey - } - - TapHandler { - onDoubleTapped: { - resetControl.value = 1; - resetControl.value = 0; - } - } - -} diff --git a/res/skins/QMLDemo/ResettableControlSlider.qml b/res/skins/QMLDemo/ResettableControlSlider.qml deleted file mode 100644 index b3c912dab21..00000000000 --- a/res/skins/QMLDemo/ResettableControlSlider.qml +++ /dev/null @@ -1,24 +0,0 @@ -import "." as Skin -import Mixxx 0.1 as Mixxx -import Mixxx.Controls 0.1 as MixxxControls -import QtQuick 2.12 - -Skin.ControlSlider { - property string resetGroup: group - property string resetKey: key + "_set_default" - - Mixxx.ControlProxy { - id: resetControl - - group: resetGroup - key: resetKey - } - - TapHandler { - onDoubleTapped: { - resetControl.value = 1; - resetControl.value = 0; - } - } - -} diff --git a/src/skin/qml/qmlcontrolproxy.cpp b/src/skin/qml/qmlcontrolproxy.cpp index b57b4e2acce..5cb7f2cdc56 100644 --- a/src/skin/qml/qmlcontrolproxy.cpp +++ b/src/skin/qml/qmlcontrolproxy.cpp @@ -105,6 +105,13 @@ double QmlControlProxy::getParameter() const { return m_pControlProxy->getParameter(); } +void QmlControlProxy::reset() { + if (!isInitialized()) { + return; + } + m_pControlProxy->reset(); +} + void QmlControlProxy::reinitializeFromKey() { // Just ignore this if the component is still loading, because group or key may not be set yet. if (!m_isComponentComplete) { diff --git a/src/skin/qml/qmlcontrolproxy.h b/src/skin/qml/qmlcontrolproxy.h index 1e62590b0ee..5b2493714a6 100644 --- a/src/skin/qml/qmlcontrolproxy.h +++ b/src/skin/qml/qmlcontrolproxy.h @@ -55,6 +55,9 @@ class QmlControlProxy : public QObject, public QQmlParserStatus { bool isKeyValid() const; bool isInitialized() const; + /// Reset the control to the default value. + Q_INVOKABLE void reset(); + signals: void groupChanged(const QString& group); void keyChanged(const QString& key);