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
|
|
|
|
|
|
2026-03-07 03:08:07 +00:00
|
|
|
import org.kde.kirigami as Kirigami
|
2026-03-06 01:13:34 +00:00
|
|
|
import org.kde.kitemmodels
|
2023-07-25 01:13:52 +00:00
|
|
|
|
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
|
2025-03-19 20:09:33 +00:00
|
|
|
import org.kde.plasma.private.mobileshell.shellsettingsplugin as ShellSettings
|
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
|
|
|
|
2025-03-19 20:09:33 +00:00
|
|
|
spacing: 0
|
2026-03-06 01:13:34 +00:00
|
|
|
model: filterModel
|
2024-10-04 15:34:34 +00:00
|
|
|
orientation: ListView.Horizontal
|
2019-10-07 16:49:18 +00:00
|
|
|
|
|
|
|
|
Layout.alignment: Qt.AlignVCenter
|
2025-03-19 20:09:33 +00:00
|
|
|
Layout.preferredWidth: contentItem.childrenRect.width
|
2024-10-04 15:34:34 +00:00
|
|
|
Layout.fillHeight: true
|
|
|
|
|
Layout.fillWidth: false
|
|
|
|
|
|
2026-03-06 01:13:34 +00:00
|
|
|
KSortFilterProxyModel {
|
|
|
|
|
id: filterModel
|
|
|
|
|
sourceModel: MobileShell.BatteryInfo.batteries
|
|
|
|
|
|
|
|
|
|
filterRoleName: "Type"
|
|
|
|
|
filterString: "Battery" // only show internal batteries
|
|
|
|
|
}
|
|
|
|
|
|
2024-10-04 15:34:34 +00:00
|
|
|
delegate: RowLayout {
|
2025-03-19 20:09:33 +00:00
|
|
|
id: batteryBase
|
2024-10-04 15:34:34 +00:00
|
|
|
|
|
|
|
|
Layout.fillHeight: false
|
|
|
|
|
Layout.alignment: Qt.AlignVCenter
|
|
|
|
|
|
|
|
|
|
height: batteryRepeater.height
|
|
|
|
|
|
|
|
|
|
PW.BatteryIcon {
|
|
|
|
|
id: battery
|
|
|
|
|
|
|
|
|
|
Layout.alignment: Qt.AlignVCenter
|
2025-03-19 20:09:33 +00:00
|
|
|
Layout.fillHeight: true
|
2024-10-04 15:34:34 +00:00
|
|
|
width: batteryLabel.height
|
|
|
|
|
|
|
|
|
|
hasBattery: PluggedIn
|
|
|
|
|
percent: Percent
|
|
|
|
|
pluggedIn: ChargeState === BatteryControlModel.Charging
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PlasmaComponents.Label {
|
|
|
|
|
id: batteryLabel
|
|
|
|
|
text: i18n("%1%", Percent)
|
|
|
|
|
Layout.alignment: Qt.AlignVCenter
|
2025-03-19 20:09:33 +00:00
|
|
|
Layout.fillHeight: true
|
2024-10-04 15:34:34 +00:00
|
|
|
|
|
|
|
|
color: Kirigami.Theme.textColor
|
2025-03-19 20:09:33 +00:00
|
|
|
visible: ShellSettings.Settings.showBatteryPercentage
|
2024-10-04 15:34:34 +00:00
|
|
|
font.pixelSize: textPixelSize
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-10-07 16:49:18 +00:00
|
|
|
}
|
|
|
|
|
}
|