From 49daa163530ceabc9eaa8911ab96b5f799cfb552 Mon Sep 17 00:00:00 2001 From: Fabien Proriol Date: Sun, 25 May 2025 17:58:09 +0200 Subject: Initial Commit --- src/main.cpp | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 src/main.cpp (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..ca19b05 --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,70 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "applicationmanager.h" +#include "applicationsadaptor.h" +#include "waylandentries.h" +#include "waylandentriesfiltered.h" + +int main(int argc, char *argv[]) +{ + qputenv("QT_IM_MODULE", "qtvirtualkeyboard"); + QDBusConnection bus = QDBusConnection::sessionBus(); + QGuiApplication app(argc, argv); + ApplicationManager manager; + QTimer watchdog; + uint64_t watchdogPeriodUSec; + + QFileInfo volatilapps("/var/volatile/applications"); + if(!volatilapps.exists()) + { + QDir().mkdir("/var/volatile/applications"); + } + + qmlRegisterType("org.kazoe.desktop", 1, 0, "WaylandEntries"); + qmlRegisterType("org.kazoe.desktop", 1, 0, "WaylandEntriesFiltered"); + + if (!bus.isConnected()) { + qWarning("Cannot connect to the D-Bus session bus.\n" + "Please check your system settings and try again.\n"); + return 1; + } + + QQmlApplicationEngine engine; + new ApplicationsAdaptor(&manager); + bus.registerObject("/applications", &manager); + + + bool conres = bus.registerService("org.kazoe.desktop"); + if(!conres) qWarning() << "Can't register dbus service org.kazoe.desktop"; + + KaZoe::StatusNotifierWatcher notifierWatcher; + + engine.rootContext()->setContextProperty("manager", &manager); + engine.loadFromModule("org.kazoe.desktop", "Main"); + + // signal systemd that the app the ready + QTimer::singleShot(0, [] () { + sd_notify(0, "READY=1"); + } + ); + + // setup a timer to refresh the systemd'd watchdog if needed + if (sd_watchdog_enabled(0,&watchdogPeriodUSec) > 0) { + QObject::connect(&watchdog, &QTimer::timeout, [] () { + sd_notify(0, "WATCHDOG=1"); + } + ); + } + // configure the period of the QT timer for a half period of the watchdog timer + watchdog.start(watchdogPeriodUSec / 2000); + return app.exec(); +} -- cgit v1.2.3