mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-26 14:23:09 +00:00
dataproviders: declare BatteryInfo as singleton
This commit is contained in:
parent
73e020e448
commit
72657628b6
4 changed files with 11 additions and 13 deletions
|
|
@ -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");
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@
|
|||
* SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
|
||||
pragma Singleton
|
||||
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue