summaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorFabien Proriol <fabien.proriol@kazoe.org>2025-05-25 17:58:09 +0200
committerFabien Proriol <fabien.proriol@kazoe.org>2025-05-26 18:01:49 +0200
commit49daa163530ceabc9eaa8911ab96b5f799cfb552 (patch)
tree080d0b31eafd138cd8d47d5c2a52b75d3cfa6f28 /src/main.cpp
Initial Commit
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp70
1 files changed, 70 insertions, 0 deletions
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 <QGuiApplication>
+#include <QQmlApplicationEngine>
+#include <QQmlContext>
+#include <QDBusConnection>
+#include <QIcon>
+#include <QTimer>
+#include <QThread>
+#include <systemd/sd-daemon.h>
+#include <QDir>
+#include <QFileInfo>
+#include <xdgstatusnotifierwatcher.h>
+#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<WaylandEntries>("org.kazoe.desktop", 1, 0, "WaylandEntries");
+ qmlRegisterType<WaylandEntriesFiltered>("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();
+}