mirror of
https://github.com/vanhoefm/fragattacks.git
synced 2024-11-25 00:38:24 -05:00
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. Signed-off-by: Arkadiusz Bokowy <arkadiusz.bokowy@gmail.com>
This commit is contained in:
parent
9a3cb4133d
commit
eaa3728a64
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user