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>
80 lines
2.3 KiB
QML
80 lines
2.3 KiB
QML
pragma ComponentBehavior: Bound
|
|
import QtQuick
|
|
import TNCat
|
|
|
|
// One small window that is exactly the cat. Used wherever a client may place
|
|
// its own window, which is everything except Wayland.
|
|
Window {
|
|
id: win
|
|
|
|
required property CatController cat
|
|
required property AppSettings settings
|
|
|
|
signal settingsRequested()
|
|
|
|
width: settings.catSize
|
|
height: Math.round(settings.catSize * 0.9)
|
|
x: cat.x
|
|
y: Screen.desktopAvailableHeight - height - settings.bottomMargin
|
|
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("TNCat")
|
|
|
|
Component.onCompleted: {
|
|
cat.stageWidth = Screen.desktopAvailableWidth
|
|
cat.catWidth = width
|
|
}
|
|
onWidthChanged: cat.catWidth = width
|
|
Screen.onDesktopAvailableWidthChanged: cat.stageWidth = Screen.desktopAvailableWidth
|
|
|
|
// The eyes need to know where the face sits on the desktop.
|
|
Binding {
|
|
target: win.cat
|
|
property: "catCenter"
|
|
value: Qt.point(win.x + win.width / 2, win.y + win.height / 2)
|
|
}
|
|
|
|
Cat {
|
|
anchors.fill: parent
|
|
coat: win.settings.coat
|
|
facingRight: win.cat.facingRight
|
|
mood: CatMoods.name(win.cat.mood)
|
|
lifted: win.cat.dragging
|
|
petted: win.cat.hovered && !win.cat.dragging
|
|
look: win.cat.look
|
|
showCodes: win.settings.showCodes
|
|
|
|
Accessible.role: Accessible.Button
|
|
Accessible.name: qsTr("TNCat")
|
|
}
|
|
|
|
HoverHandler {
|
|
onHoveredChanged: win.cat.hovered = hovered
|
|
}
|
|
|
|
DragHandler {
|
|
target: null
|
|
onActiveChanged: win.cat.dragging = active
|
|
onCentroidChanged: {
|
|
if (active)
|
|
win.cat.x = Math.max(0, Math.min(win.cat.stageWidth - win.width,
|
|
win.x + centroid.position.x - centroid.pressPosition.x))
|
|
}
|
|
}
|
|
|
|
TapHandler {
|
|
acceptedButtons: Qt.LeftButton
|
|
onTapped: win.cat.pet()
|
|
onDoubleTapped: win.settingsRequested()
|
|
onLongPressed: win.settingsRequested()
|
|
}
|
|
|
|
TapHandler {
|
|
acceptedButtons: Qt.RightButton
|
|
onTapped: win.settingsRequested()
|
|
}
|
|
}
|