BarTab/NSectionEditor: minor UI improvements

This commit is contained in:
LemmyCook 2025-08-31 22:55:51 -04:00
parent d910f30ed1
commit 6bcb85137b
2 changed files with 12 additions and 7 deletions

View file

@ -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()

View file

@ -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)
}
}
}