Use an icon if using >=Qt-5.9 in notificaions.
authorRoy Marples <roy@marples.name>
Sat, 21 Oct 2017 03:56:37 +0000 (04:56 +0100)
committerRoy Marples <roy@marples.name>
Sat, 21 Oct 2017 03:56:37 +0000 (04:56 +0100)
src/dhcpcd-qt/dhcpcd-qt.cpp
src/dhcpcd-qt/dhcpcd-qt.h

index 7a2712341d9435074a4cdd63c772e6e3bfd42d7c..98c2a050b35ec771a9d8e69113f87338966c668a 100644 (file)
@@ -318,11 +318,16 @@ void DhcpcdQt::ifCallback(DHCPCD_IF *i)
                if (msg) {
                        qDebug("%s", msg);
                        if (new_msg) {
                if (msg) {
                        qDebug("%s", msg);
                        if (new_msg) {
-                               QSystemTrayIcon::MessageIcon icon =
-                                   i->up ? QSystemTrayIcon::Information :
-                                   QSystemTrayIcon::Warning;
                                QString t = tr("Network Event");
                                QString m = msg;
                                QString t = tr("Network Event");
                                QString m = msg;
+                               QString icon;
+
+                               if (i->up)
+                                       icon = "network-transmit-receive";
+                               //else
+                               //      icon = "network-transmit";
+                               if (!i->up)
+                                       icon = "network-offline";
                                notify(t, m, icon);
                        }
                        free(msg);
                                notify(t, m, icon);
                        }
                        free(msg);
@@ -382,7 +387,7 @@ void DhcpcdQt::processScans(DhcpcdWi *wi, DHCPCD_WI_SCAN *scans)
        }
        if (!txt.isEmpty() &&
            (ssidMenu == NULL || !ssidMenu->isVisible()))
        }
        if (!txt.isEmpty() &&
            (ssidMenu == NULL || !ssidMenu->isVisible()))
-               notify(title, txt);
+               notify(title, txt, "network-wireless");
 
        if (wi->setScans(scans) && ssidMenu && ssidMenu->isVisible())
                ssidMenu->popup(ssidMenuPos);
 
        if (wi->setScans(scans) && ssidMenu && ssidMenu->isVisible())
                ssidMenu->popup(ssidMenuPos);
@@ -525,13 +530,8 @@ void DhcpcdQt::dispatch()
        dhcpcd_dispatch(con);
 }
 
        dhcpcd_dispatch(con);
 }
 
-void DhcpcdQt::notify(QString &title, QString &msg,
-#ifdef NOTIFY
-    QSystemTrayIcon::MessageIcon
-#else
-    QSystemTrayIcon::MessageIcon icon
-#endif
-    )
+void DhcpcdQt::notify(const QString &title, const QString &msg,
+    const QString &icon)
 {
 
 #ifdef NOTIFY
 {
 
 #ifdef NOTIFY
@@ -540,10 +540,15 @@ void DhcpcdQt::notify(QString &title, QString &msg,
        n->setText(msg);
        n->sendEvent();
 #else
        n->setText(msg);
        n->sendEvent();
 #else
-       Q_UNUSED(title);
-       Q_UNUSED(msg);
-       Q_UNUSED(icon);
-       //trayIcon->showMessage(title, msg, icon);
+#if QT_VERSION >= QT_VERSION_CHECK(5, 9, 0)
+       const QIcon i = getIcon("status", icon);
+#else
+       QSystemTrayIcon::MessageIcon i = QSystemTrayIcon::Information;
+
+       if (icon.compare("network-offline") == 0)
+               i = QSystemTrayIcon::Warning;
+#endif
+       trayIcon->showMessage(title, msg, i);
 #endif
 }
 
 #endif
 }
 
index 366ad2577a71951abb9b3cec877a74ecfb2b69cb..56384f72e852d05ec1ae22fd52b73a147fc191fb 100644 (file)
@@ -126,8 +126,8 @@ private:
        QMenu *ssidMenu;
        QPoint ssidMenuPos;
 
        QMenu *ssidMenu;
        QPoint ssidMenuPos;
 
-       void notify(QString &title, QString &msg,
-           QSystemTrayIcon::MessageIcon icon = QSystemTrayIcon::Information);
+       void notify(const QString &title, const QString &msg,
+           const QString &icon);
 };
 
 #endif
 };
 
 #endif