Drop Qt Quick Controls and Qt Widgets
The binary now links Core, Gui, Quick and QuickShapes, nothing else. Qt Widgets was there for one reason, QSystemTrayIcon, so the tray icon is gone and QApplication is back to QGuiApplication. The cat itself is the whole interface: right-click or long-press opens the settings window, which carries the tricks and a quit button. Ctrl+C in the terminal works as well. The settings window is rebuilt from Qt Quick primitives. AppButton, AppSlider, AppToggle and SettingsGroup replace the Controls types, keyboard handling and accessible roles included, and a Flickable with plain positioners replaces QtQuick.Layouts. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f6ecf0ddbf
commit
1581a760be
10 files changed
+540
-294
No files matched your search
+245
-165
@@ -1,9 +1,8 @@
|
||||
pragma ComponentBehavior: Bound
|
||||
import QtQuick
|
||||
import QtQuick.Controls.Basic
|
||||
import QtQuick.Layouts
|
||||
import TNCat
|
||||
|
||||
// Plain Qt Quick: no Controls, no Widgets, no Layouts.
|
||||
Window {
|
||||
id: win
|
||||
|
||||
@@ -18,194 +17,275 @@ Window {
|
||||
{ name: qsTr("Sage"), color: "#a9bfa0" },
|
||||
{ name: qsTr("Plum"), color: "#9a7bb0" }
|
||||
]
|
||||
readonly property real margin: 22
|
||||
readonly property real labelWidth: 96
|
||||
|
||||
width: 440
|
||||
height: 700
|
||||
// Tall enough for the whole panel, but never taller than the screen; the
|
||||
// Flickable takes over when it has to be shorter.
|
||||
height: Math.min(830, Screen.desktopAvailableHeight - 60)
|
||||
minimumWidth: 380
|
||||
minimumHeight: 600
|
||||
minimumHeight: 420
|
||||
title: qsTr("TNCat")
|
||||
color: "#faf7f2"
|
||||
flags: Qt.Dialog | Qt.WindowStaysOnTopHint
|
||||
flags: Qt.Dialog
|
||||
|
||||
ColumnLayout {
|
||||
Flickable {
|
||||
id: flick
|
||||
anchors.fill: parent
|
||||
anchors.margins: 24
|
||||
spacing: 18
|
||||
contentWidth: width
|
||||
contentHeight: content.implicitHeight + win.margin * 2
|
||||
boundsBehavior: Flickable.StopAtBounds
|
||||
|
||||
RowLayout {
|
||||
Layout.fillWidth: true
|
||||
Column {
|
||||
id: content
|
||||
x: win.margin
|
||||
y: win.margin
|
||||
width: flick.width - win.margin * 2
|
||||
spacing: 16
|
||||
Loader {
|
||||
Layout.preferredWidth: 110
|
||||
Layout.preferredHeight: Math.round(110 * CatDefs.aspect)
|
||||
active: win.visible
|
||||
sourceComponent: Cat {
|
||||
coat: win.settings.coat
|
||||
mood: "sitting"
|
||||
showCodes: false
|
||||
petted: previewHover.hovered
|
||||
HoverHandler { id: previewHover }
|
||||
}
|
||||
}
|
||||
ColumnLayout {
|
||||
Layout.fillWidth: true
|
||||
spacing: 4
|
||||
Label {
|
||||
Layout.fillWidth: true
|
||||
text: qsTr("TNCat")
|
||||
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"
|
||||
// header
|
||||
Item {
|
||||
width: parent.width
|
||||
height: Math.max(96, headerText.implicitHeight)
|
||||
|
||||
Loader {
|
||||
id: preview
|
||||
width: 106
|
||||
height: Math.round(106 * CatDefs.aspect)
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
active: win.visible
|
||||
sourceComponent: Cat {
|
||||
coat: win.settings.coat
|
||||
mood: "sitting"
|
||||
showCodes: false
|
||||
petted: previewHover.hovered
|
||||
HoverHandler { id: previewHover }
|
||||
}
|
||||
}
|
||||
|
||||
Column {
|
||||
id: headerText
|
||||
anchors.left: preview.right
|
||||
anchors.leftMargin: 14
|
||||
anchors.right: parent.right
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
spacing: 4
|
||||
|
||||
Text {
|
||||
text: qsTr("TNCat")
|
||||
font.pixelSize: 26
|
||||
font.bold: true
|
||||
color: "#2f2a36"
|
||||
}
|
||||
Text {
|
||||
width: headerText.width
|
||||
wrapMode: Text.WordWrap
|
||||
text: qsTr("A little cat that wanders along the bottom of your screen. Click to pet it, drag it somewhere else.")
|
||||
color: "#7a7484"
|
||||
font.pixelSize: 12
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SettingsGroup {
|
||||
width: parent.width
|
||||
title: qsTr("COAT")
|
||||
|
||||
Flow {
|
||||
width: parent.width
|
||||
spacing: 12
|
||||
|
||||
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
|
||||
activeFocusOnTab: true
|
||||
|
||||
Accessible.role: Accessible.RadioButton
|
||||
Accessible.name: swatch.modelData.name
|
||||
Accessible.checked: swatch.selected
|
||||
Accessible.onPressAction: win.settings.coat = swatch.modelData.color
|
||||
|
||||
TapHandler { onTapped: win.settings.coat = swatch.modelData.color }
|
||||
Keys.onSpacePressed: win.settings.coat = swatch.modelData.color
|
||||
}
|
||||
|
||||
Text {
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
text: swatch.modelData.name
|
||||
font.pixelSize: 11
|
||||
color: "#7a7484"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GridLayout {
|
||||
Layout.fillWidth: true
|
||||
columns: 2
|
||||
columnSpacing: 14
|
||||
rowSpacing: 12
|
||||
SettingsGroup {
|
||||
width: parent.width
|
||||
title: qsTr("THE CAT")
|
||||
spacing: 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("Ground line") }
|
||||
RowLayout {
|
||||
Layout.fillWidth: true
|
||||
Slider {
|
||||
id: marginSlider
|
||||
Layout.fillWidth: true
|
||||
from: 0; to: 600; stepSize: 10
|
||||
value: win.settings.bottomMargin
|
||||
onMoved: win.settings.bottomMargin = value
|
||||
Item {
|
||||
width: parent.width
|
||||
height: 26
|
||||
Text {
|
||||
id: sizeLabel
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
width: win.labelWidth
|
||||
text: qsTr("Size")
|
||||
color: "#2f2a36"
|
||||
font.pixelSize: 13
|
||||
}
|
||||
AppSlider {
|
||||
anchors.left: sizeLabel.right
|
||||
anchors.right: parent.right
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
from: 72; to: 260; stepSize: 4
|
||||
value: win.settings.catSize
|
||||
suffix: qsTr("px")
|
||||
onMoved: function(v) { win.settings.catSize = v }
|
||||
}
|
||||
}
|
||||
Label {
|
||||
Layout.preferredWidth: 54
|
||||
text: qsTr("%1 px").arg(Math.round(marginSlider.value))
|
||||
|
||||
Item {
|
||||
width: parent.width
|
||||
height: 26
|
||||
Text {
|
||||
id: paceLabel
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
width: win.labelWidth
|
||||
text: qsTr("Pace")
|
||||
color: "#2f2a36"
|
||||
font.pixelSize: 13
|
||||
}
|
||||
AppSlider {
|
||||
anchors.left: paceLabel.right
|
||||
anchors.right: parent.right
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
from: 10; to: 200; stepSize: 5
|
||||
value: win.settings.walkSpeed
|
||||
onMoved: function(v) { win.settings.walkSpeed = v }
|
||||
}
|
||||
}
|
||||
|
||||
Item {
|
||||
width: parent.width
|
||||
height: 26
|
||||
Text {
|
||||
id: groundLabel
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
width: win.labelWidth
|
||||
text: qsTr("Ground line")
|
||||
color: "#2f2a36"
|
||||
font.pixelSize: 13
|
||||
}
|
||||
AppSlider {
|
||||
anchors.left: groundLabel.right
|
||||
anchors.right: parent.right
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
from: 0; to: 600; stepSize: 10
|
||||
value: win.settings.bottomMargin
|
||||
suffix: qsTr("px")
|
||||
onMoved: function(v) { win.settings.bottomMargin = v }
|
||||
}
|
||||
}
|
||||
|
||||
Text {
|
||||
width: parent.width
|
||||
wrapMode: Text.WordWrap
|
||||
text: qsTr("The ground line lifts the cat off the bottom edge, so it can walk above a taskbar or a row of softkeys.")
|
||||
color: "#9b95a3"
|
||||
font.pixelSize: 11
|
||||
}
|
||||
}
|
||||
|
||||
Label { text: qsTr("Eyes") }
|
||||
Switch {
|
||||
text: qsTr("Follow the mouse")
|
||||
checked: win.settings.followCursor
|
||||
onToggled: win.settings.followCursor = checked
|
||||
SettingsGroup {
|
||||
width: parent.width
|
||||
title: qsTr("HABITS")
|
||||
spacing: 12
|
||||
|
||||
AppToggle {
|
||||
width: parent.width
|
||||
checked: win.settings.followCursor
|
||||
text: qsTr("Follow the mouse with its eyes")
|
||||
onToggled: function(v) { win.settings.followCursor = v }
|
||||
}
|
||||
AppToggle {
|
||||
width: parent.width
|
||||
checked: win.settings.showCodes
|
||||
text: qsTr("Announce what it does in G-code")
|
||||
onToggled: function(v) { win.settings.showCodes = v }
|
||||
}
|
||||
AppToggle {
|
||||
width: parent.width
|
||||
checked: win.settings.chipsEnabled
|
||||
text: qsTr("Chase a chip now and then")
|
||||
onToggled: function(v) { win.settings.chipsEnabled = v }
|
||||
}
|
||||
AppToggle {
|
||||
width: parent.width
|
||||
checked: win.settings.coffeeEnabled
|
||||
text: qsTr("Stop for coffee now and then")
|
||||
onToggled: function(v) { win.settings.coffeeEnabled = v }
|
||||
}
|
||||
AppToggle {
|
||||
width: parent.width
|
||||
checked: win.cat.paused
|
||||
text: win.cat.paused ? qsTr("Napping, nothing will wake it") : qsTr("Awake and on the move")
|
||||
onToggled: function(v) { win.cat.paused = v }
|
||||
}
|
||||
}
|
||||
|
||||
Label { text: qsTr("Codes") }
|
||||
Switch {
|
||||
text: qsTr("Show G-code above the cat")
|
||||
checked: win.settings.showCodes
|
||||
onToggled: win.settings.showCodes = checked
|
||||
SettingsGroup {
|
||||
width: parent.width
|
||||
title: qsTr("TRICKS")
|
||||
|
||||
Flow {
|
||||
width: parent.width
|
||||
spacing: 8
|
||||
|
||||
AppButton { text: qsTr("Sit"); onClicked: win.cat.doTrick(CatController.Sitting) }
|
||||
AppButton { text: qsTr("Groom"); onClicked: win.cat.doTrick(CatController.Grooming) }
|
||||
AppButton { text: qsTr("Stretch"); onClicked: win.cat.doTrick(CatController.Stretching) }
|
||||
AppButton { text: qsTr("Dash"); onClicked: win.cat.doTrick(CatController.Running) }
|
||||
AppButton { text: qsTr("Nap"); onClicked: win.cat.doTrick(CatController.Sleeping) }
|
||||
AppButton { text: qsTr("Chip"); onClicked: win.cat.tossChip() }
|
||||
AppButton { text: qsTr("Coffee"); onClicked: win.cat.coffeeBreak() }
|
||||
}
|
||||
}
|
||||
|
||||
Label { text: qsTr("Chips") }
|
||||
Switch {
|
||||
text: qsTr("Let a chip skitter past now and then")
|
||||
checked: win.settings.chipsEnabled
|
||||
onToggled: win.settings.chipsEnabled = checked
|
||||
}
|
||||
Item {
|
||||
width: parent.width
|
||||
height: 34
|
||||
|
||||
Label { text: qsTr("Coffee") }
|
||||
Switch {
|
||||
text: qsTr("Take a coffee break now and then")
|
||||
checked: win.settings.coffeeEnabled
|
||||
onToggled: win.settings.coffeeEnabled = 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) }
|
||||
Button { text: qsTr("Toss a chip"); onClicked: win.cat.tossChip() }
|
||||
Button { text: qsTr("Coffee"); onClicked: win.cat.coffeeBreak() }
|
||||
}
|
||||
}
|
||||
|
||||
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()
|
||||
Text {
|
||||
anchors.left: parent.left
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
text: qsTr("%n pet(s) so far.", "", win.settings.petCount)
|
||||
color: "#7a7484"
|
||||
font.pixelSize: 12
|
||||
}
|
||||
AppButton {
|
||||
anchors.right: parent.right
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
text: qsTr("Quit")
|
||||
onClicked: Qt.quit()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user