-
-
Notifications
You must be signed in to change notification settings - Fork 482
feat(settings): improve battery status layout #3103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 6 commits
dbd6e83
6515395
f2451b3
df40aa0
5a768b9
d1df7b3
7f32ebb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -8,6 +8,14 @@ import qs.Modules.Settings.Widgets | |||||
| Item { | ||||||
| id: root | ||||||
|
|
||||||
| readonly property color batteryStatusColor: { | ||||||
| if (BatteryService.isLowBattery && !BatteryService.isCharging) | ||||||
| return Theme.error; | ||||||
| if (BatteryService.isCharging || BatteryService.isPluggedIn) | ||||||
| return Theme.primary; | ||||||
| return Theme.surfaceText; | ||||||
| } | ||||||
|
|
||||||
| Process { | ||||||
| id: applyLimitProcess | ||||||
| command: ["pkexec", "sh", "-c", " | ||||||
|
|
@@ -47,8 +55,6 @@ done | |||||
| // 1. Information Card | ||||||
| SettingsCard { | ||||||
| width: parent.width | ||||||
| iconName: "battery_charging_full" | ||||||
| title: I18n.tr("Status") | ||||||
| settingKey: "batteryStatusCard" | ||||||
| tags: ["battery", "status", "charge", "health"] | ||||||
|
|
||||||
|
|
@@ -57,108 +63,131 @@ done | |||||
| x: Theme.spacingM | ||||||
| spacing: Theme.spacingM | ||||||
|
|
||||||
| SettingsDivider {} | ||||||
|
|
||||||
| Row { | ||||||
| width: parent.width | ||||||
| StyledText { | ||||||
| text: I18n.tr("Power source") | ||||||
| font.pixelSize: Theme.fontSizeMedium | ||||||
| color: Theme.surfaceVariantText | ||||||
| width: parent.width / 2 | ||||||
| horizontalAlignment: Text.AlignLeft | ||||||
| } | ||||||
| StyledText { | ||||||
| text: BatteryService.isPluggedIn ? I18n.tr("AC Adapter (Plugged In)") : I18n.tr("Battery Power") | ||||||
| font.pixelSize: Theme.fontSizeMedium | ||||||
| font.weight: Font.Medium | ||||||
| color: Theme.surfaceText | ||||||
| width: parent.width / 2 | ||||||
| horizontalAlignment: Text.AlignLeft | ||||||
| } | ||||||
| } | ||||||
| spacing: Theme.spacingM | ||||||
|
|
||||||
| SettingsDivider {} | ||||||
|
|
||||||
| Row { | ||||||
| width: parent.width | ||||||
| StyledText { | ||||||
| text: I18n.tr("Charge Level") | ||||||
| font.pixelSize: Theme.fontSizeMedium | ||||||
| color: Theme.surfaceVariantText | ||||||
| width: parent.width / 2 | ||||||
| horizontalAlignment: Text.AlignLeft | ||||||
| DankIcon { | ||||||
| name: BatteryService.getBatteryIcon() | ||||||
| size: Theme.iconSizeLarge | ||||||
| color: root.batteryStatusColor | ||||||
| anchors.verticalCenter: parent.verticalCenter | ||||||
| } | ||||||
| StyledText { | ||||||
| text: `${BatteryService.batteryLevel}%` | ||||||
| font.pixelSize: Theme.fontSizeMedium | ||||||
| font.weight: Font.Medium | ||||||
| color: Theme.surfaceText | ||||||
| width: parent.width / 2 | ||||||
| horizontalAlignment: Text.AlignLeft | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| SettingsDivider {} | ||||||
|
|
||||||
| Row { | ||||||
| width: parent.width | ||||||
| StyledText { | ||||||
| text: I18n.tr("Status") | ||||||
| font.pixelSize: Theme.fontSizeMedium | ||||||
| color: Theme.surfaceVariantText | ||||||
| width: parent.width / 2 | ||||||
| horizontalAlignment: Text.AlignLeft | ||||||
| } | ||||||
| StyledText { | ||||||
| text: BatteryService.batteryStatus | ||||||
| font.pixelSize: Theme.fontSizeMedium | ||||||
| font.weight: Font.Medium | ||||||
| color: Theme.surfaceText | ||||||
| width: parent.width / 2 | ||||||
| horizontalAlignment: Text.AlignLeft | ||||||
| Column { | ||||||
| spacing: Theme.spacingXS | ||||||
| width: parent.width - Theme.iconSizeLarge - Theme.spacingM | ||||||
| anchors.verticalCenter: parent.verticalCenter | ||||||
|
|
||||||
| Row { | ||||||
| spacing: Theme.spacingS | ||||||
| width: parent.width | ||||||
|
|
||||||
| StyledText { | ||||||
| text: BatteryService.batteryAvailable ? `${BatteryService.batteryLevel}%` : I18n.tr("Power") | ||||||
| font.pixelSize: Theme.fontSizeXLarge | ||||||
| font.weight: Font.Bold | ||||||
| color: root.batteryStatusColor | ||||||
| } | ||||||
|
|
||||||
| StyledText { | ||||||
| text: BatteryService.batteryAvailable ? BatteryService.batteryStatus : I18n.tr("Management") | ||||||
| font.pixelSize: Theme.fontSizeLarge | ||||||
| font.weight: Font.Medium | ||||||
| color: Theme.surfaceText | ||||||
| anchors.verticalCenter: parent.verticalCenter | ||||||
| elide: Text.ElideRight | ||||||
| width: Math.max(0, parent.width - 100) | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| StyledText { | ||||||
| text: BatteryService.isPluggedIn ? I18n.tr("Plugged In (AC)") : I18n.tr("Battery Power") | ||||||
| font.pixelSize: Theme.fontSizeSmall | ||||||
| color: Theme.surfaceTextMedium | ||||||
| width: parent.width | ||||||
| elide: Text.ElideRight | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| SettingsDivider {} | ||||||
|
|
||||||
| Row { | ||||||
| Item { | ||||||
| width: parent.width | ||||||
| StyledText { | ||||||
| text: I18n.tr("Estimated Time") | ||||||
| font.pixelSize: Theme.fontSizeMedium | ||||||
| color: Theme.surfaceVariantText | ||||||
| width: parent.width / 2 | ||||||
| horizontalAlignment: Text.AlignLeft | ||||||
| height: 4 | ||||||
|
|
||||||
| Rectangle { | ||||||
| anchors.fill: parent | ||||||
| radius: height / 2 | ||||||
| color: Theme.withAlpha(Theme.primary, 0.16) | ||||||
| } | ||||||
| StyledText { | ||||||
| text: BatteryService.formatTimeRemaining() | ||||||
| font.pixelSize: Theme.fontSizeMedium | ||||||
| font.weight: Font.Medium | ||||||
| color: Theme.surfaceText | ||||||
| width: parent.width / 2 | ||||||
| horizontalAlignment: Text.AlignLeft | ||||||
|
|
||||||
| Rectangle { | ||||||
| width: parent.width * Math.max(0, Math.min(1, BatteryService.batteryLevel / 100)) | ||||||
| height: parent.height | ||||||
| radius: height / 2 | ||||||
| color: root.batteryStatusColor | ||||||
| visible: BatteryService.batteryAvailable | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| SettingsDivider {} | ||||||
|
|
||||||
| Row { | ||||||
| width: parent.width | ||||||
| StyledText { | ||||||
| text: I18n.tr("Battery Health") | ||||||
| font.pixelSize: Theme.fontSizeMedium | ||||||
| color: Theme.surfaceVariantText | ||||||
| width: parent.width / 2 | ||||||
| horizontalAlignment: Text.AlignLeft | ||||||
| spacing: Theme.spacingM | ||||||
|
|
||||||
| Item { | ||||||
| width: (parent.width - Theme.spacingM) / 2 | ||||||
| height: timeColumn.implicitHeight | ||||||
|
|
||||||
| Column { | ||||||
| id: timeColumn | ||||||
| width: parent.width | ||||||
| spacing: Theme.spacingXXS | ||||||
|
|
||||||
| StyledText { | ||||||
| text: I18n.tr("Estimated time") | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These re-cased/reworded labels create brand-new untranslated terms and orphan already-translated ones. Please restore the exact existing terms:
Suggested change
|
||||||
| font.pixelSize: Theme.fontSizeSmall | ||||||
| color: Theme.surfaceTextMedium | ||||||
| } | ||||||
|
|
||||||
| StyledText { | ||||||
| text: { | ||||||
| const remaining = BatteryService.formatTimeRemaining(); | ||||||
| const estimated = BatteryService.formatEstimatedTime(); | ||||||
| return estimated ? `${remaining} (${estimated})` : remaining; | ||||||
| } | ||||||
| font.pixelSize: Theme.fontSizeMedium | ||||||
| font.weight: Font.Medium | ||||||
| color: Theme.surfaceText | ||||||
| width: parent.width | ||||||
| elide: Text.ElideRight | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
| StyledText { | ||||||
| text: BatteryService.batteryHealth | ||||||
| font.pixelSize: Theme.fontSizeMedium | ||||||
| font.weight: Font.Medium | ||||||
| color: Theme.surfaceText | ||||||
| width: parent.width / 2 | ||||||
| horizontalAlignment: Text.AlignLeft | ||||||
|
|
||||||
| Item { | ||||||
| width: (parent.width - Theme.spacingM) / 2 | ||||||
| height: healthColumn.implicitHeight | ||||||
|
|
||||||
| Column { | ||||||
| id: healthColumn | ||||||
| width: parent.width | ||||||
| spacing: Theme.spacingXXS | ||||||
|
|
||||||
| StyledText { | ||||||
| text: I18n.tr("Battery health") | ||||||
| font.pixelSize: Theme.fontSizeSmall | ||||||
| color: Theme.surfaceTextMedium | ||||||
| } | ||||||
|
|
||||||
| StyledText { | ||||||
| text: BatteryService.batteryHealth | ||||||
| font.pixelSize: Theme.fontSizeMedium | ||||||
| font.weight: Font.Medium | ||||||
| color: Theme.surfaceText | ||||||
| width: parent.width | ||||||
| elide: Text.ElideRight | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dropping
title:here breaks the settings-search label for this card.extract_settings_index.pyfalls back to the block's firsttext:when there's notitle(find_settings_components, lines 368-377), so it picked up the no-battery fallback string: the regenerated index now listsbatteryStatusCardas "Power" (and with no icon) instead of "Status". Users searching settings will see the battery card titled "Power" under the "Power & Security" tab, which reads as a different setting.If the header-less card is intentional, keep the searchable title but hide the header — or at minimum reorder so the first
text:in the block is a meaningful label rather than the!batteryAvailablefallback.