dhcpcd-qt: Add support for KDE5 Notifications
authorRoy Marples <roy@marples.name>
Sat, 8 Aug 2020 14:44:52 +0000 (15:44 +0100)
committerRoy Marples <roy@marples.name>
Sat, 8 Aug 2020 14:44:52 +0000 (15:44 +0100)
configure
src/dhcpcd-qt/dhcpcd-qt.cpp

index 57b68e53e24f7a34bf58f138bdbc74f2d039a2e9..3a180198351e5fff8cd91bb4aa11aebe6659348a 100755 (executable)
--- a/configure
+++ b/configure
@@ -427,28 +427,35 @@ if [ -z "$WITH_QT" -o "$WITH_QT" != no ]; then
                        exit 1
                fi
        fi
-       if $DHCPCD_QT; then
-               QMAKE_CONFIG="$QMAKE_CONFIG PREFIX=$PREFIX"
-               QMAKE_CONFIG="$QMAKE_CONFIG SYSCONFDIR=$SYSCONFDIR"
-               QMAKE_CONFIG="$QMAKE_CONFIG MANDIR=$MANDIR"
-               if (cd src/dhcpcd-qt; $QMAKE $QMAKE_CONFIG dhcpcd-qt.pro); then
-                       UI="$UI${UI:+ }dhcpcd-qt"
-               else
-                       echo "Failed to configure dhcpcd-qt" >&2
-                       [ -n "$WITH_QT" ] && exit 1
-                       DHCPCD_QT=false
-               fi
-       fi
 fi
 
 NOTIFY="$_NOTIFY"
+if $DHCPCD_QT; then
+       QMAKE_CONFIG="$QMAKE_CONFIG PREFIX=$PREFIX"
+       QMAKE_CONFIG="$QMAKE_CONFIG SYSCONFDIR=$SYSCONFDIR"
+       QMAKE_CONFIG="$QMAKE_CONFIG MANDIR=$MANDIR"
+fi
 if $DHCPCD_QT && [ -z "$NOTIFY" -o "$NOTIFY" = yes ]; then
-       if kde4-config --path lib --locate libkdeui.so >/dev/null 2>&3; then
-               QMAKE_CONFIG="$QMAKE_CONFIG CONFIG+=has_libkdeui"
-               echo "Building dhcpcd-qt with notification support"
-       elif [ "$NOTIFY" = yes ]; then
-               echo "$0: knotify4 not found" >&2
-               exit 1
+       printf "Looking for KDE Notification support ... "
+       QT_KNOTE="QT+=KNotifications"
+       if (cd src/dhcpcd-qt; $QMAKE $QMAKE_CONFIG $QT_KNOTE dhcpcd-qt.pro) 2>>config.log; then
+               QMAKE_CONFIG="$QMAKE_CONFIG $QT_KNOTE DEFINES+=KNOTIFY5"
+               echo "KDE5"
+       elif kde4-config --path lib --locate libkdeui.so >/dev/null 2>&3; then
+               QMAKE_CONFIG="$QMAKE_CONFIG CONFIG+=has_libkdeui DEFINES+=KNOTIFY4"
+               echo "KDE4"
+       else
+               echo "none found"
+               [ "$NOTIFY" = yes ] && exit 1
+       fi
+fi
+if $DHCPCD_QT; then
+       if (cd src/dhcpcd-qt; $QMAKE $QMAKE_CONFIG dhcpcd-qt.pro); then
+               UI="$UI${UI:+ }dhcpcd-qt"
+       else
+               echo "Failed to configure dhcpcd-qt" >&2
+               [ -n "$WITH_QT" ] && exit 1
+               DHCPCD_QT=false
        fi
 fi
 
index 3730c2a9b90604ed85b1a127018f343805c037b4..f4d54a3f222387d142ea6e3575bdf482a95d229b 100644 (file)
 #include "dhcpcd-ifmenu.h"
 #include "dhcpcd-ssidmenu.h"
 
-#ifdef NOTIFY
+
+#if defined(KNOTIFY5)
+#include <KNotification>
+#elif defined(KNOTIFY4)
 #include <knotification.h>
 #endif
 
@@ -538,8 +541,9 @@ void DhcpcdQt::notify(const QString &title, const QString &msg,
     const QString &icon)
 {
 
-#ifdef NOTIFY
+#if defined(KNOTIFY4) || defined(KNOTIFY5)
        KNotification *n = new KNotification("event", this);
+       n->setIconName(icon);
        n->setTitle(title);
        n->setText(msg);
        n->sendEvent();