Files
arthur-os/shell/Ui/BarIndicator.qml
T
David Heinemeier Hansson 9baf3f7f79 Fix parseModuleJson undefined call in custom command modules
CustomCommandModule.update() in Bar.qml called root.parseModuleJson(raw)
but the function was removed in 3b970068 (the indicator split). Any
custom command module emitting waybar-style JSON would have crashed on
first poll.

Hoist the helper into Util so both call sites — the bar's custom command
module and BarIndicator.extractData — share one definition.
2026-05-20 19:46:47 +02:00

50 lines
1.9 KiB
QML

import QtQuick
import qs.Commons
WidgetButton {
id: root
property string moduleName: ""
property var settings: ({})
property string activeText: ""
property string inactiveText: activeText
property string activeTooltipText: ""
property string inactiveTooltipText: activeTooltipText
property string indicatorBlock: "single"
property var indicatorHost: null
property var activeOverride: null
readonly property bool effectiveActive: activeOverride === null || activeOverride === undefined ? active : activeOverride === true
readonly property bool belongsInBlock: indicatorBlock === "active" ? effectiveActive : (indicatorBlock === "inactive" ? !effectiveActive : true)
readonly property bool inactiveRevealed: !effectiveActive && !!indicatorHost && indicatorHost.revealInactiveIndicators
function extractData(raw) {
return Util.parseModuleJson(raw)
}
function syncIndicatorOpacity() {
root.opacity = !belongsInBlock ? 0 : (active ? 1 : (inactiveRevealed ? 0.45 : 0))
}
Component.onCompleted: syncIndicatorOpacity()
onActiveChanged: syncIndicatorOpacity()
onEffectiveActiveChanged: syncIndicatorOpacity()
onBarChanged: syncIndicatorOpacity()
onBelongsInBlockChanged: syncIndicatorOpacity()
onInactiveRevealedChanged: syncIndicatorOpacity()
onIndicatorBlockChanged: syncIndicatorOpacity()
visible: belongsInBlock && (text !== "" || keepSpace)
text: effectiveActive ? activeText : inactiveText
tooltipText: effectiveActive ? activeTooltipText : inactiveTooltipText
keepSpace: true
dimmed: !effectiveActive
concealed: !effectiveActive && !inactiveRevealed
interactive: belongsInBlock && (effectiveActive || indicatorBlock === "inactive" || inactiveRevealed)
useActiveColor: false
maintainIndicatorReveal: indicatorBlock === "inactive"
revealHost: indicatorHost
fontSize: Style.font.caption
horizontalMargin: 5
verticalPadding: 5
}