mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-08-04 02:34:45 +00:00
Improve the signal strength indicator
Show 'Sim locked' instead of '0%' when Sim is locked Don't show the percentage at all, it's redundant
This commit is contained in:
parent
4a6fdab931
commit
fae8ac9969
1 changed files with 20 additions and 44 deletions
|
|
@ -25,74 +25,50 @@ import org.kde.plasma.plasmoid 2.0
|
||||||
import org.kde.plasma.core 2.0 as PlasmaCore
|
import org.kde.plasma.core 2.0 as PlasmaCore
|
||||||
import org.kde.plasma.components 2.0 as PlasmaComponents
|
import org.kde.plasma.components 2.0 as PlasmaComponents
|
||||||
|
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
|
|
||||||
width: strengthIcon.height + strengthLabel.width
|
width: strengthIcon.height + strengthLabel.width
|
||||||
Layout.minimumWidth: strengthIcon.height + strengthLabel.width
|
Layout.minimumWidth: strengthIcon.height + strengthLabel.width
|
||||||
|
|
||||||
OfonoManager {
|
OfonoManager {
|
||||||
id: ofonoManager
|
id: ofonoManager
|
||||||
onAvailableChanged: {
|
|
||||||
console.log("Ofono is " + available)
|
|
||||||
}
|
|
||||||
onModemAdded: {
|
|
||||||
console.log("modem added " + modem)
|
|
||||||
}
|
|
||||||
onModemRemoved: console.log("modem removed")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
OfonoNetworkRegistration {
|
OfonoNetworkRegistration {
|
||||||
id: netreg
|
id: netreg
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
netreg.scan()
|
netreg.scan()
|
||||||
updateStrengthIcon()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onNetworkOperatorsChanged : {
|
|
||||||
console.log("operators :"+netreg.currentOperator["Name"].toString())
|
|
||||||
}
|
|
||||||
modemPath: ofonoManager.modems.length ? ofonoManager.modems[0] : ""
|
modemPath: ofonoManager.modems.length ? ofonoManager.modems[0] : ""
|
||||||
function updateStrengthIcon() {
|
|
||||||
if (netreg.strength >= 100) {
|
|
||||||
strengthIcon.source = "network-mobile-100";
|
|
||||||
} else if (netreg.strength >= 80) {
|
|
||||||
strengthIcon.source = "network-mobile-80";
|
|
||||||
} else if (netreg.strength >= 60) {
|
|
||||||
strengthIcon.source = "network-mobile-60";
|
|
||||||
} else if (netreg.strength >= 40) {
|
|
||||||
strengthIcon.source = "network-mobile-40";
|
|
||||||
} else if (netreg.strength >= 20) {
|
|
||||||
strengthIcon.source = "network-mobile-20";
|
|
||||||
} else {
|
|
||||||
strengthIcon.source = "network-mobile-0";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
onStrengthChanged: {
|
|
||||||
console.log("Strength changed to " + netreg.strength)
|
|
||||||
updateStrengthIcon()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OfonoSimManager {
|
||||||
|
id: simManager
|
||||||
|
modemPath: ofonoManager.modems.length ? ofonoManager.modems[0] : ""
|
||||||
|
}
|
||||||
|
|
||||||
PlasmaCore.IconItem {
|
PlasmaCore.IconItem {
|
||||||
id: strengthIcon
|
id: strengthIcon
|
||||||
colorGroup: PlasmaCore.ColorScope.colorGroup
|
colorGroup: PlasmaCore.ColorScope.colorGroup
|
||||||
anchors {
|
anchors.left: parent.left
|
||||||
left: parent.left
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
verticalCenter: parent.verticalCenter
|
|
||||||
}
|
|
||||||
width: height
|
width: height
|
||||||
height: parent.height
|
height: parent.height
|
||||||
|
|
||||||
|
source: netreg.strength == 100 ? "network-mobile-100"
|
||||||
|
: netreg.strength >= 80 ? "network-mobile-80"
|
||||||
|
: netreg.strength >= 60 ? "network-mobile-60"
|
||||||
|
: netreg.strength >= 40 ? "network-mobile-40"
|
||||||
|
: netreg.strength >= 20 ? "network-mobile-20"
|
||||||
|
: "network-mobile-0"
|
||||||
}
|
}
|
||||||
|
|
||||||
PlasmaComponents.Label {
|
PlasmaComponents.Label {
|
||||||
id: strengthLabel
|
id: label
|
||||||
anchors {
|
anchors.left: strengthIcon.right
|
||||||
left: strengthIcon.right
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
verticalCenter: parent.verticalCenter
|
|
||||||
}
|
text: simManager.pinRequired !== OfonoSimManager.NoPin ? i18n("Sim locked") : netreg.name
|
||||||
text: netreg.strength + "% " + netreg.name
|
|
||||||
color: PlasmaCore.ColorScope.textColor
|
color: PlasmaCore.ColorScope.textColor
|
||||||
font.pixelSize: parent.height / 2
|
font.pixelSize: parent.height / 2
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue