Skip to content

Commit

Permalink
Merge pull request #4068 from Holzhaus/qml-syncbutton
Browse files Browse the repository at this point in the history
skins/QMLDemo: Add SyncButton component with leader support
  • Loading branch information
Swiftb0y committed Jul 7, 2021
2 parents d6236d4 + a152e84 commit a88e298
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 5 deletions.
6 changes: 1 addition & 5 deletions res/skins/QMLDemo/Deck.qml
Original file line number Diff line number Diff line change
Expand Up @@ -365,16 +365,12 @@ Item {

}

Skin.ControlButton {
Skin.SyncButton {
id: syncButton

anchors.right: parent.right
anchors.top: parent.top
text: "Sync"
group: root.group
key: "sync_enabled"
toggleable: true
activeColor: Theme.deckActiveColor
}

FadeBehavior on visible {
Expand Down
70 changes: 70 additions & 0 deletions res/skins/QMLDemo/SyncButton.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import "." as Skin
import Mixxx 0.1 as Mixxx
import "Theme"

Skin.Button {
id: root

enum SyncMode {
Off,
Follower,
ImplicitLeader,
ExplicitLeader
}

property string group // required
property alias mode: modeControl.value

function toggleSync() {
enabledControl.value = !enabledControl.value;
}

function toggleLeader() {
leaderControl.value = !leaderControl.value;
}

activeColor: {
switch (mode) {
case SyncButton.SyncMode.ImplicitLeader:
return Theme.yellow;
case SyncButton.SyncMode.ExplicitLeader:
return Theme.red;
default:
return Theme.deckActiveColor;
}
}
text: {
switch (mode) {
case SyncButton.SyncMode.ImplicitLeader:
case SyncButton.SyncMode.ExplicitLeader:
return "Leader";
default:
return "Sync";
}
}
highlight: enabledControl.value
onClicked: toggleSync()
onPressAndHold: toggleLeader()

Mixxx.ControlProxy {
id: enabledControl

group: root.group
key: "sync_enabled"
}

Mixxx.ControlProxy {
id: modeControl

group: root.group
key: "sync_mode"
}

Mixxx.ControlProxy {
id: leaderControl

group: root.group
key: "sync_master"
}

}

0 comments on commit a88e298

Please sign in to comment.