Files
DankMaterialShell/quickshell/Modules/ControlCenter/Widgets/BatteryTile.qml
T
bbedward 014c69b09a settings: tile color restyle and re-org, use materials own shift for
them towards theme
controlCenter: make a real grid, add numerous more tile varieties, add
icon size option
surfaces: fix elevation levels in general, and shift them down
settings: restyles and re-org
sliders: scale down universally
2026-09-18 14:32:55 -04:00

54 lines
1.8 KiB
QML

import QtQuick
import qs.Common
import qs.Modules.ControlCenter
import qs.Services
import qs.Widgets
CcTile {
id: root
readonly property bool available: BatteryService.batteryAvailable
iconName: BatteryService.getBatteryIcon()
title: available ? I18n.tr("Battery") : I18n.tr("No battery")
subtitle: {
if (!available)
return I18n.tr("Not available");
if (BatteryService.isCharging)
return `${BatteryService.batteryLevel}% • ` + I18n.tr("Charging");
if (BatteryService.isPluggedIn)
return `${BatteryService.batteryLevel}% • ` + I18n.tr("Plugged in");
return `${BatteryService.batteryLevel}%`;
}
active: available && (BatteryService.isCharging || BatteryService.isPluggedIn)
opensPage: true
tallContent: Component {
Item {
BatteryMeter {
anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter
thickness: CcMetrics.tallMeterThickness
levelColors: true
showNumber: false
visible: root.available
}
}
}
onClicked: expandClicked()
expandedContent: Component {
CcTileActions {
actions: PowerProfileWatcher.availableProfiles.map(profile => ({
text: Theme.getPowerProfileLabel(profile),
icon: Theme.getPowerProfileIcon(profile),
active: profile === PowerProfileWatcher.currentProfile,
enabled: PowerProfileWatcher.available,
trigger: () => {
if (!PowerProfileWatcher.applyProfile(profile))
ToastService.showError(I18n.tr("Failed to set power profile"));
}
}))
}
}
}