Files
noctalia-shell/Modules/Bar/Battery/BatteryPanel.qml
T
ItsLemmy 101b27fcc7 New windowing system
Large commit that totally refactor of the way we handle the bar and
panels.

Testing should focus on Panels, Bar, Keyboard Focus, IPC calls.

Changes brief:
- One NFullScreenWindow per screen which handle it's bar and dedicated
panels.
- Added shadows
- Reintroduced dimming
- New panels animations
- Proper Z ordering
- Panels on overlay laywer is not reimplemented, if we do it then the
bar will be on the Overlay too
- Panel dragging was not reimplemented, to be discussed before
reimplementing
- Still a WIP, need to work more on shadows and polishing + debugging.
2025-11-03 00:53:02 -05:00

137 lines
3.5 KiB
QML

import QtQuick
import QtQuick.Layouts
import QtQuick.Controls
import Quickshell
import Quickshell.Wayland
import qs.Commons
import qs.Services
import qs.Widgets
NPanel {
id: root
preferredWidth: 350 * Style.uiScaleRatio
preferredHeight: 210 * Style.uiScaleRatio
property var optionsModel: []
function updateOptionsModel() {
let newOptions = [{
"id": BatteryService.ChargingMode.Full,
"label": "battery.panel.full"
}, {
"id": BatteryService.ChargingMode.Balanced,
"label": "battery.panel.balanced"
}, {
"id": BatteryService.ChargingMode.Lifespan,
"label": "battery.panel.lifespan"
}]
root.optionsModel = newOptions
}
onOpened: {
updateOptionsModel()
}
panelContent: Item {
anchors.fill: parent
ColumnLayout {
anchors.fill: parent
anchors.margins: Style.marginM
spacing: Style.marginM
// HEADER
NBox {
Layout.fillWidth: true
Layout.preferredHeight: header.implicitHeight + Style.marginM * 2
RowLayout {
id: header
anchors.fill: parent
anchors.margins: Style.marginM
spacing: Style.marginM
NText {
text: I18n.tr("battery.panel.title")
pointSize: Style.fontSizeL
font.weight: Style.fontWeightBold
color: Color.mOnSurface
Layout.fillWidth: true
}
NToggle {
id: batteryManagerSwitch
checked: BatteryService.chargingMode !== BatteryService.ChargingMode.Disabled
onToggled: checked => BatteryService.toggleEnabled(checked)
baseSize: Style.baseWidgetSize * 0.65
}
NIconButton {
icon: "close"
tooltipText: I18n.tr("tooltips.close")
baseSize: Style.baseWidgetSize * 0.8
onClicked: {
root.close()
}
}
}
}
ButtonGroup {
id: batteryGroup
}
NBox {
Layout.fillWidth: true
Layout.fillHeight: true
ColumnLayout {
anchors.fill: parent
anchors.margins: Style.marginM
spacing: Style.marginM
Repeater {
model: optionsModel
NRadioButton {
visible: BatteryService.chargingMode !== BatteryService.ChargingMode.Disabled
ButtonGroup.group: batteryGroup
required property var modelData
text: I18n.tr(modelData.label, {
"percent": BatteryService.getThresholdValue(modelData.id)
})
checked: BatteryService.chargingMode === modelData.id
onClicked: {
BatteryService.setChargingMode(modelData.id)
}
Layout.fillWidth: true
}
}
}
ColumnLayout {
visible: BatteryService.chargingMode === BatteryService.ChargingMode.Disabled
anchors.fill: parent
spacing: Style.marginM
Item {
Layout.fillHeight: true
}
NText {
text: I18n.tr("battery.panel.disabled")
pointSize: Style.fontSizeL
color: Color.mOnSurfaceVariant
Layout.alignment: Qt.AlignHCenter
}
Item {
Layout.fillHeight: true
}
}
}
}
}
}