Skip to content
Permalink
Browse files

design: Use *-symbolic incons only in *Views

  • Loading branch information...
palinek committed Jun 5, 2019
1 parent 01585a6 commit ecbe243339cc4a89dbaf3c37362cd0d963e0a22d
Showing with 21 additions and 21 deletions.
  1. +15 −15 src/icons.cpp
  2. +1 −1 src/icons.h
  3. +1 −1 src/main.cpp
  4. +2 −2 src/nmmodel.cpp
  5. +2 −2 src/tray.cpp
@@ -23,66 +23,66 @@ COPYRIGHT_HEADER*/
#include "icons.h"

#include <QStringList>
#include <QDebug>
#include <QStringBuilder>

namespace icons
{
QIcon getIcon(Icon ico)
QIcon getIcon(Icon ico, bool useSymbolic)
{
static const QStringList i_empty;
QStringList const * icon_names = &i_empty;
switch (ico)
{
case NETWORK_OFFLINE:
static const QStringList i_network_offline = { QStringLiteral("network-offline-symbolic") };
static const QStringList i_network_offline = { QStringLiteral("network-offline") };
icon_names = &i_network_offline;
break;
case NETWORK_WIRED:
static const QStringList i_network_wired = { QStringLiteral("network-wired-symbolic") };
static const QStringList i_network_wired = { QStringLiteral("network-wired") };
icon_names = &i_network_wired;
break;
case NETWORK_WIRED_DISCONNECTED:
static const QStringList i_network_wired_disconnected = { QStringLiteral("network-wired-disconnected-symbolic") };
static const QStringList i_network_wired_disconnected = { QStringLiteral("network-wired-disconnected") };
icon_names = &i_network_wired_disconnected;
break;
case NETWORK_WIFI_DISCONNECTED:
static const QStringList i_wifi_disconnected = { QStringLiteral("network-wireless-disconnected-symbolic") };
static const QStringList i_wifi_disconnected = { QStringLiteral("network-wireless-disconnected") };
icon_names = &i_wifi_disconnected;
break;
case NETWORK_WIFI_ACQUIRING:
static const QStringList i_wifi_acquiring = { QStringLiteral("network-wireless-acquiring-symbolic") };
static const QStringList i_wifi_acquiring = { QStringLiteral("network-wireless-acquiring") };
icon_names = &i_wifi_acquiring;
break;
case NETWORK_WIFI_NONE:
static const QStringList i_wifi_none = { QStringLiteral("network-wireless-signal-none-symbolic"), QStringLiteral("network-wireless-connected-00-symbolic") };
static const QStringList i_wifi_none = { QStringLiteral("network-wireless-signal-none"), QStringLiteral("network-wireless-connected-00") };
icon_names = &i_wifi_none;
break;
case NETWORK_WIFI_WEAK:
static const QStringList i_wifi_weak = { QStringLiteral("network-wireless-signal-weak-symbolic"), QStringLiteral("network-wireless-connected-25-symbolic") };
static const QStringList i_wifi_weak = { QStringLiteral("network-wireless-signal-weak"), QStringLiteral("network-wireless-connected-25") };
icon_names = &i_wifi_weak;
break;
case NETWORK_WIFI_OK:
static const QStringList i_wifi_ok = { QStringLiteral("network-wireless-signal-ok-symbolic"), QStringLiteral("network-wireless-connected-50-symbolic") };
static const QStringList i_wifi_ok = { QStringLiteral("network-wireless-signal-ok"), QStringLiteral("network-wireless-connected-50") };
icon_names = &i_wifi_ok;
break;
case NETWORK_WIFI_GOOD:
static const QStringList i_wifi_good = { QStringLiteral("network-wireless-signal-good-symbolic"), QStringLiteral("network-wireless-connected-75-symbolic") };
static const QStringList i_wifi_good = { QStringLiteral("network-wireless-signal-good"), QStringLiteral("network-wireless-connected-75") };
icon_names = &i_wifi_good;
break;
case NETWORK_WIFI_EXCELENT:
static const QStringList i_wifi_excelent = { QStringLiteral("network-wireless-signal-excellent-symbolic"), QStringLiteral("network-wireless-connected-100-symbolic") };
static const QStringList i_wifi_excelent = { QStringLiteral("network-wireless-signal-excellent"), QStringLiteral("network-wireless-connected-100") };
icon_names = &i_wifi_excelent;
break;
case NETWORK_VPN:
static const QStringList i_network_vpn = { QStringLiteral("network-vpn") };
icon_names = &i_network_vpn;
break;
case SECURITY_LOW:
static const QStringList i_security_low = { QStringLiteral("security-low-symbolic") };
static const QStringList i_security_low = { QStringLiteral("security-low") };
icon_names = &i_security_low;
break;
case SECURITY_HIGH:
static const QStringList i_security_high = { QStringLiteral("security-high-symbolic") };
static const QStringList i_security_high = { QStringLiteral("security-high") };
icon_names = &i_security_high;
break;
case PREFERENCES_NETWORK:
@@ -92,7 +92,7 @@ namespace icons
};
for (auto const & name : *icon_names)
{
QIcon icon{QIcon::fromTheme(name)};
QIcon icon{QIcon::fromTheme(useSymbolic ? name % QStringLiteral("-symbolic") : name)};
if (!icon.isNull())
return icon;
}
@@ -46,7 +46,7 @@ namespace icons
, PREFERENCES_NETWORK
};

QIcon getIcon(Icon ico);
QIcon getIcon(Icon ico, bool useSymbolic);
Icon wifiSignalIcon(const int signal);
}

@@ -31,7 +31,7 @@ int main(int argc, char * argv[])
QApplication app{argc, argv};
app.setOrganizationName(QStringLiteral("nm-tray"));
app.setApplicationName(QStringLiteral("nm-tray"));
app.setWindowIcon(icons::getIcon(icons::PREFERENCES_NETWORK));
app.setWindowIcon(icons::getIcon(icons::PREFERENCES_NETWORK, true));
app.setQuitOnLastWindowClosed(false);

Tray tray;
@@ -909,7 +909,7 @@ QVariant NmModel::dataRole<NmModel::IconSecurityRole>(const QModelIndex & index)
{
const auto type = dataRole<IconSecurityTypeRole>(index).toInt();
if (0 <= type)
return icons::getIcon(static_cast<icons::Icon>(type));
return icons::getIcon(static_cast<icons::Icon>(type), true);
else
return QVariant{};
}
@@ -1258,7 +1258,7 @@ QVariant NmModel::dataRole<NmModel::IconTypeRole>(const QModelIndex & index) con
template <>
QVariant NmModel::dataRole<NmModel::IconRole>(const QModelIndex & index) const
{
return icons::getIcon(static_cast<icons::Icon>(dataRole<IconTypeRole>(index).toInt()));
return icons::getIcon(static_cast<icons::Icon>(dataRole<IconTypeRole>(index).toInt()), true);
}

QVariant NmModel::data(const QModelIndex &index, int role) const
@@ -174,7 +174,7 @@ void TrayPrivate::refreshIcon()
{
//Note: the icons::getIcon chooses the right icon from list of possible candidates
// -> we need to refresh the icon in case of icon theme change
mTrayIcon.setIcon(icons::getIcon(mIconCurrent));
mTrayIcon.setIcon(icons::getIcon(mIconCurrent, false));
}

void TrayPrivate::openCloseDialog(QDialog * dialog)
@@ -219,7 +219,7 @@ void TrayPrivate::notify(QModelIndex const & index, bool removing)
// TODO: do somehow check the result?
mNotification.Notify(Tray::tr("NetworkManager(nm-tray)")
, 0
, icons::getIcon(static_cast<icons::Icon>(mActiveConnections.data(index, NmModel::IconTypeRole).toInt())).name()
, icons::getIcon(static_cast<icons::Icon>(mActiveConnections.data(index, NmModel::IconTypeRole).toInt()), false).name()
, summary
, body.arg(mActiveConnections.data(index, NmModel::ConnectionTypeStringRole).toString()).arg(mActiveConnections.data(index, NmModel::NameRole).toString())
, {}

0 comments on commit ecbe243

Please sign in to comment.
You can’t perform that action at this time.