Bar editor: removing the last ControlCenter triggers a toast warning.

This commit is contained in:
ItsLemmy
2025-09-25 21:54:51 -04:00
parent 95d059007e
commit 012ae28dd9
2 changed files with 12 additions and 3 deletions
+6 -2
View File
@@ -771,7 +771,7 @@
},
"section-editor": {
"placeholder": "Select a widget to add...",
"search-placeholder": "Search widgets..."
"search-placeholder": "Search widget..."
},
"active-window": {
"auto-hide": "Hide automatically",
@@ -1233,8 +1233,12 @@
"unmuted": "Unmuted"
},
"battery": {
"low": "Low Battery",
"low": "Low battery",
"low-desc": "Battery is at {percent}%. Please connect the charger."
},
"missing-control-center": {
"label": "Last Control Center widget removed",
"description": "The Control Center widget has been removed from the bar. To access it from the bar again, you will need to re-add the widget."
}
},
"weather": {
+6 -1
View File
@@ -314,8 +314,13 @@ ColumnLayout {
function _removeWidgetFromSection(section, index) {
if (index >= 0 && index < Settings.data.bar.widgets[section].length) {
var newArray = Settings.data.bar.widgets[section].slice()
newArray.splice(index, 1)
var removedWidgets = newArray.splice(index, 1)
Settings.data.bar.widgets[section] = newArray
// Check that we still have a control center
if (removedWidgets[0].id === "ControlCenter" && BarService.lookupWidget("ControlCenter") === undefined) {
ToastService.showWarning(I18n.tr("toast.missing-control-center.label"), I18n.tr("toast.missing-control-center.description"), 12000)
}
}
}