punktdateien/kde/plasma/plasmoids/com.siezi.plasma.mpdWidget/contents/ui/Components/Application/MpdToggleOptionItem.qml

35 lines
932 B
QML
Raw Normal View History

2024-02-14 21:14:16 +01:00
import QtQuick 2.15
import QtQuick.Controls 2.15 as QQC2
QQC2.ToolButton {
id: root
checkable: true
icon.name: modelData.icon.name
visible: !appWindow.narrowLayout || checked
QQC2.ToolTip {
text: modelData.tooltip + " (" + modelData.shortcut.toUpperCase() + ")"
}
onCheckedChanged: {
let localState = mpdState.mpdOptions[modelData.mpdOption] === "on"
if (root.checked === localState) {
return
}
modelData.onTriggered()
}
Connections {
function onMpdOptionsChanged() {
// This catches us getting our own cmd replied, so don't act on it.
let localState = mpdState.mpdOptions[modelData.mpdOption] === "on"
if (root.checked === localState) {
return
}
root.checked = mpdState.mpdOptions[modelData.mpdOption] === "on"
}
target: mpdState
}
}