[PATCH 2/2] wpa_gui-qt4: tray icon based signal strength meter

Arkadiusz Arkq Bokowy arkadiusz.bokowy
Sun Apr 19 10:41:45 PDT 2015


Hi,

This patch should fix the issue with not loaded icons on the Ubuntu.
I've checked which icons are available on the vanilla Ubuntu 14.04,
e.g. there is no "network-wireless-offline" icon...

Anyway, I've tested it on the virtual box only. For my daily basis
work I'm using pretty much customized Linux box, so it was the reason
why I've missed this issue, for which I'm very sorry.

Best Regards,
Arek

[PATCH] wpa_gui: Themed icon loader

Signal strength meter uses non-standard icons (not included in the
freedesktop icon specification), which might not be available in all
icon sets on the market. What's more, according to the latest Ubuntu
practices, in the status-like places one should use symbolic icons.
Unfortunately not all icon sets provide them.

In order to overcome this inconsistency, we are going to try to load
more than one icon from the current theme in the fallback-like
fashion.
---
 wpa_supplicant/wpa_gui-qt4/wpagui.cpp | 54 +++++++++++++++++++++++------------
 wpa_supplicant/wpa_gui-qt4/wpagui.h   |  2 ++
 2 files changed, 38 insertions(+), 18 deletions(-)

diff --git a/wpa_supplicant/wpa_gui-qt4/wpagui.cpp b/wpa_supplicant/wpa_gui-qt4/wpagui.cpp
index 408e387..d2d76f1 100644
--- a/wpa_supplicant/wpa_gui-qt4/wpagui.cpp
+++ b/wpa_supplicant/wpa_gui-qt4/wpagui.cpp
@@ -1503,8 +1503,8 @@ void WpaGui::updateTrayIcon(TrayIconType type)
 	if (!tray_icon || currentIconType == type)
 		return;
 
-	QIcon icon;
 	QIcon fallback_icon;
+	QStringList names;
 
 	if (QImageReader::supportedImageFormats().contains(QByteArray("svg")))
 		fallback_icon = QIcon(":/icons/wpa_gui.svg");
@@ -1513,41 +1513,59 @@ void WpaGui::updateTrayIcon(TrayIconType type)
 
 	switch (type) {
 	case TrayIconOffline:
-		icon = QIcon::fromTheme("network-wireless-offline",
-					fallback_icon);
+		names << "network-wireless-offline-symbolic"
+		      << "network-wireless-offline"
+		      << "network-wireless-signal-none-symbolic"
+		      << "network-wireless-signal-none";
 		break;
 	case TrayIconAcquiring:
-		icon = QIcon::fromTheme("network-wireless-acquiring",
-					fallback_icon);
+		names << "network-wireless-acquiring-symbolic"
+		      << "network-wireless-acquiring";
 		break;
 	case TrayIconConnected:
-		icon = QIcon::fromTheme("network-wireless-connected",
-					fallback_icon);
+		names << "network-wireless-connected-symbolic"
+		      << "network-wireless-connected";
 		break;
 	case TrayIconSignalNone:
-		icon = QIcon::fromTheme("network-wireless-signal-none",
-					fallback_icon);
+		names << "network-wireless-signal-none-symbolic"
+		      << "network-wireless-signal-none";
 		break;
 	case TrayIconSignalWeak:
-		icon = QIcon::fromTheme("network-wireless-signal-weak",
-					fallback_icon);
+		names << "network-wireless-signal-weak-symbolic"
+		      << "network-wireless-signal-weak";
 		break;
 	case TrayIconSignalOk:
-		icon = QIcon::fromTheme("network-wireless-signal-ok",
-					fallback_icon);
+		names << "network-wireless-signal-ok-symbolic"
+		      << "network-wireless-signal-ok";
 		break;
 	case TrayIconSignalGood:
-		icon = QIcon::fromTheme("network-wireless-signal-good",
-					fallback_icon);
+		names << "network-wireless-signal-good-symbolic"
+		      << "network-wireless-signal-good";
 		break;
 	case TrayIconSignalExcellent:
-		icon = QIcon::fromTheme("network-wireless-signal-excellent",
-					fallback_icon);
+		names << "network-wireless-signal-excellent-symbolic"
+		      << "network-wireless-signal-excellent";
 		break;
 	}
 
 	currentIconType = type;
-	tray_icon->setIcon(icon);
+	tray_icon->setIcon(loadThemedIcon(names, fallback_icon));
+}
+
+
+QIcon WpaGui::loadThemedIcon(const QStringList &names,
+			     const QIcon &fallback)
+{
+	QIcon icon;
+
+	for (QStringList::ConstIterator it = names.begin();
+	     it != names.end(); it++) {
+		icon = QIcon::fromTheme(*it);
+		if (!icon.isNull())
+			return icon;
+	}
+
+	return fallback;
 }
 
 
diff --git a/wpa_supplicant/wpa_gui-qt4/wpagui.h b/wpa_supplicant/wpa_gui-qt4/wpagui.h
index c0de67b..58c655d 100644
--- a/wpa_supplicant/wpa_gui-qt4/wpagui.h
+++ b/wpa_supplicant/wpa_gui-qt4/wpagui.h
@@ -85,6 +85,8 @@ public slots:
 	virtual void showTrayStatus();
 	virtual void updateTrayIcon(TrayIconType type);
 	virtual void updateTrayToolTip(const QString &msg);
+	virtual QIcon loadThemedIcon(const QStringList &names,
+				     const QIcon &fallback);
 	virtual void wpsDialog();
 	virtual void peersDialog();
 	virtual void tabChanged(int index);
-- 
2.0.5



More information about the Hostap mailing list