diff --git a/Modules/Bar/Widgets/Battery.qml b/Modules/Bar/Widgets/Battery.qml index d0c5c474..b9c36c1f 100644 --- a/Modules/Bar/Widgets/Battery.qml +++ b/Modules/Bar/Widgets/Battery.qml @@ -122,7 +122,8 @@ Item { forceOpen: isReady && (testMode || battery.isLaptopBattery) && displayMode === "alwaysShow" forceClose: displayMode === "alwaysHide" || !isReady || (!testMode && !battery.isLaptopBattery) customBackgroundColor: isLowBattery ? Color.mError : Qt.rgba(0, 0, 0, 0) - customTextIconColor: isLowBattery ? Color.mOnError : Qt.rgba(0, 0, 0, 0) + customTextIconColor: isLowBattery ? Color.mOnError : charging ? Color.mPrimary : Qt.rgba(0, 0, 0, 0) + tooltipText: { let lines = []; if (testMode) { diff --git a/Modules/Panels/Battery/BatteryPanel.qml b/Modules/Panels/Battery/BatteryPanel.qml index 69a5b30d..dcac2cbd 100644 --- a/Modules/Panels/Battery/BatteryPanel.qml +++ b/Modules/Panels/Battery/BatteryPanel.qml @@ -22,6 +22,7 @@ SmartPanel { readonly property bool healthSupported: isReady && battery.healthSupported readonly property bool healthAvailable: healthSupported readonly property int healthPercent: healthAvailable ? Math.round(battery.healthPercentage) : -1 + readonly property bool powerProfileAvailable: PowerProfileService.available readonly property var powerProfiles: [PowerProfile.PowerSaver, PowerProfile.Balanced, PowerProfile.Performance] readonly property string timeText: { if (!isReady) @@ -65,7 +66,7 @@ SmartPanel { NIcon { pointSize: Style.fontSizeXXL - color: Color.mPrimary + color: root.charging ? Color.mPrimary : Color.mOnSurface icon: iconName } @@ -102,26 +103,44 @@ SmartPanel { // Charge level + health/time NBox { Layout.fillWidth: true - implicitHeight: chargeLayout.implicitHeight + Style.marginM * 2 + height: chargeLayout.implicitHeight + Style.marginL * 2 ColumnLayout { id: chargeLayout anchors.fill: parent - anchors.margins: Style.marginM + anchors.margins: Style.marginL spacing: Style.marginS RowLayout { Layout.fillWidth: true spacing: Style.marginS - NText { - text: I18n.tr("battery.charge-level") - color: Color.mOnSurfaceVariant - pointSize: Style.fontSizeS - } - Item { - Layout.fillWidth: true + ColumnLayout { + NText { + text: I18n.tr("battery.charge-level") + color: Color.mOnSurface + pointSize: Style.fontSizeS + } + + Rectangle { + Layout.fillWidth: true + height: Math.round(8 * Style.uiScaleRatio) + radius: height / 2 + color: Color.mSurfaceVariant + + Rectangle { + anchors.verticalCenter: parent.verticalCenter + height: parent.height + radius: parent.radius + width: { + var ratio = Math.max(0, Math.min(1, percent / 100)); + return parent.width * ratio; + } + color: Color.mPrimary + } + } } + NText { text: percent >= 0 ? `${percent}%` : "--" color: Color.mOnSurface @@ -130,24 +149,6 @@ SmartPanel { } } - Rectangle { - Layout.fillWidth: true - height: Math.round(8 * Style.uiScaleRatio) - radius: height / 2 - color: Color.mSurfaceVariant - - Rectangle { - anchors.verticalCenter: parent.verticalCenter - height: parent.height - radius: parent.radius - width: { - var ratio = Math.max(0, Math.min(1, percent / 100)); - return parent.width * ratio; - } - color: Color.mPrimary - } - } - RowLayout { Layout.fillWidth: true spacing: Style.marginL @@ -169,7 +170,7 @@ SmartPanel { // Power profile and idle inhibit controls NBox { Layout.fillWidth: true - implicitHeight: controlsLayout.implicitHeight + Style.marginM * 2 + height: controlsLayout.implicitHeight + Style.marginM * 2 ColumnLayout { id: controlsLayout @@ -177,41 +178,46 @@ SmartPanel { anchors.margins: Style.marginM spacing: Style.marginM - RowLayout { - Layout.fillWidth: true - spacing: Style.marginS - NIcon { - icon: PowerProfileService.getIcon() - pointSize: Style.fontSizeM - color: Color.mPrimary - } - NText { - text: I18n.tr("battery.power-profile") - font.weight: Style.fontWeightBold - color: Color.mOnSurface - Layout.fillWidth: true - } - NText { - text: PowerProfileService.getName(profileIndex) - color: Color.mOnSurfaceVariant - } - } + ColumnLayout { + id: ppd + visible: root.powerProfileAvailable - NValueSlider { - Layout.fillWidth: true - from: 0 - to: 2 - stepSize: 1 - snapAlways: true - value: profileIndex - enabled: profilesAvailable - onPressedChanged: function (pressed, v) { - if (!pressed) { - setProfileByIndex(v); + RowLayout { + Layout.fillWidth: true + spacing: Style.marginS + NIcon { + icon: PowerProfileService.getIcon() + pointSize: Style.fontSizeM + color: Color.mPrimary + } + NText { + text: I18n.tr("battery.power-profile") + font.weight: Style.fontWeightBold + color: Color.mOnSurface + Layout.fillWidth: true + } + NText { + text: PowerProfileService.getName(profileIndex) + color: Color.mOnSurfaceVariant } } - onMoved: function (v) { - profileIndex = v; + + NValueSlider { + Layout.fillWidth: true + from: 0 + to: 2 + stepSize: 1 + snapAlways: true + value: profileIndex + enabled: profilesAvailable + onPressedChanged: (pressed, v) => { + if (!pressed) { + setProfileByIndex(v); + } + } + onMoved: v => { + profileIndex = v; + } } }