Files
pi-gui/noctalia-plugin/pi-status-bridge/BarWidget.qml

72 lines
3.0 KiB
QML

import QtQuick
import QtQuick.Layouts
import Quickshell
import Quickshell.Io
import qs.Commons
import qs.Widgets
Item {
id: root
property var pluginApi: null
property ShellScreen screen
property string widgetId: ""
property string section: ""
property int sectionWidgetIndex: -1
property int sectionWidgetsCount: 0
readonly property string screenName: screen?.name ?? ""
readonly property real capsuleHeight: Style.getCapsuleHeightForScreen(screenName)
readonly property string bridgeState: pluginApi?.pluginSettings?.bridgeState ?? "idle"
readonly property string projectLabel: pluginApi?.pluginSettings?.projectLabel ?? "0 sessions"
readonly property int attentionCount: pluginApi?.pluginSettings?.attentionCount ?? 0
readonly property int workingCount: pluginApi?.pluginSettings?.workingCount ?? 0
readonly property int recoveringCount: pluginApi?.pluginSettings?.recoveringCount ?? 0
readonly property int errorCount: pluginApi?.pluginSettings?.errorCount ?? 0
readonly property string glyph: errorCount > 0 ? "!" : bridgeState === "streaming" ? "◒" : recoveringCount > 0 ? "↻" : attentionCount > 0 ? "●" : "●"
readonly property color stateColor: errorCount > 0 ? Color.mError : attentionCount > 0 ? Color.mPrimary : Color.mOnSurface
implicitWidth: content.implicitWidth + Style.marginM * 2
implicitHeight: capsuleHeight
// Keep launch paths configurable for deployments while retaining the local build fallback.
Process {
id: bridgeStartProcess
command: ["systemctl", "--user", "start", "pi-status-bridge.service"]
onExited: function(exitCode) {
if (exitCode === 0)
uiLaunchProcess.running = true
}
}
Process {
id: uiLaunchProcess
command: ["bash", "-c", "ui=\"${PI_STATUS_UI_BINARY:-$HOME/projects/pi-status-bridge/ui/src-tauri/target/release/pi-status-ui}\"; test -x \"$ui\" && exec setsid -f env TMPDIR=/tmp \"$ui\" --toggle >/tmp/pi-status-ui.log 2>&1"]
}
Rectangle {
id: visualCapsule
anchors.centerIn: parent
width: root.implicitWidth
height: root.implicitHeight
radius: Style.radiusL
color: mouseArea.containsMouse ? Color.mHover : Style.capsuleColor
border.color: Style.capsuleBorderColor
border.width: Style.capsuleBorderWidth
RowLayout {
id: content
anchors.centerIn: parent
spacing: Style.marginS
Text { text: root.glyph; color: root.stateColor; font.bold: true }
Text { text: root.projectLabel; color: Color.mOnSurface; elide: Text.ElideRight; Layout.maximumWidth: 160 }
Text { visible: root.attentionCount > 0; text: root.attentionCount; color: root.stateColor; font.bold: true }
}
MouseArea {
id: mouseArea
anchors.fill: parent
hoverEnabled: true
onClicked: bridgeStartProcess.running = true
}
}
}