Split the bar panel into one QML file per stage

Panel.qml keeps the state, the CLI calls and the stage switch (889 lines,
was 2360); each stage is its own file taking the panel as a required
property. The omarchy installer copies every QML/JS file and clears stale
ones. tests/static.sh filters qmllint on [syntax], not the word error.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
smoido
2026-09-15 02:12:49 +03:00
co-authored by Claude Opus 5
parent 4091746d4e
commit bb01418ce0
17 changed files with 1717 additions and 1510 deletions
+162
View File
@@ -0,0 +1,162 @@
import QtQuick
import qs.Commons
import qs.Ui
// PresetStage.qml - One preset: its tier map, each row opening a picker.
//
// One stage of the claude-mode panel. Panel.qml hands itself in as `panel`
// and owns all the state and actions; this file only draws them.
Column {
id: stage
required property var panel
width: parent.width
visible: stage.panel.stage === "preset" && stage.panel.editPreset !== ""
spacing: Style.space(6)
Text {
width: parent.width
text: "'" + stage.panel.editPreset + "' · " + stage.panel.pTitle(stage.panel.editProvider)
color: Color.popups.text
elide: Text.ElideRight
font.family: stage.panel.uiFont
font.pixelSize: Style.space(13)
font.bold: true
}
Text {
width: parent.width
visible: text !== ""
text: stage.panel.editEntry && stage.panel.editEntry.description ? String(stage.panel.editEntry.description) : ""
color: Color.muted
wrapMode: Text.WordWrap
font.family: stage.panel.uiFont
font.pixelSize: Style.space(10)
}
Text {
width: parent.width
visible: stage.panel.editIsActive
text: "In use now. A change is applied straight away and reaches sessions started after it."
color: Color.accent
wrapMode: Text.WordWrap
font.family: stage.panel.uiFont
font.pixelSize: Style.space(10)
}
Text {
width: parent.width
visible: stage.panel.editIsDefault
text: "claude-mode " + stage.panel.editProvider + " picks this one when no preset is named"
+ (stage.panel.editIsChosenDefault ? "." : " (the built-in choice).")
color: Color.muted
wrapMode: Text.WordWrap
font.family: stage.panel.uiFont
font.pixelSize: Style.space(10)
}
Column {
width: parent.width
spacing: Style.space(1)
Repeater {
model: stage.panel.stage === "preset" ? stage.panel.tierNames : []
Item {
id: tierRow
required property var modelData
readonly property string tier: String(modelData)
readonly property string current: stage.panel.editCurrent(tier)
width: stage.width
height: Style.space(26)
Rectangle {
anchors.fill: parent
anchors.leftMargin: -Style.space(6)
anchors.rightMargin: -Style.space(6)
radius: Style.space(4)
color: tierArea.containsMouse
? Qt.rgba(Color.accent.r, Color.accent.g, Color.accent.b, 0.14)
: "transparent"
}
Text {
anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter
text: tierRow.tier
color: Color.muted
font.family: stage.panel.uiFont
font.pixelSize: Style.space(11)
}
Text {
anchors.left: parent.left
anchors.leftMargin: Style.space(54)
anchors.right: tierChevron.left
anchors.rightMargin: Style.space(6)
anchors.verticalCenter: parent.verticalCenter
horizontalAlignment: Text.AlignRight
text: tierRow.current !== "" ? tierRow.current : "not set"
color: tierRow.current !== "" ? Color.popups.text : Color.muted
elide: Text.ElideLeft
font.family: stage.panel.uiFont
font.pixelSize: Style.space(11)
}
Text {
id: tierChevron
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
text: String.fromCodePoint(0xF0142)
color: tierArea.containsMouse ? Color.accent : Color.muted
font.family: stage.panel.uiFont
font.pixelSize: Style.font.body
}
MouseArea {
id: tierArea
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
enabled: !stage.panel.busy
onClicked: stage.panel.openTierEditor(tierRow.tier)
}
}
}
}
// Flow, not Row: these can total more than the card is wide, and a
// Row lays them straight past its right edge instead of wrapping.
Flow {
width: parent.width
spacing: Style.space(7)
PillButton { fontFamily: stage.panel.uiFont;
label: "Server settings…"
visible: stage.panel.serverEditable(stage.panel.editProvider)
onTriggered: stage.panel.openServerSettings(stage.panel.editPreset, "preset")
}
PillButton { fontFamily: stage.panel.uiFont; label: "Make default"; visible: !stage.panel.editIsDefault; onTriggered: stage.panel.setDefault(true) }
PillButton { fontFamily: stage.panel.uiFont; label: "Clear default"; visible: stage.panel.editIsChosenDefault; onTriggered: stage.panel.setDefault(false) }
PillButton { fontFamily: stage.panel.uiFont; label: "Duplicate…"; onTriggered: stage.panel.openNewPreset(stage.panel.editProvider, stage.panel.editPreset) }
PillButton { fontFamily: stage.panel.uiFont; label: "Rename…"; onTriggered: stage.panel.openRename() }
// The CLI refuses to delete the preset in use. A button that always
// fails would be worse than one that says why it is off.
PillButton { fontFamily: stage.panel.uiFont;
label: "Delete…"
enabled: !stage.panel.editIsActive
onTriggered: { stage.panel.lastError = ""; stage.panel.stage = "presetDelete" }
}
PillButton { fontFamily: stage.panel.uiFont; label: "Done"; primary: true; onTriggered: stage.panel.resetFlow() }
}
Text {
width: parent.width
visible: stage.panel.editIsActive
text: "In use, so it cannot be deleted. Switch to another preset first."
color: Color.muted
wrapMode: Text.WordWrap
font.family: stage.panel.uiFont
font.pixelSize: Style.space(9)
}
}