Rename to TNCat, add chip chase, G-codes and a Wayland layout
The project is now TNCat, after HEIDENHAIN's TNC controls. Binary, QML module URI, settings path, bundle id and .desktop entry follow; the environment switches are TNCAT_*. Entertainment: a curled steel chip skitters in every minute or two, the cat runs it down and bats it away a few times before sitting back looking pleased. Mood changes flash the matching machine code above its head, G00 for a sprint, G01 for a stroll, M08 while it washes, G28 for a stretch, M30 for a nap. Window handling was split into two layouts. X11 and macOS keep one small window per object, positioned by the app. Wayland gets a screen-filling overlay whose input region is masked down to the cat, since a Wayland client cannot place its own window. Overlay mode is automatic there and available elsewhere via TNCAT_OVERLAY=1. Also adds a ground-line setting so the cat can walk above a softkey row. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
acef398f49
commit
0f1df75a1d
19 files changed
+817
-185
No files matched your search
+24
-69
@@ -1,87 +1,42 @@
|
||||
pragma ComponentBehavior: Bound
|
||||
import QtQuick
|
||||
import Workcat
|
||||
import TNCat
|
||||
|
||||
Window {
|
||||
id: root
|
||||
// Root is not a window: which windows exist depends on the platform.
|
||||
QtObject {
|
||||
id: app
|
||||
|
||||
required property CatController cat
|
||||
required property AppSettings settings
|
||||
|
||||
readonly property var moodNames: ["walking", "running", "sitting", "grooming", "stretching", "sleeping", "loving", "alert"]
|
||||
readonly property real floorY: Screen.desktopAvailableHeight - height
|
||||
|
||||
function openSettings() {
|
||||
settingsLoader.active = true
|
||||
if (settingsLoader.status === Loader.Ready)
|
||||
(settingsLoader.item as SettingsWindow).show()
|
||||
settingsWindow.show()
|
||||
settingsWindow.raise()
|
||||
settingsWindow.requestActivate()
|
||||
}
|
||||
|
||||
width: settings.catSize
|
||||
height: Math.round(settings.catSize * 0.9)
|
||||
x: cat.x
|
||||
y: floorY
|
||||
color: Platform.opaqueBackground ? settings.coat : "transparent"
|
||||
flags: Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint | Qt.Tool
|
||||
| Qt.NoDropShadowWindowHint | Qt.WindowDoesNotAcceptFocus
|
||||
| (Platform.bypassWindowManager ? Qt.X11BypassWindowManagerHint : 0)
|
||||
visible: true
|
||||
title: qsTr("Workcat")
|
||||
|
||||
Component.onCompleted: {
|
||||
cat.screenWidth = Screen.desktopAvailableWidth
|
||||
cat.catWidth = width
|
||||
}
|
||||
onWidthChanged: cat.catWidth = width
|
||||
Screen.onDesktopAvailableWidthChanged: cat.screenWidth = Screen.desktopAvailableWidth
|
||||
|
||||
Cat {
|
||||
id: sprite
|
||||
anchors.fill: parent
|
||||
coat: root.settings.coat
|
||||
facingRight: root.cat.facingRight
|
||||
mood: root.moodNames[root.cat.mood]
|
||||
lifted: root.cat.dragging
|
||||
petted: root.cat.hovered && !root.cat.dragging
|
||||
look: root.cat.look
|
||||
|
||||
Accessible.role: Accessible.Button
|
||||
Accessible.name: qsTr("Workcat")
|
||||
readonly property CatWindow catWindow: CatWindow {
|
||||
cat: app.cat
|
||||
settings: app.settings
|
||||
visible: !Platform.overlayMode
|
||||
onSettingsRequested: app.openSettings()
|
||||
}
|
||||
|
||||
HoverHandler {
|
||||
onHoveredChanged: root.cat.hovered = hovered
|
||||
readonly property ChipWindow chipWindow: ChipWindow {
|
||||
cat: app.cat
|
||||
settings: app.settings
|
||||
visible: !Platform.overlayMode && app.cat.chipVisible
|
||||
}
|
||||
|
||||
DragHandler {
|
||||
target: null
|
||||
onActiveChanged: root.cat.dragging = active
|
||||
onCentroidChanged: {
|
||||
if (active)
|
||||
root.cat.x = Math.max(0, Math.min(root.cat.screenWidth - root.width,
|
||||
root.x + centroid.position.x - centroid.pressPosition.x))
|
||||
}
|
||||
readonly property OverlayWindow overlayWindow: OverlayWindow {
|
||||
cat: app.cat
|
||||
settings: app.settings
|
||||
active: Platform.overlayMode
|
||||
onSettingsRequested: app.openSettings()
|
||||
}
|
||||
|
||||
TapHandler {
|
||||
acceptedButtons: Qt.LeftButton
|
||||
onTapped: root.cat.pet()
|
||||
onDoubleTapped: root.openSettings()
|
||||
}
|
||||
|
||||
TapHandler {
|
||||
acceptedButtons: Qt.RightButton
|
||||
onTapped: root.openSettings()
|
||||
}
|
||||
|
||||
Loader {
|
||||
id: settingsLoader
|
||||
active: false
|
||||
sourceComponent: SettingsWindow {
|
||||
cat: root.cat
|
||||
settings: root.settings
|
||||
onClosing: settingsLoader.active = false
|
||||
}
|
||||
onLoaded: (item as SettingsWindow).show()
|
||||
readonly property SettingsWindow settingsWindow: SettingsWindow {
|
||||
cat: app.cat
|
||||
settings: app.settings
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user