diff options
| author | Roy Marples <roy@marples.name> | 2017-10-21 04:56:37 +0100 |
|---|---|---|
| committer | Roy Marples <roy@marples.name> | 2017-10-21 04:56:37 +0100 |
| commit | 03789633486277c4ff8a83d63fa636e5f5f88050 (patch) | |
| tree | 31b87846c1bd55b94df5bb49029885e7135de8e0 | |
| parent | b7298bde47c726b9cd91e21abc46698ab236fa3d (diff) | |
| download | dhcpcd-ui-03789633486277c4ff8a83d63fa636e5f5f88050.tar.xz | |
Use an icon if using >=Qt-5.9 in notificaions.
| -rw-r--r-- | src/dhcpcd-qt/dhcpcd-qt.cpp | 35 | ||||
| -rw-r--r-- | src/dhcpcd-qt/dhcpcd-qt.h | 4 |
2 files changed, 22 insertions, 17 deletions
diff --git a/src/dhcpcd-qt/dhcpcd-qt.cpp b/src/dhcpcd-qt/dhcpcd-qt.cpp index 7a27123..98c2a05 100644 --- a/src/dhcpcd-qt/dhcpcd-qt.cpp +++ b/src/dhcpcd-qt/dhcpcd-qt.cpp @@ -318,11 +318,16 @@ void DhcpcdQt::ifCallback(DHCPCD_IF *i) 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 icon; + + if (i->up) + icon = "network-transmit-receive"; + //else + // icon = "network-transmit"; + if (!i->up) + icon = "network-offline"; 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())) - notify(title, txt); + notify(title, txt, "network-wireless"); if (wi->setScans(scans) && ssidMenu && ssidMenu->isVisible()) ssidMenu->popup(ssidMenuPos); @@ -525,13 +530,8 @@ void DhcpcdQt::dispatch() 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 @@ -540,10 +540,15 @@ void DhcpcdQt::notify(QString &title, QString &msg, 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 } diff --git a/src/dhcpcd-qt/dhcpcd-qt.h b/src/dhcpcd-qt/dhcpcd-qt.h index 366ad25..56384f7 100644 --- a/src/dhcpcd-qt/dhcpcd-qt.h +++ b/src/dhcpcd-qt/dhcpcd-qt.h @@ -126,8 +126,8 @@ private: 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 |
