From db675eb7b23e64c51c5af3fb99c491022262c781 Mon Sep 17 00:00:00 2001 From: Piyush Aggarwal Date: Tue, 13 Jul 2021 23:23:58 +0530 Subject: [PATCH] connectivity_action: replace manual ifs with code --- .../systray_actions/connectivity_action.cpp | 34 ++----------------- .../systray_actions/connectivity_action.h | 10 ++++++ 2 files changed, 12 insertions(+), 32 deletions(-) diff --git a/indicator/systray_actions/connectivity_action.cpp b/indicator/systray_actions/connectivity_action.cpp index 22ba53f24..b6c025a5f 100644 --- a/indicator/systray_actions/connectivity_action.cpp +++ b/indicator/systray_actions/connectivity_action.cpp @@ -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)); diff --git a/indicator/systray_actions/connectivity_action.h b/indicator/systray_actions/connectivity_action.h index 956a1fdea..5cf4c45e3 100644 --- a/indicator/systray_actions/connectivity_action.h +++ b/indicator/systray_actions/connectivity_action.h @@ -16,6 +16,16 @@ #include +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