connectivity_action: replace manual ifs with code

This commit is contained in:
Piyush Aggarwal 2021-07-13 23:23:58 +05:30
parent 296de907b5
commit db675eb7b2
2 changed files with 12 additions and 32 deletions

View file

@ -51,38 +51,8 @@ void ConnectivityAction::update()
iconName += QStringLiteral("-") + QString::number(signalStrength);
}
if (m_cellularNetworkType == QStringLiteral("5G")) {
// No icon for this case!
iconName += QStringLiteral("-");
} else if (m_cellularNetworkType == QStringLiteral("LTE")) {
iconName += QStringLiteral("-lte");
} else if (m_cellularNetworkType == QStringLiteral("HSPA")) {
iconName += QStringLiteral("-hspa");
} else if (m_cellularNetworkType == QStringLiteral("UMTS")) {
iconName += QStringLiteral("-umts");
} else if (m_cellularNetworkType == QStringLiteral("CDMA2000")) {
// GSconnect just uses the 3g icon
// No icon for this case!
iconName += QStringLiteral("");
} else if (m_cellularNetworkType == QStringLiteral("EDGE")) {
iconName += QStringLiteral("-edge");
} else if (m_cellularNetworkType == QStringLiteral("GPRS")) {
iconName += QStringLiteral("-gprs");
} else if (m_cellularNetworkType == QStringLiteral("GSM")) {
// GSconnect just uses the 2g icon
// No icon for this case!
iconName += QStringLiteral("");
} else if (m_cellularNetworkType == QStringLiteral("CDMA")) {
// GSconnect just uses the 2g icon
// No icon for this case!
iconName += QStringLiteral("");
} else if (m_cellularNetworkType == QStringLiteral("iDEN")) {
// GSconnect just uses the 2g icon
// No icon for this case!
iconName += QStringLiteral("");
} else {
// We didn't recognize the network type. Don't append anything.
iconName += QStringLiteral("");
if (connectivity_action::networkTypesWithIcons.contains(m_cellularNetworkType)) {
iconName += QStringLiteral("-") + m_cellularNetworkType.toLower();
}
setIcon(QIcon::fromTheme(iconName));

View file

@ -16,6 +16,16 @@
#include <dbushelper.h>
namespace connectivity_action {
const QStringList networkTypesWithIcons { // contains the name of network types that have an associated icon in Breeze-icons
QStringLiteral("EDGE"),
QStringLiteral("GPRS"),
QStringLiteral("HSPA"),
QStringLiteral("LTE"),
QStringLiteral("UMTS"),
};
}
class ConnectivityAction : public QAction
{
Q_OBJECT