From 6bcb85137b2d41426d93fa0f93433755e4fb2935 Mon Sep 17 00:00:00 2001 From: LemmyCook Date: Sun, 31 Aug 2025 22:55:51 -0400 Subject: [PATCH] BarTab/NSectionEditor: minor UI improvements --- Modules/SettingsPanel/Tabs/BarTab.qml | 4 ++++ Widgets/NSectionEditor.qml | 15 ++++++++------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/Modules/SettingsPanel/Tabs/BarTab.qml b/Modules/SettingsPanel/Tabs/BarTab.qml index f000705..b1d064d 100644 --- a/Modules/SettingsPanel/Tabs/BarTab.qml +++ b/Modules/SettingsPanel/Tabs/BarTab.qml @@ -158,6 +158,7 @@ ColumnLayout { // Left Section NSectionEditor { sectionName: "Left" + sectionId: "left" widgetModel: Settings.data.bar.widgets.left availableWidgets: availableWidgets onAddWidget: (widgetName, section) => addWidgetToSection(widgetName, section) @@ -168,6 +169,7 @@ ColumnLayout { // Center Section NSectionEditor { sectionName: "Center" + sectionId: "center" widgetModel: Settings.data.bar.widgets.center availableWidgets: availableWidgets onAddWidget: (widgetName, section) => addWidgetToSection(widgetName, section) @@ -178,6 +180,7 @@ ColumnLayout { // Right Section NSectionEditor { sectionName: "Right" + sectionId: "right" widgetModel: Settings.data.bar.widgets.right availableWidgets: availableWidgets onAddWidget: (widgetName, section) => addWidgetToSection(widgetName, section) @@ -197,6 +200,7 @@ ColumnLayout { function addWidgetToSection(widgetName, section) { //Logger.log("BarTab", "Adding widget", widgetName, "to section", section) var sectionArray = Settings.data.bar.widgets[section] + if (sectionArray) { // Create a new array to avoid modifying the original var newArray = sectionArray.slice() diff --git a/Widgets/NSectionEditor.qml b/Widgets/NSectionEditor.qml index 55c9ce8..c878eeb 100644 --- a/Widgets/NSectionEditor.qml +++ b/Widgets/NSectionEditor.qml @@ -8,6 +8,7 @@ NBox { id: root property string sectionName: "" + property string sectionId: "" property var widgetModel: [] property var availableWidgets: [] @@ -73,7 +74,7 @@ NBox { model: availableWidgets label: "" description: "" - placeholder: "Add widget to the " + sectionName.toLowerCase() + " section..." + placeholder: "Select a widget to add..." onSelected: key => { comboBox.currentKey = key } @@ -88,12 +89,12 @@ NBox { colorBgHover: Color.mSecondary colorFgHover: Color.mOnSecondary enabled: comboBox.currentKey !== "" - tooltipText: "Add widget to this section" + tooltipText: "Add widget to section" Layout.alignment: Qt.AlignVCenter Layout.leftMargin: Style.marginS * scaling onClicked: { if (comboBox.currentKey !== "") { - addWidget(comboBox.currentKey, sectionName.toLowerCase()) + addWidget(comboBox.currentKey, sectionId) comboBox.currentKey = "" } } @@ -167,7 +168,7 @@ NBox { colorBgHover: Color.applyOpacity(Color.mOnPrimary, "40") colorFgHover: Color.mOnPrimary onClicked: { - removeWidget(sectionName.toLowerCase(), index) + removeWidget(sectionId, index) } } } @@ -239,7 +240,7 @@ NBox { // "NSectionEditor", // `Dropped widget from index ${fromIndex} to position ${toIndex} (distance: ${minDistance.toFixed( // 2)})`) - reorderWidget(sectionName.toLowerCase(), fromIndex, toIndex) + reorderWidget(sectionId, fromIndex, toIndex) } else { Logger.warn("NSectionEditor", `No valid drop target found for widget at index ${index}`) } @@ -277,7 +278,7 @@ NBox { const toIndex = 0 // Insert at the beginning if (fromIndex !== toIndex) { //Logger.log("NSectionEditor", `Dropped widget from index ${fromIndex} to beginning`) - reorderWidget(sectionName.toLowerCase(), fromIndex, toIndex) + reorderWidget(sectionId, fromIndex, toIndex) } } } @@ -311,7 +312,7 @@ NBox { const toIndex = widgetModel.length // Insert at the end if (fromIndex !== toIndex) { //Logger.log("NSectionEditor", `Dropped widget from index ${fromIndex} to end`) - reorderWidget(sectionName.toLowerCase(), fromIndex, toIndex) + reorderWidget(sectionId, fromIndex, toIndex) } } }