Warning, /plasma/plasma-workspace/applets/batterymonitor/package/contents/ui/CompactRepresentation.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 SPDX-FileCopyrightText: 2011 Sebastian Kügler <sebas@kde.org> 0003 SPDX-FileCopyrightText: 2011 Viranch Mehta <viranch.mehta@gmail.com> 0004 SPDX-FileCopyrightText: 2013 Kai Uwe Broulik <kde@privat.broulik.de> 0005 0006 SPDX-License-Identifier: LGPL-2.0-or-later 0007 */ 0008 0009 import QtQuick 0010 import QtQuick.Layouts 0011 0012 import org.kde.plasma.plasmoid 0013 import org.kde.plasma.core as PlasmaCore 0014 import org.kde.plasma.workspace.components as WorkspaceComponents 0015 import org.kde.kirigami as Kirigami 0016 0017 MouseArea { 0018 id: root 0019 0020 property real itemSize: Math.min(root.height, root.width/view.count) 0021 readonly property bool isConstrained: Plasmoid.formFactor === PlasmaCore.Types.Vertical || Plasmoid.formFactor === PlasmaCore.Types.Horizontal 0022 property real brightnessError: 0 0023 property QtObject batteries 0024 property bool hasBatteries: false 0025 required property bool isSetToPerformanceMode 0026 required property bool isSetToPowerSaveMode 0027 required property bool isSomehowFullyCharged 0028 0029 activeFocusOnTab: true 0030 hoverEnabled: true 0031 0032 property bool wasExpanded 0033 0034 Accessible.name: Plasmoid.title 0035 Accessible.description: `${toolTipMainText}; ${toolTipSubText}` 0036 Accessible.role: Accessible.Button 0037 0038 onPressed: wasExpanded = batterymonitor.expanded 0039 onClicked: batterymonitor.expanded = !wasExpanded 0040 0041 // "No Batteries" case 0042 Kirigami.Icon { 0043 anchors.fill: parent 0044 visible: !root.hasBatteries 0045 source: Plasmoid.icon 0046 active: root.containsMouse 0047 } 0048 0049 // We have any batteries; show their status 0050 //Should we consider turning this into a Flow item? 0051 Row { 0052 visible: root.hasBatteries 0053 anchors.centerIn: parent 0054 Repeater { 0055 id: view 0056 0057 model: root.isConstrained ? 1 : root.batteries 0058 0059 Item { 0060 id: batteryContainer 0061 0062 property int percent: root.isConstrained ? pmSource.data["Battery"]["Percent"] : model["Percent"] 0063 property bool pluggedIn: pmSource.data["AC Adapter"] && pmSource.data["AC Adapter"]["Plugged in"] && (root.isConstrained || model["Is Power Supply"]) 0064 0065 height: root.itemSize 0066 width: root.width/view.count 0067 0068 property real iconSize: Math.min(width, height) 0069 0070 // "Held on a Power Profile mode while plugged in" use case; show the 0071 // icon of the active mode so the user can notice this at a glance 0072 Kirigami.Icon { 0073 id: powerProfileModeIcon 0074 0075 anchors.fill: parent 0076 0077 visible: batteryContainer.pluggedIn && (root.isSetToPerformanceMode || root.isSetToPowerSaveMode) 0078 source: root.isSetToPerformanceMode 0079 ? "battery-profile-performance-symbolic" 0080 : "battery-profile-powersave-symbolic" 0081 active: root.containsMouse 0082 } 0083 0084 // Show normal battery icon 0085 WorkspaceComponents.BatteryIcon { 0086 id: batteryIcon 0087 0088 anchors.centerIn: parent 0089 height: batteryContainer.iconSize 0090 width: height 0091 0092 active: root.containsMouse 0093 visible: !powerProfileModeIcon.visible 0094 hasBattery: root.hasBatteries 0095 percent: batteryContainer.percent 0096 pluggedIn: batteryContainer.pluggedIn 0097 } 0098 0099 WorkspaceComponents.BadgeOverlay { 0100 anchors.bottom: parent.bottom 0101 anchors.right: parent.right 0102 0103 visible: Plasmoid.configuration.showPercentage && !root.isSomehowFullyCharged 0104 0105 text: i18nc("battery percentage below battery icon", "%1%", percent) 0106 icon: batteryIcon 0107 } 0108 } 0109 } 0110 } 0111 }