Skip to content

Commit

Permalink
Merge pull request #3957 from Holzhaus/qml-controlproxy-reset
Browse files Browse the repository at this point in the history
QML: Add QmlControlProxy::reset() method
  • Loading branch information
uklotzde authored Jun 7, 2021
2 parents 937658a + 9238dc1 commit a0d1c2d
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 54 deletions.
5 changes: 5 additions & 0 deletions res/skins/QMLDemo/ControlKnob.qml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import "." as Skin
import Mixxx 0.1 as Mixxx
import QtQuick 2.12

Skin.Knob {
id: root
Expand All @@ -14,4 +15,8 @@ Skin.Knob {
id: control
}

TapHandler {
onDoubleTapped: control.reset()
}

}
5 changes: 5 additions & 0 deletions res/skins/QMLDemo/ControlSlider.qml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import "." as Skin
import Mixxx 0.1 as Mixxx
import QtQuick 2.12

Skin.Slider {
property alias group: control.group
Expand All @@ -12,4 +13,8 @@ Skin.Slider {
id: control
}

TapHandler {
onDoubleTapped: control.reset()
}

}
2 changes: 1 addition & 1 deletion res/skins/QMLDemo/CrossfaderRow.qml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Item {
anchors.bottom: parent.bottom
}

Skin.ResettableControlSlider {
Skin.ControlSlider {
id: crossfaderSlider

orientation: Qt.Horizontal
Expand Down
2 changes: 1 addition & 1 deletion res/skins/QMLDemo/Deck.qml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Item {
group: root.group
}

Skin.ResettableControlSlider {
Skin.ControlSlider {
id: rateSlider

visible: !root.minimized
Expand Down
2 changes: 1 addition & 1 deletion res/skins/QMLDemo/EqKnob.qml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Rectangle {
height: 56
radius: 5

Skin.ResettableControlKnob {
Skin.ControlKnob {
id: knob

anchors.centerIn: root
Expand Down
4 changes: 2 additions & 2 deletions res/skins/QMLDemo/MixerColumn.qml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Item {
color: Theme.knobBackgroundColor
radius: 5

Skin.ResettableControlKnob {
Skin.ControlKnob {
id: gainKnob

anchors.centerIn: parent
Expand Down Expand Up @@ -57,7 +57,7 @@ Item {
key: "VuMeterR"
}

Skin.ResettableControlSlider {
Skin.ControlSlider {
id: volumeSlider

anchors.fill: parent
Expand Down
25 changes: 0 additions & 25 deletions res/skins/QMLDemo/ResettableControlKnob.qml

This file was deleted.

24 changes: 0 additions & 24 deletions res/skins/QMLDemo/ResettableControlSlider.qml

This file was deleted.

7 changes: 7 additions & 0 deletions src/skin/qml/qmlcontrolproxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
3 changes: 3 additions & 0 deletions src/skin/qml/qmlcontrolproxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit a0d1c2d

Please sign in to comment.