diff --git a/components/mobileshell/mobileshellplugin.cpp b/components/mobileshell/mobileshellplugin.cpp index 2cfd8923..9476ed7a 100644 --- a/components/mobileshell/mobileshellplugin.cpp +++ b/components/mobileshell/mobileshellplugin.cpp @@ -61,7 +61,7 @@ void MobileShellPlugin::registerTypes(const char *uri) // /dataproviders qmlRegisterSingletonType(resolvePath("dataproviders/AudioInfo.qml"), uri, 1, 0, "AudioInfo"); - qmlRegisterType(resolvePath("dataproviders/BatteryInfo.qml"), uri, 1, 0, "BatteryInfo"); + qmlRegisterSingletonType(resolvePath("dataproviders/BatteryInfo.qml"), uri, 1, 0, "BatteryInfo"); qmlRegisterType(resolvePath("dataproviders/BluetoothInfo.qml"), uri, 1, 0, "BluetoothInfo"); qmlRegisterType(resolvePath("dataproviders/SignalStrengthInfo.qml"), uri, 1, 0, "SignalStrengthInfo"); diff --git a/components/mobileshell/qml/dataproviders/BatteryInfo.qml b/components/mobileshell/qml/dataproviders/BatteryInfo.qml index 0bdbedf4..444363cd 100644 --- a/components/mobileshell/qml/dataproviders/BatteryInfo.qml +++ b/components/mobileshell/qml/dataproviders/BatteryInfo.qml @@ -5,6 +5,8 @@ * SPDX-License-Identifier: GPL-2.0-or-later */ +pragma Singleton + import QtQuick import QtQuick.Layouts diff --git a/components/mobileshell/qml/statusbar/indicators/BatteryIndicator.qml b/components/mobileshell/qml/statusbar/indicators/BatteryIndicator.qml index fa72a8f4..9d1db113 100644 --- a/components/mobileshell/qml/statusbar/indicators/BatteryIndicator.qml +++ b/components/mobileshell/qml/statusbar/indicators/BatteryIndicator.qml @@ -12,22 +12,20 @@ import org.kde.kirigami 2.20 as Kirigami import org.kde.plasma.components 3.0 as PlasmaComponents import org.kde.plasma.workspace.components 2.0 as PW - -import "../../dataproviders" as DataProviders +import org.kde.plasma.private.mobileshell 1.0 as MobileShell RowLayout { - readonly property var provider: DataProviders.BatteryInfo {} property real textPixelSize: Kirigami.Units.gridUnit * 0.6 - visible: provider.isVisible + visible: MobileShell.BatteryInfo.isVisible PW.BatteryIcon { id: battery Layout.preferredWidth: height Layout.fillHeight: true hasBattery: true - percent: provider.percent - pluggedIn: provider.pluggedIn + percent: MobileShell.BatteryInfo.percent + pluggedIn: MobileShell.BatteryInfo.pluggedIn height: batteryLabel.height width: batteryLabel.height @@ -35,7 +33,7 @@ RowLayout { PlasmaComponents.Label { id: batteryLabel - text: i18n("%1%", provider.percent) + text: i18n("%1%", MobileShell.BatteryInfo.percent) Layout.alignment: Qt.AlignVCenter color: Kirigami.Theme.textColor diff --git a/quicksettings/battery/contents/ui/main.qml b/quicksettings/battery/contents/ui/main.qml index e5744a6a..533a41fa 100644 --- a/quicksettings/battery/contents/ui/main.qml +++ b/quicksettings/battery/contents/ui/main.qml @@ -6,12 +6,10 @@ import QtQuick 2.15 import org.kde.plasma.private.mobileshell.quicksettingsplugin as QS import org.kde.plasma.private.mobileshell 1.0 as MobileShell -QS.QuickSetting { - property var batteryInfo: MobileShell.BatteryInfo {} - +QS.QuickSetting { text: i18n("Battery") - status: i18n("%1%", batteryInfo.percent) - icon: "battery-full" + (batteryInfo.pluggedIn ? "-charging" : "") + status: i18n("%1%", MobileShell.BatteryInfo.percent) + icon: "battery-full" + (MobileShell.BatteryInfo.pluggedIn ? "-charging" : "") enabled: false settingsCommand: "plasma-open-settings kcm_mobile_power" }