mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-07-26 06:14:45 +00:00
move ofono stuff in different file
since is now loaded in a Loader, it should fail gracefully
This commit is contained in:
parent
ebb4e5677a
commit
85fdc45d03
2 changed files with 101 additions and 63 deletions
98
containments/panel/contents/ui/SignalStrength.qml
Normal file
98
containments/panel/contents/ui/SignalStrength.qml
Normal file
|
|
@ -0,0 +1,98 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2015 Marco Martin <mart@kde.org>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 2.010-1301, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import QtQuick 2.1
|
||||||
|
import QtQuick.Layouts 1.1
|
||||||
|
|
||||||
|
import MeeGo.QOfono 0.2
|
||||||
|
|
||||||
|
import org.kde.plasma.plasmoid 2.0
|
||||||
|
import org.kde.plasma.core 2.0 as PlasmaCore
|
||||||
|
import org.kde.plasma.components 2.0 as PlasmaComponents
|
||||||
|
|
||||||
|
|
||||||
|
Item {
|
||||||
|
|
||||||
|
Layout.minimumWidth: strengthIcon.height + strengthLabel.width
|
||||||
|
OfonoManager {
|
||||||
|
id: ofonoManager
|
||||||
|
onAvailableChanged: {
|
||||||
|
console.log("Ofono is " + available)
|
||||||
|
}
|
||||||
|
onModemAdded: {
|
||||||
|
console.log("modem added " + modem)
|
||||||
|
}
|
||||||
|
onModemRemoved: console.log("modem removed")
|
||||||
|
}
|
||||||
|
|
||||||
|
OfonoNetworkRegistration {
|
||||||
|
id: netreg
|
||||||
|
Component.onCompleted: {
|
||||||
|
netreg.scan()
|
||||||
|
updateStrengthIcon()
|
||||||
|
}
|
||||||
|
|
||||||
|
onNetworkOperatorsChanged : {
|
||||||
|
console.log("operators :"+netreg.currentOperator["Name"].toString())
|
||||||
|
}
|
||||||
|
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()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
PlasmaCore.IconItem {
|
||||||
|
id: strengthIcon
|
||||||
|
colorGroup: PlasmaCore.ColorScope.colorGroup
|
||||||
|
anchors {
|
||||||
|
left: parent.left
|
||||||
|
verticalCenter: parent.verticalCenter
|
||||||
|
}
|
||||||
|
width: height
|
||||||
|
height: parent.height
|
||||||
|
}
|
||||||
|
PlasmaComponents.Label {
|
||||||
|
id: strengthLabel
|
||||||
|
anchors {
|
||||||
|
left: strengthIcon.right
|
||||||
|
verticalCenter: parent.verticalCenter
|
||||||
|
}
|
||||||
|
text: netreg.strength + "% " + netreg.name
|
||||||
|
color: PlasmaCore.ColorScope.textColor
|
||||||
|
font.pixelSize: parent.height / 2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -19,8 +19,6 @@
|
||||||
import QtQuick 2.1
|
import QtQuick 2.1
|
||||||
import QtQuick.Layouts 1.1
|
import QtQuick.Layouts 1.1
|
||||||
|
|
||||||
import MeeGo.QOfono 0.2
|
|
||||||
|
|
||||||
import org.kde.plasma.plasmoid 2.0
|
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
|
||||||
|
|
@ -180,50 +178,6 @@ PlasmaCore.ColorScope {
|
||||||
interval: 60 * 1000
|
interval: 60 * 1000
|
||||||
}
|
}
|
||||||
|
|
||||||
OfonoManager {
|
|
||||||
id: ofonoManager
|
|
||||||
onAvailableChanged: {
|
|
||||||
console.log("Ofono is " + available)
|
|
||||||
}
|
|
||||||
onModemAdded: {
|
|
||||||
console.log("modem added " + modem)
|
|
||||||
}
|
|
||||||
onModemRemoved: console.log("modem removed")
|
|
||||||
}
|
|
||||||
|
|
||||||
OfonoNetworkRegistration {
|
|
||||||
id: netreg
|
|
||||||
Component.onCompleted: {
|
|
||||||
netreg.scan()
|
|
||||||
updateStrengthIcon()
|
|
||||||
}
|
|
||||||
|
|
||||||
onNetworkOperatorsChanged : {
|
|
||||||
console.log("operators :"+netreg.currentOperator["Name"].toString())
|
|
||||||
}
|
|
||||||
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()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
parent: slidingPanel.visible ? panelContents : root
|
parent: slidingPanel.visible ? panelContents : root
|
||||||
anchors {
|
anchors {
|
||||||
|
|
@ -234,24 +188,10 @@ PlasmaCore.ColorScope {
|
||||||
height: root.height
|
height: root.height
|
||||||
color: PlasmaCore.ColorScope.backgroundColor
|
color: PlasmaCore.ColorScope.backgroundColor
|
||||||
|
|
||||||
PlasmaCore.IconItem {
|
Loader {
|
||||||
id: strengthIcon
|
|
||||||
colorGroup: PlasmaCore.ColorScope.colorGroup
|
|
||||||
anchors {
|
|
||||||
left: parent.left
|
|
||||||
verticalCenter: parent.verticalCenter
|
|
||||||
}
|
|
||||||
width: height
|
|
||||||
height: parent.height
|
height: parent.height
|
||||||
}
|
width: item.width
|
||||||
PlasmaComponents.Label {
|
source: Qt.resolvedUrl("SignalStrength.qml")
|
||||||
anchors {
|
|
||||||
left: strengthIcon.right
|
|
||||||
verticalCenter: parent.verticalCenter
|
|
||||||
}
|
|
||||||
text: netreg.strength + "% " + netreg.name
|
|
||||||
color: PlasmaCore.ColorScope.textColor
|
|
||||||
font.pixelSize: parent.height / 2
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PlasmaComponents.Label {
|
PlasmaComponents.Label {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue