2019-10-07 16:49:18 +00:00
|
|
|
/*
|
2024-10-04 15:34:34 +00:00
|
|
|
* SPDX-FileCopyrightText: 2024 Sebastian Kügler <sebas@kde.org>
|
2021-04-09 20:59:05 +00:00
|
|
|
* SPDX-FileCopyrightText: 2021 Devin Lin <espidev@gmail.com>
|
2021-03-01 20:03:25 +00:00
|
|
|
* SPDX-FileCopyrightText: 2019 Marco Martin <mart@kde.org>
|
2019-10-07 16:49:18 +00:00
|
|
|
*
|
2021-03-01 20:03:25 +00:00
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
2019-10-07 16:49:18 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import QtQuick 2.6
|
|
|
|
|
import QtQuick.Layouts 1.4
|
|
|
|
|
|
2023-07-25 01:13:52 +00:00
|
|
|
import org.kde.kirigami 2.20 as Kirigami
|
|
|
|
|
|
2019-10-07 16:49:18 +00:00
|
|
|
import org.kde.plasma.components 3.0 as PlasmaComponents
|
|
|
|
|
import org.kde.plasma.workspace.components 2.0 as PW
|
2023-11-02 11:08:17 +00:00
|
|
|
import org.kde.plasma.private.mobileshell as MobileShell
|
2024-10-04 15:34:34 +00:00
|
|
|
import org.kde.plasma.private.battery // needed for charging state
|
2023-03-17 02:44:36 +00:00
|
|
|
|
2019-10-07 16:49:18 +00:00
|
|
|
RowLayout {
|
2023-07-25 01:13:52 +00:00
|
|
|
property real textPixelSize: Kirigami.Units.gridUnit * 0.6
|
2024-07-27 03:47:44 +00:00
|
|
|
|
2023-10-19 17:41:29 +00:00
|
|
|
visible: MobileShell.BatteryInfo.isVisible
|
2019-10-07 16:49:18 +00:00
|
|
|
|
2024-10-04 15:34:34 +00:00
|
|
|
ListView {
|
|
|
|
|
id: batteryRepeater
|
2019-10-07 16:49:18 +00:00
|
|
|
|
2024-10-04 15:34:34 +00:00
|
|
|
property int batteryWidth: 0
|
|
|
|
|
|
|
|
|
|
spacing: root.elementSpacing
|
|
|
|
|
model: MobileShell.BatteryInfo.batteries
|
|
|
|
|
orientation: ListView.Horizontal
|
2019-10-07 16:49:18 +00:00
|
|
|
|
|
|
|
|
Layout.alignment: Qt.AlignVCenter
|
2024-10-04 15:34:34 +00:00
|
|
|
Layout.preferredWidth: (batteryRepeater.batteryWidth + root.elementSpacing) * batteryRepeater.count
|
|
|
|
|
Layout.fillHeight: true
|
|
|
|
|
Layout.fillWidth: false
|
|
|
|
|
|
|
|
|
|
delegate: RowLayout {
|
|
|
|
|
|
|
|
|
|
Layout.preferredWidth: batteryRepeater.batteryWidth
|
|
|
|
|
Layout.fillHeight: false
|
|
|
|
|
Layout.alignment: Qt.AlignVCenter
|
|
|
|
|
|
|
|
|
|
height: batteryRepeater.height
|
|
|
|
|
|
|
|
|
|
PW.BatteryIcon {
|
|
|
|
|
id: battery
|
|
|
|
|
|
|
|
|
|
Layout.alignment: Qt.AlignVCenter
|
|
|
|
|
height: batteryLabel.height
|
|
|
|
|
width: batteryLabel.height
|
|
|
|
|
|
|
|
|
|
hasBattery: PluggedIn
|
|
|
|
|
percent: Percent
|
|
|
|
|
pluggedIn: ChargeState === BatteryControlModel.Charging
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PlasmaComponents.Label {
|
|
|
|
|
id: batteryLabel
|
|
|
|
|
text: i18n("%1%", Percent)
|
|
|
|
|
Layout.alignment: Qt.AlignVCenter
|
|
|
|
|
|
|
|
|
|
color: Kirigami.Theme.textColor
|
|
|
|
|
font.pixelSize: textPixelSize
|
|
|
|
|
}
|
2019-10-07 16:49:18 +00:00
|
|
|
|
2024-10-04 15:34:34 +00:00
|
|
|
Component.onCompleted: {
|
|
|
|
|
// ListView & RowLayout have problems with childrenRect size,
|
|
|
|
|
// set it here so it propagates up nicely
|
|
|
|
|
batteryRepeater.batteryWidth = batteryLabel.width + battery.width
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-10-07 16:49:18 +00:00
|
|
|
}
|
|
|
|
|
}
|