Files
dotfiles/quickshell/BatterySettings.qml
T
2026-11-17 18:15:16 +07:00

83 lines
3.3 KiB
QML

pragma ComponentBehavior: Bound
import QtQuick
import QtQuick.Controls
import QtQuick.Controls.Material
import QtQuick.Layouts
import "services"
ScrollView {
id: root
contentWidth: availableWidth
clip: true
BrightnessController { id: brightness }
ColumnLayout {
width: root.availableWidth
spacing: 16
Label { text: "Батарея и питание"; font.pixelSize: 24; font.bold: true; color: Theme.primary }
Label {
Layout.fillWidth: true
text: "Данные поступают от UPower. На устройствах без аккумулятора раздел скрыт."
wrapMode: Text.Wrap
color: Theme.outline
}
Label { text: "Яркость экрана"; font.bold: true; color: Theme.foreground }
Label { text: "Управление подсветкой через brightnessctl"; color: Theme.outline }
Repeater {
model: brightness.devices
ColumnLayout {
required property var modelData
Layout.fillWidth: true
Label { text: modelData.name + " · " + modelData.percent + "%"; color: Theme.foreground }
Slider {
Layout.fillWidth: true
from: 1; to: 100; stepSize: 1
value: modelData.percent
enabled: !brightness.busy
onMoved: brightness.setBrightness(modelData.name, Math.round(value))
}
}
}
Label { visible: brightness.devices.length === 0; text: "Подсветка не обнаружена"; color: Theme.outline }
Label { visible: brightness.error !== ""; text: brightness.error; wrapMode: Text.Wrap; color: "#d04040" }
Repeater {
model: Hardware.batteries
ColumnLayout {
id: batteryCard
required property var modelData
required property int index
Layout.fillWidth: true
spacing: 8
Label { text: "Аккумулятор " + (index + 1); font.bold: true; color: Theme.foreground }
RowLayout {
Layout.fillWidth: true
Label {
text: Math.round(batteryCard.modelData.percentage * 100) + "%"
font.pixelSize: 22
font.bold: true
color: Theme.primary
}
Item { Layout.fillWidth: true }
}
ProgressBar {
Layout.fillWidth: true
from: 0
to: 1
value: Math.max(0, Math.min(1, batteryCard.modelData.percentage || 0))
}
Label {
Layout.fillWidth: true
text: "Уровень заряда обновляется автоматически при изменении состояния устройства."
color: Theme.outline
wrapMode: Text.Wrap
}
}
}
Label {
Layout.fillWidth: true
visible: Hardware.batteries.length === 0
text: "Аккумулятор не обнаружен."
color: Theme.outline
}
}
}