Files
TNCcat/qml/SettingsWindow.qml
T
JulianandClaude Opus 5 acef398f49 Workcat: cute desktop cat, no window closing
Reworks the example into a pure desktop-pet: the cat wanders, sits, grooms,
stretches, dashes and naps, reacts to petting and dragging, and follows the
cursor with its eyes. The window-scanning and Accessibility code is gone.

The cat is drawn from rounded primitives plus Shape paths in a fixed 100x90
design space, so it scales cleanly to any size.

Linux/X11 is the primary target: the tray is optional, Wayland gets a warning,
and WORKCAT_X11_BYPASS / WORKCAT_OPAQUE cover uncooperative window managers.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-10 22:20:35 +02:00

170 lines
5.7 KiB
QML

pragma ComponentBehavior: Bound
import QtQuick
import QtQuick.Controls.Basic
import QtQuick.Layouts
import Workcat
Window {
id: win
required property CatController cat
required property AppSettings settings
readonly property var coats: [
{ name: qsTr("Apricot"), color: "#f4b183" },
{ name: qsTr("Ivory"), color: "#f3ede2" },
{ name: qsTr("Grey"), color: "#a4a6b3" },
{ name: qsTr("Charcoal"), color: "#3c3b46" },
{ name: qsTr("Sage"), color: "#a9bfa0" },
{ name: qsTr("Plum"), color: "#9a7bb0" }
]
width: 440
height: 600
minimumWidth: 380
minimumHeight: 520
title: qsTr("Workcat")
color: "#faf7f2"
flags: Qt.Dialog | Qt.WindowStaysOnTopHint
ColumnLayout {
anchors.fill: parent
anchors.margins: 24
spacing: 18
RowLayout {
Layout.fillWidth: true
spacing: 16
Cat {
Layout.preferredWidth: 110
Layout.preferredHeight: 99
coat: win.settings.coat
mood: "sitting"
petted: previewHover.hovered
HoverHandler { id: previewHover }
}
ColumnLayout {
Layout.fillWidth: true
spacing: 4
Label {
Layout.fillWidth: true
text: qsTr("Workcat")
font.pixelSize: 26
font.bold: true
color: "#2f2a36"
}
Label {
Layout.fillWidth: true
wrapMode: Text.WordWrap
text: qsTr("A little cat that wanders along the bottom of your screen. Drag it around, pet it with a click, and it will purr.")
color: "#7a7484"
}
}
}
GroupBox {
Layout.fillWidth: true
title: qsTr("Coat")
Flow {
anchors.fill: parent
spacing: 10
Repeater {
model: win.coats
Column {
id: swatch
required property var modelData
readonly property bool selected: Qt.colorEqual(win.settings.coat, modelData.color)
spacing: 4
Rectangle {
width: 40; height: 40
radius: 20
color: swatch.modelData.color
border.width: swatch.selected ? 3 : 1
border.color: swatch.selected ? "#f25f7a" : "#d8d2ca"
antialiasing: true
Accessible.role: Accessible.RadioButton
Accessible.name: swatch.modelData.name
Accessible.checked: swatch.selected
activeFocusOnTab: true
Keys.onSpacePressed: win.settings.coat = swatch.modelData.color
TapHandler { onTapped: win.settings.coat = swatch.modelData.color }
}
Label {
anchors.horizontalCenter: parent.horizontalCenter
text: swatch.modelData.name
font.pixelSize: 11
color: "#7a7484"
}
}
}
}
}
GridLayout {
Layout.fillWidth: true
columns: 2
columnSpacing: 14
rowSpacing: 12
Label { text: qsTr("Size") }
Slider {
Layout.fillWidth: true
from: 72; to: 260; stepSize: 4
value: win.settings.catSize
onMoved: win.settings.catSize = value
}
Label { text: qsTr("Pace") }
Slider {
Layout.fillWidth: true
from: 10; to: 200; stepSize: 5
value: win.settings.walkSpeed
onMoved: win.settings.walkSpeed = value
}
Label { text: qsTr("Eyes") }
Switch {
text: qsTr("Follow the mouse")
checked: win.settings.followCursor
onToggled: win.settings.followCursor = checked
}
Label { text: qsTr("Cat") }
Switch {
text: checked ? qsTr("Napping") : qsTr("Awake")
checked: win.cat.paused
onToggled: win.cat.paused = checked
}
}
GroupBox {
Layout.fillWidth: true
title: qsTr("Tricks")
Flow {
anchors.fill: parent
spacing: 8
Button { text: qsTr("Sit"); onClicked: win.cat.doTrick(CatController.Sitting) }
Button { text: qsTr("Groom"); onClicked: win.cat.doTrick(CatController.Grooming) }
Button { text: qsTr("Stretch"); onClicked: win.cat.doTrick(CatController.Stretching) }
Button { text: qsTr("Dash"); onClicked: win.cat.doTrick(CatController.Running) }
Button { text: qsTr("Nap"); onClicked: win.cat.doTrick(CatController.Sleeping) }
}
}
Item { Layout.fillHeight: true }
RowLayout {
Layout.fillWidth: true
Label {
Layout.fillWidth: true
text: qsTr("%n pet(s) so far.", "", win.settings.petCount)
color: "#7a7484"
}
Button {
text: qsTr("Quit")
onClicked: Qt.quit()
}
}
}
}