From 984683b6c0639f51040b4ad238183cd2b0e95776 Mon Sep 17 00:00:00 2001
From: "Haelwenn (lanodan) Monnier" <contact@hacktivis.me>
Date: Sat, 13 Jun 2020 06:49:18 +0200
Subject: [PATCH 1/2] Make DBus optionnal

---
 Qarma.cpp | 4 ++++
 qarma.pro | 7 ++++++-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/Qarma.cpp b/Qarma.cpp
index bc746f8..69e5b20 100644
--- a/Qarma.cpp
+++ b/Qarma.cpp
@@ -26,9 +26,11 @@
 #include <QComboBox>
 #include <QCryptographicHash>
 #include <QDate>
+#ifdef DBUS_ENABLED
 #include <QDBusConnection>
 #include <QDBusConnectionInterface>
 #include <QDBusInterface>
+#endif
 #include <QDialogButtonBox>
 #include <QEvent>
 #include <QFileDialog>
@@ -1150,6 +1152,7 @@ char Qarma::showList(const QStringList &args)
 
 void Qarma::notify(const QString message, bool noClose)
 {
+#ifdef DBUS_ENABLED
     if (QDBusConnection::sessionBus().interface()->isServiceRegistered("org.freedesktop.Notifications")) {
         QDBusInterface notifications("org.freedesktop.Notifications", "/org/freedesktop/Notifications", "org.freedesktop.Notifications");
         const QString summary = (message.length() < 32) ? message : message.left(25) + "...";
@@ -1181,6 +1184,7 @@ void Qarma::notify(const QString message, bool noClose)
     SHOW_DIALOG
     dlg->adjustSize();
     dlg->move(QGuiApplication::screens().at(0)->availableGeometry().topRight() - QPoint(dlg->width() + 20, -20));
+#endif
 }
 
 char Qarma::showNotification(const QStringList &args)
diff --git a/qarma.pro b/qarma.pro
index 8cb4d2a..c904d66 100644
--- a/qarma.pro
+++ b/qarma.pro
@@ -1,11 +1,16 @@
 HEADERS = Qarma.h
 SOURCES = Qarma.cpp
-QT      += dbus gui widgets
+QT      += gui widgets
 lessThan(QT_MAJOR_VERSION, 6){
   unix:!macx:QT += x11extras
 }
 TARGET  = qarma
 
+!DISABLE_DBUS {
+	DEFINES += DBUS_ENABLED
+	QT += dbus
+}
+
 unix:!macx:LIBS    += -lX11
 unix:!macx:DEFINES += WS_X11
 
-- 
2.52.0

