Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Network
KDE Connect
Commits
de02b9b5
Commit
de02b9b5
authored
Jun 13, 2021
by
Piyush Aggarwal
🎮
Browse files
systray: add dynamic icon support for connectivity action
parent
9e0741c7
Changes
1
Hide whitespace changes
Inline
Side-by-side
indicator/systray_actions/connectivity_action.cpp
View file @
de02b9b5
...
...
@@ -31,6 +31,63 @@ void ConnectivityAction::update()
}
else
{
setText
(
i18nc
(
"Display the cellular connection type and an approximate percentage of signal strength"
,
"%1 | ~%2%"
,
m_cellularNetworkType
,
m_cellularNetworkStrength
*
25
));
}
// set icon name
QString
iconName
=
QStringLiteral
(
"network-mobile"
);
if
(
m_cellularNetworkStrength
<
0
)
{
iconName
+=
QStringLiteral
(
"-off"
);
}
else
{
int
signalStrength
;
switch
(
m_cellularNetworkStrength
)
{
case
0
:
signalStrength
=
0
;
break
;
case
1
:
signalStrength
=
20
;
break
;
case
2
:
signalStrength
=
60
;
break
;
case
3
:
signalStrength
=
80
;
break
;
default
:
signalStrength
=
100
;
break
;
}
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
(
""
);
}
qDebug
()
<<
"iconName ="
<<
iconName
;
setIcon
(
QIcon
::
fromTheme
(
iconName
));
}
void
ConnectivityAction
::
setCellularNetworkStrength
(
int
cellularNetworkStrength
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment