mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-08-04 12:38:31 -04:00
refactor(battery): align status layout and add individual notification types (#2743)
* refactor(battery): restore status list layout and add individual notification types * settings/battery: fix RTL display of top tablular-like view --------- Co-authored-by: bbedward <bbedward@gmail.com>
This commit is contained in:
@@ -52,9 +52,12 @@ done
|
||||
settingKey: "batteryStatusCard"
|
||||
|
||||
Column {
|
||||
width: parent.width
|
||||
width: parent.width - Theme.spacingM * 2
|
||||
x: Theme.spacingM
|
||||
spacing: Theme.spacingM
|
||||
|
||||
SettingsDivider {}
|
||||
|
||||
Row {
|
||||
width: parent.width
|
||||
StyledText {
|
||||
@@ -62,6 +65,7 @@ done
|
||||
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")
|
||||
@@ -69,15 +73,11 @@ done
|
||||
font.weight: Font.Medium
|
||||
color: Theme.surfaceText
|
||||
width: parent.width / 2
|
||||
horizontalAlignment: Text.AlignLeft
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
width: parent.width
|
||||
height: 1
|
||||
color: Theme.outline
|
||||
opacity: 0.1
|
||||
}
|
||||
SettingsDivider {}
|
||||
|
||||
Row {
|
||||
width: parent.width
|
||||
@@ -86,6 +86,7 @@ done
|
||||
font.pixelSize: Theme.fontSizeMedium
|
||||
color: Theme.surfaceVariantText
|
||||
width: parent.width / 2
|
||||
horizontalAlignment: Text.AlignLeft
|
||||
}
|
||||
StyledText {
|
||||
text: `${BatteryService.batteryLevel}%`
|
||||
@@ -93,15 +94,11 @@ done
|
||||
font.weight: Font.Medium
|
||||
color: Theme.surfaceText
|
||||
width: parent.width / 2
|
||||
horizontalAlignment: Text.AlignLeft
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
width: parent.width
|
||||
height: 1
|
||||
color: Theme.outline
|
||||
opacity: 0.1
|
||||
}
|
||||
SettingsDivider {}
|
||||
|
||||
Row {
|
||||
width: parent.width
|
||||
@@ -110,6 +107,7 @@ done
|
||||
font.pixelSize: Theme.fontSizeMedium
|
||||
color: Theme.surfaceVariantText
|
||||
width: parent.width / 2
|
||||
horizontalAlignment: Text.AlignLeft
|
||||
}
|
||||
StyledText {
|
||||
text: BatteryService.batteryStatus
|
||||
@@ -117,15 +115,11 @@ done
|
||||
font.weight: Font.Medium
|
||||
color: Theme.surfaceText
|
||||
width: parent.width / 2
|
||||
horizontalAlignment: Text.AlignLeft
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
width: parent.width
|
||||
height: 1
|
||||
color: Theme.outline
|
||||
opacity: 0.1
|
||||
}
|
||||
SettingsDivider {}
|
||||
|
||||
Row {
|
||||
width: parent.width
|
||||
@@ -134,6 +128,7 @@ done
|
||||
font.pixelSize: Theme.fontSizeMedium
|
||||
color: Theme.surfaceVariantText
|
||||
width: parent.width / 2
|
||||
horizontalAlignment: Text.AlignLeft
|
||||
}
|
||||
StyledText {
|
||||
text: BatteryService.formatTimeRemaining()
|
||||
@@ -141,15 +136,11 @@ done
|
||||
font.weight: Font.Medium
|
||||
color: Theme.surfaceText
|
||||
width: parent.width / 2
|
||||
horizontalAlignment: Text.AlignLeft
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
width: parent.width
|
||||
height: 1
|
||||
color: Theme.outline
|
||||
opacity: 0.1
|
||||
}
|
||||
SettingsDivider {}
|
||||
|
||||
Row {
|
||||
width: parent.width
|
||||
@@ -158,6 +149,7 @@ done
|
||||
font.pixelSize: Theme.fontSizeMedium
|
||||
color: Theme.surfaceVariantText
|
||||
width: parent.width / 2
|
||||
horizontalAlignment: Text.AlignLeft
|
||||
}
|
||||
StyledText {
|
||||
text: BatteryService.batteryHealth
|
||||
@@ -165,6 +157,7 @@ done
|
||||
font.weight: Font.Medium
|
||||
color: Theme.surfaceText
|
||||
width: parent.width / 2
|
||||
horizontalAlignment: Text.AlignLeft
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -174,7 +167,7 @@ done
|
||||
SettingsCard {
|
||||
width: parent.width
|
||||
iconName: "tune"
|
||||
title: I18n.tr("Battery Protection & Charging")
|
||||
title: I18n.tr("Battery Protection")
|
||||
settingKey: "batteryProtection"
|
||||
|
||||
SettingsSliderRow {
|
||||
@@ -191,7 +184,12 @@ done
|
||||
Row {
|
||||
width: parent.width
|
||||
height: applyButton.height
|
||||
layoutDirection: Qt.RightToLeft
|
||||
layoutDirection: I18n.isRtl ? Qt.LeftToRight : Qt.RightToLeft
|
||||
|
||||
Item {
|
||||
width: Theme.spacingM
|
||||
height: 1
|
||||
}
|
||||
|
||||
DankButton {
|
||||
id: applyButton
|
||||
@@ -213,12 +211,27 @@ done
|
||||
onToggled: checked => SettingsData.set("batteryNotifyChargeLimit", checked)
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
width: parent.width
|
||||
height: 1
|
||||
color: Theme.outline
|
||||
opacity: 0.15
|
||||
SettingsButtonGroupRow {
|
||||
settingKey: "batteryChargeLimitNotificationType"
|
||||
text: I18n.tr("Notification Type")
|
||||
description: I18n.tr("Choose how to be notified when charge limit is reached.")
|
||||
model: [I18n.tr("Toast"), I18n.tr("Notification")]
|
||||
visible: SettingsData.batteryNotifyChargeLimit
|
||||
currentIndex: SettingsData.batteryChargeLimitNotificationType
|
||||
onSelectionChanged: (index, selected) => {
|
||||
if (selected) {
|
||||
SettingsData.set("batteryChargeLimitNotificationType", index);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 3. Battery Alerts Card
|
||||
SettingsCard {
|
||||
width: parent.width
|
||||
iconName: "notifications"
|
||||
title: I18n.tr("Battery Alerts")
|
||||
settingKey: "batteryAlerts"
|
||||
|
||||
SettingsSliderRow {
|
||||
settingKey: "batteryLowThreshold"
|
||||
@@ -240,39 +253,29 @@ done
|
||||
}
|
||||
|
||||
SettingsButtonGroupRow {
|
||||
settingKey: "batteryNotificationType"
|
||||
settingKey: "batteryLowNotificationType"
|
||||
text: I18n.tr("Notification Type")
|
||||
description: I18n.tr("Choose how to be notified about battery alerts.")
|
||||
description: I18n.tr("Choose how to be notified about low battery alerts.")
|
||||
model: [I18n.tr("Toast"), I18n.tr("Notification")]
|
||||
currentIndex: SettingsData.batteryNotificationType
|
||||
visible: SettingsData.batteryNotifyLow
|
||||
currentIndex: SettingsData.batteryLowNotificationType
|
||||
onSelectionChanged: (index, selected) => {
|
||||
if (selected) {
|
||||
SettingsData.set("batteryNotificationType", index);
|
||||
SettingsData.set("batteryLowNotificationType", index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SettingsToggleRow {
|
||||
settingKey: "batteryAutoPowerSaver"
|
||||
text: I18n.tr("Auto Power Saver")
|
||||
description: I18n.tr("Automatically turn on Power Saver profile when battery is low.")
|
||||
checked: SettingsData.batteryAutoPowerSaver
|
||||
onToggled: checked => SettingsData.set("batteryAutoPowerSaver", checked)
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
width: parent.width
|
||||
height: 1
|
||||
color: Theme.outline
|
||||
opacity: 0.15
|
||||
}
|
||||
SettingsDivider {}
|
||||
|
||||
StyledText {
|
||||
text: I18n.tr("Critical Battery Alert")
|
||||
font.pixelSize: Theme.fontSizeMedium
|
||||
font.weight: Font.DemiBold
|
||||
color: Theme.surfaceText
|
||||
topPadding: Theme.spacingM
|
||||
x: Theme.spacingM
|
||||
width: parent.width - Theme.spacingM * 2
|
||||
topPadding: Theme.spacingS
|
||||
}
|
||||
|
||||
SettingsSliderRow {
|
||||
@@ -293,14 +296,38 @@ done
|
||||
checked: SettingsData.batteryNotifyCritical
|
||||
onToggled: checked => SettingsData.set("batteryNotifyCritical", checked)
|
||||
}
|
||||
|
||||
SettingsButtonGroupRow {
|
||||
settingKey: "batteryCriticalNotificationType"
|
||||
text: I18n.tr("Notification Type")
|
||||
description: I18n.tr("Choose how to be notified about critical battery alerts.")
|
||||
model: [I18n.tr("Toast"), I18n.tr("Notification")]
|
||||
visible: SettingsData.batteryNotifyCritical
|
||||
currentIndex: SettingsData.batteryCriticalNotificationType
|
||||
onSelectionChanged: (index, selected) => {
|
||||
if (selected) {
|
||||
SettingsData.set("batteryCriticalNotificationType", index);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 3. Power Profiles Card
|
||||
// 4. Power Profiles & Saving Card
|
||||
SettingsCard {
|
||||
width: parent.width
|
||||
iconName: "power"
|
||||
title: I18n.tr("Power Profiles Auto-Switching")
|
||||
settingKey: "powerProfilesAuto"
|
||||
title: I18n.tr("Power Profiles & Saving")
|
||||
settingKey: "powerProfilesSaving"
|
||||
|
||||
SettingsToggleRow {
|
||||
settingKey: "batteryAutoPowerSaver"
|
||||
text: I18n.tr("Auto Power Saver")
|
||||
description: I18n.tr("Automatically turn on Power Saver profile when battery is low.")
|
||||
checked: SettingsData.batteryAutoPowerSaver
|
||||
onToggled: checked => SettingsData.set("batteryAutoPowerSaver", checked)
|
||||
}
|
||||
|
||||
SettingsDivider {}
|
||||
|
||||
SettingsDropdownRow {
|
||||
settingKey: "acProfileName"
|
||||
|
||||
Reference in New Issue
Block a user