mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-08-02 01:34:46 +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
|
// /dataproviders
|
||||||
qmlRegisterSingletonType(resolvePath("dataproviders/AudioInfo.qml"), uri, 1, 0, "AudioInfo");
|
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/BluetoothInfo.qml"), uri, 1, 0, "BluetoothInfo");
|
||||||
qmlRegisterType(resolvePath("dataproviders/SignalStrengthInfo.qml"), uri, 1, 0, "SignalStrengthInfo");
|
qmlRegisterType(resolvePath("dataproviders/SignalStrengthInfo.qml"), uri, 1, 0, "SignalStrengthInfo");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,8 @@
|
||||||
* SPDX-License-Identifier: GPL-2.0-or-later
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
pragma Singleton
|
||||||
|
|
||||||
import QtQuick
|
import QtQuick
|
||||||
import QtQuick.Layouts
|
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.components 3.0 as PlasmaComponents
|
||||||
import org.kde.plasma.workspace.components 2.0 as PW
|
import org.kde.plasma.workspace.components 2.0 as PW
|
||||||
|
import org.kde.plasma.private.mobileshell 1.0 as MobileShell
|
||||||
import "../../dataproviders" as DataProviders
|
|
||||||
|
|
||||||
RowLayout {
|
RowLayout {
|
||||||
readonly property var provider: DataProviders.BatteryInfo {}
|
|
||||||
property real textPixelSize: Kirigami.Units.gridUnit * 0.6
|
property real textPixelSize: Kirigami.Units.gridUnit * 0.6
|
||||||
|
|
||||||
visible: provider.isVisible
|
visible: MobileShell.BatteryInfo.isVisible
|
||||||
|
|
||||||
PW.BatteryIcon {
|
PW.BatteryIcon {
|
||||||
id: battery
|
id: battery
|
||||||
Layout.preferredWidth: height
|
Layout.preferredWidth: height
|
||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
hasBattery: true
|
hasBattery: true
|
||||||
percent: provider.percent
|
percent: MobileShell.BatteryInfo.percent
|
||||||
pluggedIn: provider.pluggedIn
|
pluggedIn: MobileShell.BatteryInfo.pluggedIn
|
||||||
|
|
||||||
height: batteryLabel.height
|
height: batteryLabel.height
|
||||||
width: batteryLabel.height
|
width: batteryLabel.height
|
||||||
|
|
@ -35,7 +33,7 @@ RowLayout {
|
||||||
|
|
||||||
PlasmaComponents.Label {
|
PlasmaComponents.Label {
|
||||||
id: batteryLabel
|
id: batteryLabel
|
||||||
text: i18n("%1%", provider.percent)
|
text: i18n("%1%", MobileShell.BatteryInfo.percent)
|
||||||
Layout.alignment: Qt.AlignVCenter
|
Layout.alignment: Qt.AlignVCenter
|
||||||
|
|
||||||
color: Kirigami.Theme.textColor
|
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.quicksettingsplugin as QS
|
||||||
import org.kde.plasma.private.mobileshell 1.0 as MobileShell
|
import org.kde.plasma.private.mobileshell 1.0 as MobileShell
|
||||||
|
|
||||||
QS.QuickSetting {
|
QS.QuickSetting {
|
||||||
property var batteryInfo: MobileShell.BatteryInfo {}
|
|
||||||
|
|
||||||
text: i18n("Battery")
|
text: i18n("Battery")
|
||||||
status: i18n("%1%", batteryInfo.percent)
|
status: i18n("%1%", MobileShell.BatteryInfo.percent)
|
||||||
icon: "battery-full" + (batteryInfo.pluggedIn ? "-charging" : "")
|
icon: "battery-full" + (MobileShell.BatteryInfo.pluggedIn ? "-charging" : "")
|
||||||
enabled: false
|
enabled: false
|
||||||
settingsCommand: "plasma-open-settings kcm_mobile_power"
|
settingsCommand: "plasma-open-settings kcm_mobile_power"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue