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>
This commit is contained in:
JulianandClaude Opus 5 committed 2026-09-10 22:20:35 +02:00
commit acef398f49
17 files changed
+1584

No files matched your search

+47
View File
@@ -0,0 +1,47 @@
#include <QApplication>
#include <QQmlApplicationEngine>
#include <QQuickStyle>
#include <QQuickWindow>
#include <QLoggingCategory>
#include "appsettings.h"
#include "catcontroller.h"
#include "traycontroller.h"
int main(int argc, char *argv[])
{
QCoreApplication::setOrganizationName("workcat");
QCoreApplication::setOrganizationDomain("workcat.app");
QCoreApplication::setApplicationName("Workcat");
QApplication::setQuitOnLastWindowClosed(false);
// QApplication (not QGuiApplication) so QSystemTrayIcon can show a menu.
QApplication app(argc, argv);
QQuickStyle::setStyle("Basic");
AppSettings settings;
CatController cat(&settings);
TrayController tray(&cat);
if (QGuiApplication::platformName().startsWith(QLatin1String("wayland"))) {
qWarning("Workcat: Wayland does not let a client place its own window. "
"Run with QT_QPA_PLATFORM=xcb for the cat to walk.");
}
QQmlApplicationEngine engine;
engine.setInitialProperties({
{ "cat", QVariant::fromValue(&cat) },
{ "settings", QVariant::fromValue(&settings) },
});
QObject::connect(&engine, &QQmlApplicationEngine::objectCreationFailed, &app,
[] { QCoreApplication::exit(1); }, Qt::QueuedConnection);
engine.loadFromModule("Workcat", "Main");
if (auto *root = qobject_cast<QQuickWindow *>(engine.rootObjects().value(0))) {
cat.setWindow(root);
QObject::connect(&tray, &TrayController::settingsRequested, root,
[root] { QMetaObject::invokeMethod(root, "openSettings"); });
}
return app.exec();
}