* Add Tailscale header on/off toggle * Address Tailscale toggle review feedback * Hide Tailscale tooltip while busy * Keep Tailscale labels clear of header toggle * Extract the switch from Toggle into a reusable ToggleSwitch Toggle rendered its own track and knob inline, so anything else wanting a switch had to copy the geometry. Pull it into Ui/ToggleSwitch.qml and let Toggle compose it, and give PanelHero a trailingControl slot so a hero can pin a control to its trailing edge without the caller doing the layout. The switch draws its cursor as a ring outside the track: themes give normal chrome a stronger border than hover-cursor, which is right for controls that are borderless at rest but would make a bordered track go fainter under the cursor. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * Keep the panel cursor on the virtual header section clampCursor resets focusSection whenever it is not in visibleSections, but "header" is virtual and never appears there. Any refresh of the underlying model therefore threw the cursor off the hero toggle: muting republishes the PipeWire snapshot, and toggling the Bluetooth adapter empties and refills the device lists. moveCursor already special-cases "header"; clampCursor now does too. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * Toggle panel heroes with a switch instead of the status icon The hero icon doubled as the on/off control, which was invisible as an affordance and made the icon carry two jobs at once. Give Tailscale, Dropbox, Bluetooth, Audio, and Network a ToggleSwitch on the trailing edge of the hero and leave the icon to report status. The switch is the header's only cursor target, so the keyboard reaches it the same way the mouse does. Dropping the icon's focus ring also drops heroRingPad, which lets each hero line up with the rows beneath it. Network's link detail moves inline after the name -- "Ethernet (2.5gbit)" -- since the pill crowded the switch. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * Make the network hero switch honestly a Wi-Fi switch The switch reads and writes Networking.wifiEnabled, but its tooltip claimed to turn "network" on and off whenever Ethernet was the active connection. A click asserted nothing; a switch asserts state, so on a wired machine with the radio off it sat there reading "off" beside a perfectly live Ethernet connection. Say Wi-Fi, and only offer the switch when there is a radio to switch. headerActionCount follows the same condition so the keyboard cannot reach a control that is not there. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * Stop the header cursor claiming an absent switch The switch hides when the thing it toggles is unavailable -- no Tailscale CLI, no Dropbox CLI, no Wi-Fi radio -- but "header" stayed reachable, so the cursor could sit on a target that never rendered. The old clickable icon was always on screen, so there was always something to highlight. "header" stays navigable and Enter still no-ops safely; the cursor just stops claiming a spot that is not there. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * Wrap the gallery's switch caption The caption sat unbounded inside the switch row. The gallery has a 560px minimum width, horizontal scrolling off, and clipping on, so at that size the end of the line was simply unreachable. Move it below the row and wrap it, the way every other description in the gallery already does. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: David Heinemeier Hansson <david@hey.com> Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
116 lines
3.6 KiB
QML
116 lines
3.6 KiB
QML
import QtQuick
|
|
import qs.Commons
|
|
|
|
// Labeled toggle row: title + optional description on the left, a
|
|
// `ToggleSwitch` on the right. Clicking anywhere on the row emits `clicked()`;
|
|
// consumers flip `checked` in response (the component is stateless about the
|
|
// actual value so it composes cleanly with model-driven UI).
|
|
//
|
|
// Cursor and focus styling match the rest of the kit: hasCursor / mouse
|
|
// hover and activeFocus share the hover-cursor defaults.
|
|
//
|
|
// `rounded` is forwarded to the switch, which auto-detects from
|
|
// Style.cornerRadius: pill shape when Hyprland corners are rounded, square on
|
|
// sharp. Callers can override per-instance.
|
|
BorderSurface {
|
|
id: root
|
|
|
|
property string label: ""
|
|
property string description: ""
|
|
property bool checked: false
|
|
|
|
// Panel-cursor flag. Same role as Button.hasCursor:
|
|
// panels with their own keyboard cursor bind this to drive the highlight
|
|
// separately from activeFocus. Visuals use the same hover-cursor tokens.
|
|
property bool hasCursor: false
|
|
|
|
// Switch shape follows the theme by default: pill on round, square on sharp.
|
|
// Override per-instance if a caller wants the opposite.
|
|
property bool rounded: Style.cornerRadius > 0
|
|
|
|
property color foreground: Color.foreground
|
|
property color accent: Color.accent
|
|
property string fontFamily: Style.font.family
|
|
property real titleSize: Style.font.subtitle
|
|
property real descriptionSize: Style.font.caption
|
|
|
|
signal clicked()
|
|
signal hovered(bool isHovered)
|
|
|
|
activeFocusOnTab: true
|
|
Keys.onReturnPressed: root.clicked()
|
|
Keys.onEnterPressed: root.clicked()
|
|
Keys.onSpacePressed: root.clicked()
|
|
|
|
implicitHeight: Math.max(54, content.implicitHeight + Style.spacing.huge)
|
|
implicitWidth: Style.space(240)
|
|
radius: Style.cornerRadius
|
|
|
|
readonly property bool _hot: hasCursor || mouse.containsMouse
|
|
readonly property var _borderSpec: Border.controlSpec(activeFocus ? "focus" : (_hot ? "hover-cursor" : "normal"), foreground, accent)
|
|
|
|
color: Style.controlFill(activeFocus, _hot, foreground, accent)
|
|
borderSpec: _borderSpec
|
|
|
|
Behavior on color { ColorAnimation { duration: 100 } }
|
|
|
|
Row {
|
|
id: content
|
|
anchors.left: parent.left
|
|
anchors.right: parent.right
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
anchors.leftMargin: root.borderLeft + Style.spacing.rowPaddingX
|
|
anchors.rightMargin: root.borderRight + Style.spacing.rowPaddingX
|
|
spacing: Style.spacing.rowPaddingX
|
|
|
|
Column {
|
|
width: parent.width - track.width - parent.spacing
|
|
spacing: Style.spacing.xs
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
Text {
|
|
text: root.label
|
|
color: root.foreground
|
|
font.family: root.fontFamily
|
|
font.pixelSize: root.titleSize
|
|
font.bold: true
|
|
elide: Text.ElideRight
|
|
width: parent.width
|
|
}
|
|
|
|
Text {
|
|
visible: root.description !== ""
|
|
text: root.description
|
|
color: Qt.darker(root.foreground, 1.5)
|
|
font.family: root.fontFamily
|
|
font.pixelSize: root.descriptionSize
|
|
wrapMode: Text.WordWrap
|
|
width: parent.width
|
|
}
|
|
}
|
|
|
|
// The row owns the click, so the switch is presentation only here.
|
|
ToggleSwitch {
|
|
id: track
|
|
checked: root.checked
|
|
rounded: root.rounded
|
|
foreground: root.foreground
|
|
accent: root.accent
|
|
interactive: false
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
}
|
|
}
|
|
|
|
MouseArea {
|
|
id: mouse
|
|
anchors.fill: parent
|
|
hoverEnabled: true
|
|
cursorShape: Qt.PointingHandCursor
|
|
onClicked: root.clicked()
|
|
}
|
|
|
|
HoverHandler {
|
|
onHoveredChanged: root.hovered(hovered)
|
|
}
|
|
}
|