* 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>
540 lines
16 KiB
QML
540 lines
16 KiB
QML
import QtQuick
|
|
import QtQuick.Controls
|
|
import QtQuick.Layouts
|
|
import Quickshell
|
|
import Quickshell.Io
|
|
import qs.Commons
|
|
import qs.Ui
|
|
import "Model.js" as Model
|
|
|
|
Panel {
|
|
id: root
|
|
moduleName: "omarchy.dropbox"
|
|
ipcTarget: "omarchy.dropbox"
|
|
manageIpc: false
|
|
|
|
property string omarchyPath: Quickshell.env("OMARCHY_PATH")
|
|
property string focusSection: "login"
|
|
property int fileIndex: 0
|
|
property bool cursorActive: false
|
|
property int phraseIndex: 0
|
|
|
|
readonly property var activePhrases: [
|
|
"Filing files",
|
|
"Distributing data",
|
|
"Shuffling folders",
|
|
"Boxing bytes",
|
|
"Sorting stuff",
|
|
"Syncing secrets",
|
|
"Packing packets",
|
|
"Moving memories",
|
|
"Wrangling revisions",
|
|
"Cataloging chaos"
|
|
]
|
|
readonly property string heroPhraseText: activePhrases[phraseIndex % activePhrases.length]
|
|
readonly property color foreground: bar ? bar.foreground : Color.foreground
|
|
readonly property color urgent: bar ? bar.urgent : Color.urgent
|
|
readonly property color dim: Qt.darker(foreground, 1.55)
|
|
readonly property string fontFamily: bar ? bar.fontFamily : Style.font.family
|
|
readonly property color iconColor: dropbox.authenticated && dropbox.active ? foreground : dim
|
|
readonly property string toggleHint: dropbox.active ? "Pause syncing" : "Resume syncing"
|
|
readonly property color barIconColor: dropbox.authenticated && dropbox.active ? barForeground : Qt.darker(barForeground, 1.55)
|
|
// Only claim the header cursor when the switch is actually on screen —
|
|
// "header" stays navigable, but an absent CLI leaves nothing to highlight.
|
|
readonly property bool headerHasCursor: cursorActive && focusSection === "header" && dropbox.installed
|
|
|
|
function ensureCursor() {
|
|
if (!dropbox.authenticated) {
|
|
focusSection = "login"
|
|
fileIndex = 0
|
|
return
|
|
}
|
|
if (dropbox.files.length === 0) {
|
|
focusSection = "header"
|
|
fileIndex = 0
|
|
return
|
|
}
|
|
if (focusSection !== "files" && focusSection !== "header") focusSection = "files"
|
|
if (fileIndex >= dropbox.files.length) fileIndex = Math.max(0, dropbox.files.length - 1)
|
|
if (fileIndex < 0) fileIndex = 0
|
|
}
|
|
|
|
function moveCursor(dx, dy) {
|
|
cursorActive = true
|
|
ensureCursor()
|
|
if (dy === 0) return
|
|
if (focusSection === "header") {
|
|
if (dy > 0 && dropbox.files.length > 0) {
|
|
focusSection = "files"
|
|
fileIndex = 0
|
|
scrollCursorIntoView()
|
|
}
|
|
return
|
|
}
|
|
if (focusSection === "files") {
|
|
if (dy < 0 && fileIndex === 0) {
|
|
setHeaderCursor()
|
|
return
|
|
}
|
|
fileIndex = Math.max(0, Math.min(dropbox.files.length - 1, fileIndex + dy))
|
|
scrollCursorIntoView()
|
|
}
|
|
}
|
|
|
|
function setHeaderCursor() {
|
|
cursorActive = true
|
|
focusSection = "header"
|
|
if (panelFlick) panelFlick.contentY = 0
|
|
}
|
|
|
|
function toggleRunning() {
|
|
if (dropbox.installed && !dropbox.busy) dropbox.toggleRunning()
|
|
}
|
|
|
|
function activateCursor() {
|
|
ensureCursor()
|
|
if (focusSection === "login") dropbox.login()
|
|
else if (focusSection === "header") toggleRunning()
|
|
else if (focusSection === "files") dropbox.openFile(selectedFile())
|
|
}
|
|
|
|
function selectedFile() {
|
|
if (dropbox.files.length === 0) return null
|
|
return dropbox.files[Math.max(0, Math.min(fileIndex, dropbox.files.length - 1))]
|
|
}
|
|
|
|
function setFileCursor(index) {
|
|
cursorActive = true
|
|
focusSection = "files"
|
|
fileIndex = index
|
|
scrollCursorIntoView()
|
|
}
|
|
|
|
function scrollItemIntoView(item) {
|
|
if (!panelFlick || !item) return
|
|
Qt.callLater(function() {
|
|
if (!item) return
|
|
var margin = Style.space(6)
|
|
var point = item.mapToItem(panelFlick.contentItem, 0, 0)
|
|
var top = point.y
|
|
var bottom = top + item.height
|
|
var viewTop = panelFlick.contentY
|
|
var viewBottom = viewTop + panelFlick.height
|
|
var maxY = Math.max(0, panelFlick.contentHeight - panelFlick.height)
|
|
if (top < viewTop + margin) panelFlick.contentY = Math.max(0, top - margin)
|
|
else if (bottom > viewBottom - margin) panelFlick.contentY = Math.min(maxY, bottom + margin - panelFlick.height)
|
|
})
|
|
}
|
|
|
|
function scrollCursorIntoView() {
|
|
if (focusSection === "files" && fileColumn && fileIndex >= 0 && fileIndex < fileColumn.children.length) {
|
|
scrollItemIntoView(fileColumn.children[fileIndex])
|
|
}
|
|
}
|
|
|
|
implicitWidth: button.implicitWidth
|
|
implicitHeight: button.implicitHeight
|
|
|
|
onOpenedChanged: if (opened) {
|
|
cursorActive = false
|
|
if (panelFlick) panelFlick.contentY = 0
|
|
dropbox.refresh()
|
|
Qt.callLater(function() { keyCatcher.forceActiveFocus() })
|
|
}
|
|
onFileIndexChanged: scrollCursorIntoView()
|
|
|
|
Service {
|
|
id: dropbox
|
|
settings: root.settings
|
|
omarchyPath: root.omarchyPath
|
|
}
|
|
|
|
Connections {
|
|
target: dropbox
|
|
function onAuthenticatedChanged() { root.ensureCursor() }
|
|
function onFilesChanged() { root.ensureCursor() }
|
|
}
|
|
|
|
IpcHandler {
|
|
target: root.ipcTarget
|
|
function open(): void { root.open() }
|
|
function close(): void { root.close() }
|
|
function show(): void { root.open() }
|
|
function hide(): void { root.close() }
|
|
function toggle(): void { root.toggle() }
|
|
function refresh(): string { dropbox.refresh(); return "ok" }
|
|
function login(): string { dropbox.login(); return "ok" }
|
|
function status(): string { return dropbox.statusText }
|
|
}
|
|
|
|
BarIconButton {
|
|
id: button
|
|
anchors.fill: parent
|
|
bar: root.bar
|
|
iconComponent: Component {
|
|
Item {
|
|
DropboxIcon {
|
|
anchors.centerIn: parent
|
|
iconSize: Style.space(12)
|
|
color: root.barIconColor
|
|
opacity: dropbox.active ? 1.0 : 0.6
|
|
}
|
|
}
|
|
}
|
|
onPressed: function(buttonCode) {
|
|
if (buttonCode === Qt.RightButton) dropbox.refresh()
|
|
else if (buttonCode === Qt.MiddleButton) dropbox.login()
|
|
else root.toggle()
|
|
}
|
|
}
|
|
|
|
KeyboardPanel {
|
|
id: panel
|
|
anchorItem: button
|
|
owner: root
|
|
bar: root.bar
|
|
open: root.opened
|
|
focusTarget: keyCatcher
|
|
contentWidth: panel.fittedContentWidth(Style.space(380))
|
|
contentHeight: panel.fittedContentHeight(column.implicitHeight, Style.space(560))
|
|
|
|
PanelKeyCatcher {
|
|
id: keyCatcher
|
|
anchors.fill: parent
|
|
onMoveRequested: function(dx, dy) {
|
|
if (!root.cursorActive) { root.cursorActive = true; return }
|
|
root.moveCursor(dx, dy)
|
|
}
|
|
onActivateRequested: if (root.cursorActive) root.activateCursor()
|
|
onCloseRequested: root.close()
|
|
onTabRequested: function(direction) { root.switchPanel(direction) }
|
|
onTextKey: function(t) {
|
|
if (t === "r" || t === "R") dropbox.refresh()
|
|
else if (t === "l" || t === "L") dropbox.login()
|
|
else if (t === "p" || t === "P") root.toggleRunning()
|
|
}
|
|
|
|
Flickable {
|
|
id: panelFlick
|
|
anchors.fill: parent
|
|
contentWidth: width
|
|
contentHeight: column.implicitHeight
|
|
clip: true
|
|
boundsBehavior: Flickable.StopAtBounds
|
|
flickableDirection: Flickable.VerticalFlick
|
|
interactive: contentHeight > height
|
|
ScrollBar.vertical: ScrollBar { policy: ScrollBar.AsNeeded }
|
|
|
|
Column {
|
|
id: column
|
|
width: panelFlick.width
|
|
spacing: Style.space(12)
|
|
|
|
Item {
|
|
id: header
|
|
visible: dropbox.authenticated
|
|
width: parent.width
|
|
implicitHeight: hero.implicitHeight
|
|
// Exposed for the hero's trailingControl, whose `root` resolves to
|
|
// PanelHero (not this Panel) — reach panel state via `header`.
|
|
readonly property bool ringVisible: root.headerHasCursor
|
|
function focusHero() { root.setHeaderCursor() }
|
|
|
|
PanelHero {
|
|
id: hero
|
|
width: parent.width
|
|
title: "Dropbox"
|
|
meta: dropbox.active ? root.heroPhraseText : "Syncing paused"
|
|
foreground: root.foreground
|
|
fontFamily: root.fontFamily
|
|
iconOpacity: dropbox.active ? 1.0 : 0.5
|
|
// Status only — the switch owns toggling, mouse and keyboard alike.
|
|
iconComponent: Component {
|
|
DropboxIcon {
|
|
iconSize: Style.font.display
|
|
color: root.iconColor
|
|
}
|
|
}
|
|
|
|
// Compact on/off switch on the trailing edge of the hero, and the
|
|
// header's only cursor target. The service already flips `active`
|
|
// optimistically, so the knob throws the instant you click it.
|
|
trailingControl: Component {
|
|
ToggleSwitch {
|
|
id: powerSwitch
|
|
visible: dropbox.installed
|
|
checked: dropbox.active
|
|
busy: dropbox.busy
|
|
hasCursor: header.ringVisible
|
|
foreground: hero.foreground
|
|
onHovered: function(on) { if (on) header.focusHero() }
|
|
onToggled: root.toggleRunning()
|
|
|
|
PanelToolTip {
|
|
visible: powerSwitch.containsMouse
|
|
text: root.toggleHint
|
|
fontFamily: hero.fontFamily
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
Text {
|
|
visible: dropbox.actionStatus !== "" || dropbox.lastError !== ""
|
|
width: parent.width
|
|
text: dropbox.actionStatus !== "" ? dropbox.actionStatus : dropbox.lastError
|
|
color: dropbox.lastError !== "" && dropbox.actionStatus === "" ? root.urgent : root.dim
|
|
font.family: root.fontFamily
|
|
font.pixelSize: Style.font.bodySmall
|
|
wrapMode: Text.WordWrap
|
|
}
|
|
|
|
LoginButton {
|
|
visible: !dropbox.authenticated
|
|
width: parent.width
|
|
}
|
|
|
|
Column {
|
|
visible: dropbox.authenticated
|
|
width: parent.width
|
|
spacing: Style.spacing.labelGap
|
|
|
|
Column {
|
|
width: parent.width
|
|
spacing: Style.spacing.labelGap
|
|
InfoPair { label: "Stored"; value: Model.usageText(dropbox.usedBytes, dropbox.quotaBytes, dropbox.quotaKnown) }
|
|
}
|
|
}
|
|
|
|
PanelSeparator {
|
|
visible: dropbox.authenticated
|
|
foreground: root.foreground
|
|
}
|
|
|
|
Column {
|
|
visible: dropbox.authenticated
|
|
width: parent.width
|
|
spacing: Style.space(10)
|
|
|
|
PanelSectionHeader {
|
|
text: "RECENT FILES"
|
|
foreground: root.foreground
|
|
fontFamily: root.fontFamily
|
|
}
|
|
|
|
Text {
|
|
visible: dropbox.files.length === 0
|
|
width: parent.width
|
|
text: "No synced files found."
|
|
color: root.dim
|
|
font.family: root.fontFamily
|
|
font.pixelSize: Style.font.body
|
|
horizontalAlignment: Text.AlignHCenter
|
|
}
|
|
|
|
Column {
|
|
id: fileColumn
|
|
visible: dropbox.files.length > 0
|
|
width: parent.width
|
|
spacing: Style.space(6)
|
|
|
|
Repeater {
|
|
model: dropbox.files
|
|
FileRow {
|
|
required property var modelData
|
|
required property int index
|
|
width: fileColumn.width
|
|
file: modelData
|
|
rowIndex: index
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
Timer {
|
|
id: phraseTimer
|
|
interval: 2800
|
|
running: root.opened && dropbox.authenticated && dropbox.active
|
|
repeat: true
|
|
onTriggered: phraseSwap.restart()
|
|
}
|
|
|
|
SequentialAnimation {
|
|
id: phraseSwap
|
|
PropertyAnimation {
|
|
target: hero; property: "metaOpacity"
|
|
to: 0.0; duration: 180; easing.type: Easing.OutQuad
|
|
}
|
|
ScriptAction {
|
|
script: root.phraseIndex = (root.phraseIndex + 1) % root.activePhrases.length
|
|
}
|
|
PropertyAnimation {
|
|
target: hero; property: "metaOpacity"
|
|
to: 1.0; duration: 260; easing.type: Easing.InQuad
|
|
}
|
|
}
|
|
|
|
component LoginButton: CursorSurface {
|
|
id: loginButton
|
|
|
|
hasCursor: root.cursorActive && root.focusSection === "login"
|
|
foreground: root.foreground
|
|
|
|
implicitHeight: loginRow.implicitHeight + Style.spacing.rowPaddingX
|
|
|
|
MouseArea {
|
|
anchors.fill: parent
|
|
hoverEnabled: true
|
|
cursorShape: dropbox.installed && !dropbox.busy ? Qt.PointingHandCursor : Qt.ArrowCursor
|
|
enabled: dropbox.installed && !dropbox.busy
|
|
onEntered: {
|
|
root.cursorActive = true
|
|
root.focusSection = "login"
|
|
}
|
|
onClicked: dropbox.login()
|
|
}
|
|
|
|
RowLayout {
|
|
id: loginRow
|
|
anchors.left: parent.left
|
|
anchors.right: parent.right
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
anchors.leftMargin: Style.space(10)
|
|
anchors.rightMargin: Style.space(10)
|
|
spacing: Style.space(8)
|
|
|
|
Text {
|
|
text: ""
|
|
color: root.foreground
|
|
font.family: root.fontFamily
|
|
font.pixelSize: Style.font.heading
|
|
Layout.alignment: Qt.AlignVCenter
|
|
}
|
|
|
|
ColumnLayout {
|
|
Layout.fillWidth: true
|
|
spacing: Style.space(1)
|
|
|
|
Text {
|
|
Layout.fillWidth: true
|
|
text: dropbox.installed ? "Login to Dropbox" : "Dropbox CLI is not installed"
|
|
color: root.foreground
|
|
font.family: root.fontFamily
|
|
font.pixelSize: Style.font.body
|
|
elide: Text.ElideRight
|
|
}
|
|
|
|
Text {
|
|
Layout.fillWidth: true
|
|
text: dropbox.installed ? "Start the authentication flow" : "Install Dropbox from the service menu"
|
|
color: root.dim
|
|
font.family: root.fontFamily
|
|
font.pixelSize: Style.font.caption
|
|
elide: Text.ElideRight
|
|
}
|
|
}
|
|
|
|
PanelActionButton {
|
|
iconText: ""
|
|
foreground: root.foreground
|
|
fontFamily: root.fontFamily
|
|
enabled: dropbox.installed && !dropbox.busy
|
|
Layout.alignment: Qt.AlignVCenter
|
|
onClicked: dropbox.login()
|
|
}
|
|
}
|
|
}
|
|
|
|
component FileRow: CursorSurface {
|
|
id: fileRow
|
|
property var file: null
|
|
property int rowIndex: 0
|
|
readonly property string fileName: file ? String(file.name || "Untitled") : "Untitled"
|
|
|
|
hasCursor: root.cursorActive && root.focusSection === "files" && root.fileIndex === rowIndex
|
|
foreground: root.foreground
|
|
|
|
implicitHeight: fileContent.implicitHeight + Style.spacing.rowPaddingX
|
|
|
|
MouseArea {
|
|
anchors.fill: parent
|
|
hoverEnabled: true
|
|
cursorShape: Qt.PointingHandCursor
|
|
onEntered: root.setFileCursor(fileRow.rowIndex)
|
|
onClicked: dropbox.openFile(fileRow.file)
|
|
}
|
|
|
|
RowLayout {
|
|
anchors.left: parent.left
|
|
anchors.right: parent.right
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
anchors.leftMargin: Style.space(10)
|
|
anchors.rightMargin: Style.space(10)
|
|
spacing: Style.space(8)
|
|
|
|
Text {
|
|
text: Model.fileGlyph(fileRow.fileName)
|
|
color: root.foreground
|
|
font.family: root.fontFamily
|
|
font.pixelSize: Style.font.icon
|
|
Layout.alignment: Qt.AlignVCenter
|
|
}
|
|
|
|
ColumnLayout {
|
|
id: fileContent
|
|
Layout.fillWidth: true
|
|
spacing: Style.space(1)
|
|
|
|
Text {
|
|
Layout.fillWidth: true
|
|
text: fileRow.fileName
|
|
color: root.foreground
|
|
font.family: root.fontFamily
|
|
font.pixelSize: Style.font.body
|
|
elide: Text.ElideRight
|
|
}
|
|
|
|
Text {
|
|
Layout.fillWidth: true
|
|
text: Model.fileMeta(fileRow.file)
|
|
color: root.dim
|
|
font.family: root.fontFamily
|
|
font.pixelSize: Style.font.caption
|
|
elide: Text.ElideRight
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
component InfoPair: Row {
|
|
property string label: ""
|
|
property string value: ""
|
|
|
|
width: parent.width
|
|
spacing: Style.space(8)
|
|
|
|
InfoLabel { text: label }
|
|
Item { width: Math.max(0, parent.width - parent.children[0].implicitWidth - parent.children[2].implicitWidth - parent.spacing * 2); height: 1 }
|
|
InfoValue { text: value }
|
|
}
|
|
|
|
component InfoLabel: Text {
|
|
color: root.foreground
|
|
opacity: 0.6
|
|
font.family: root.fontFamily
|
|
font.pixelSize: Style.font.bodySmall
|
|
}
|
|
|
|
component InfoValue: Text {
|
|
color: root.foreground
|
|
font.family: root.fontFamily
|
|
font.pixelSize: Style.font.bodySmall
|
|
elide: Text.ElideRight
|
|
}
|
|
}
|