BarTab/NSectionEditor: minor UI improvements
This commit is contained in:
parent
d910f30ed1
commit
6bcb85137b
2 changed files with 12 additions and 7 deletions
|
|
@ -158,6 +158,7 @@ ColumnLayout {
|
||||||
// Left Section
|
// Left Section
|
||||||
NSectionEditor {
|
NSectionEditor {
|
||||||
sectionName: "Left"
|
sectionName: "Left"
|
||||||
|
sectionId: "left"
|
||||||
widgetModel: Settings.data.bar.widgets.left
|
widgetModel: Settings.data.bar.widgets.left
|
||||||
availableWidgets: availableWidgets
|
availableWidgets: availableWidgets
|
||||||
onAddWidget: (widgetName, section) => addWidgetToSection(widgetName, section)
|
onAddWidget: (widgetName, section) => addWidgetToSection(widgetName, section)
|
||||||
|
|
@ -168,6 +169,7 @@ ColumnLayout {
|
||||||
// Center Section
|
// Center Section
|
||||||
NSectionEditor {
|
NSectionEditor {
|
||||||
sectionName: "Center"
|
sectionName: "Center"
|
||||||
|
sectionId: "center"
|
||||||
widgetModel: Settings.data.bar.widgets.center
|
widgetModel: Settings.data.bar.widgets.center
|
||||||
availableWidgets: availableWidgets
|
availableWidgets: availableWidgets
|
||||||
onAddWidget: (widgetName, section) => addWidgetToSection(widgetName, section)
|
onAddWidget: (widgetName, section) => addWidgetToSection(widgetName, section)
|
||||||
|
|
@ -178,6 +180,7 @@ ColumnLayout {
|
||||||
// Right Section
|
// Right Section
|
||||||
NSectionEditor {
|
NSectionEditor {
|
||||||
sectionName: "Right"
|
sectionName: "Right"
|
||||||
|
sectionId: "right"
|
||||||
widgetModel: Settings.data.bar.widgets.right
|
widgetModel: Settings.data.bar.widgets.right
|
||||||
availableWidgets: availableWidgets
|
availableWidgets: availableWidgets
|
||||||
onAddWidget: (widgetName, section) => addWidgetToSection(widgetName, section)
|
onAddWidget: (widgetName, section) => addWidgetToSection(widgetName, section)
|
||||||
|
|
@ -197,6 +200,7 @@ ColumnLayout {
|
||||||
function addWidgetToSection(widgetName, section) {
|
function addWidgetToSection(widgetName, section) {
|
||||||
//Logger.log("BarTab", "Adding widget", widgetName, "to section", section)
|
//Logger.log("BarTab", "Adding widget", widgetName, "to section", section)
|
||||||
var sectionArray = Settings.data.bar.widgets[section]
|
var sectionArray = Settings.data.bar.widgets[section]
|
||||||
|
|
||||||
if (sectionArray) {
|
if (sectionArray) {
|
||||||
// Create a new array to avoid modifying the original
|
// Create a new array to avoid modifying the original
|
||||||
var newArray = sectionArray.slice()
|
var newArray = sectionArray.slice()
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ NBox {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
property string sectionName: ""
|
property string sectionName: ""
|
||||||
|
property string sectionId: ""
|
||||||
property var widgetModel: []
|
property var widgetModel: []
|
||||||
property var availableWidgets: []
|
property var availableWidgets: []
|
||||||
|
|
||||||
|
|
@ -73,7 +74,7 @@ NBox {
|
||||||
model: availableWidgets
|
model: availableWidgets
|
||||||
label: ""
|
label: ""
|
||||||
description: ""
|
description: ""
|
||||||
placeholder: "Add widget to the " + sectionName.toLowerCase() + " section..."
|
placeholder: "Select a widget to add..."
|
||||||
onSelected: key => {
|
onSelected: key => {
|
||||||
comboBox.currentKey = key
|
comboBox.currentKey = key
|
||||||
}
|
}
|
||||||
|
|
@ -88,12 +89,12 @@ NBox {
|
||||||
colorBgHover: Color.mSecondary
|
colorBgHover: Color.mSecondary
|
||||||
colorFgHover: Color.mOnSecondary
|
colorFgHover: Color.mOnSecondary
|
||||||
enabled: comboBox.currentKey !== ""
|
enabled: comboBox.currentKey !== ""
|
||||||
tooltipText: "Add widget to this section"
|
tooltipText: "Add widget to section"
|
||||||
Layout.alignment: Qt.AlignVCenter
|
Layout.alignment: Qt.AlignVCenter
|
||||||
Layout.leftMargin: Style.marginS * scaling
|
Layout.leftMargin: Style.marginS * scaling
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (comboBox.currentKey !== "") {
|
if (comboBox.currentKey !== "") {
|
||||||
addWidget(comboBox.currentKey, sectionName.toLowerCase())
|
addWidget(comboBox.currentKey, sectionId)
|
||||||
comboBox.currentKey = ""
|
comboBox.currentKey = ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -167,7 +168,7 @@ NBox {
|
||||||
colorBgHover: Color.applyOpacity(Color.mOnPrimary, "40")
|
colorBgHover: Color.applyOpacity(Color.mOnPrimary, "40")
|
||||||
colorFgHover: Color.mOnPrimary
|
colorFgHover: Color.mOnPrimary
|
||||||
onClicked: {
|
onClicked: {
|
||||||
removeWidget(sectionName.toLowerCase(), index)
|
removeWidget(sectionId, index)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -239,7 +240,7 @@ NBox {
|
||||||
// "NSectionEditor",
|
// "NSectionEditor",
|
||||||
// `Dropped widget from index ${fromIndex} to position ${toIndex} (distance: ${minDistance.toFixed(
|
// `Dropped widget from index ${fromIndex} to position ${toIndex} (distance: ${minDistance.toFixed(
|
||||||
// 2)})`)
|
// 2)})`)
|
||||||
reorderWidget(sectionName.toLowerCase(), fromIndex, toIndex)
|
reorderWidget(sectionId, fromIndex, toIndex)
|
||||||
} else {
|
} else {
|
||||||
Logger.warn("NSectionEditor", `No valid drop target found for widget at index ${index}`)
|
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
|
const toIndex = 0 // Insert at the beginning
|
||||||
if (fromIndex !== toIndex) {
|
if (fromIndex !== toIndex) {
|
||||||
//Logger.log("NSectionEditor", `Dropped widget from index ${fromIndex} to beginning`)
|
//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
|
const toIndex = widgetModel.length // Insert at the end
|
||||||
if (fromIndex !== toIndex) {
|
if (fromIndex !== toIndex) {
|
||||||
//Logger.log("NSectionEditor", `Dropped widget from index ${fromIndex} to end`)
|
//Logger.log("NSectionEditor", `Dropped widget from index ${fromIndex} to end`)
|
||||||
reorderWidget(sectionName.toLowerCase(), fromIndex, toIndex)
|
reorderWidget(sectionId, fromIndex, toIndex)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue