fix(ui): adapt icon position labels based on bar orientation

- Add barIsVertical property to BarWidgetSettingsDialog
- Pass barIsVertical from NSectionEditor to dialog
- Show Top/Bottom for vertical bar, Left/Right for horizontal bar
- Keep fallback to oppositeDirection when iconPosition not set
- Fix BarPillVertical iconPosition mapping (left=top, right=bottom)
This commit is contained in:
loner
2026-04-06 07:12:49 +08:00
parent 36a9d7afee
commit b6a85d88e7
5 changed files with 23 additions and 4 deletions
+2
View File
@@ -124,6 +124,8 @@
"icon-position-label": "Icon position",
"icon-position-left": "Left",
"icon-position-right": "Right",
"icon-position-top": "Top",
"icon-position-bottom": "Bottom",
"ipc-identifier-description": "Unique identifier for IPC commands. Use this identifier with 'qs -c noctalia-shell ipc call cb [action] [identifier]' to control this button via IPC.",
"ipc-identifier-label": "IPC Identifier",
"left-click-description": "Command to execute when the button is left-clicked.",
+3 -2
View File
@@ -50,8 +50,9 @@ Item {
readonly property int maxPillHeight: rotateText ? Math.max(1, Math.round(textItem.implicitWidth + Style.margin2M + Math.round(iconCircle.height / 4))) : Math.max(1, Math.round(textItem.implicitHeight + Style.margin2M))
// Determine pill direction based on icon position (fallback to oppositeDirection if not set)
readonly property bool openDownward: iconPosition === "right" || (iconPosition === "" && oppositeDirection)
readonly property bool openUpward: iconPosition === "left" || (iconPosition === "" && !oppositeDirection)
// For vertical bar: iconPosition="left" (top) means icon at top, text expands downward
readonly property bool openDownward: (iconPosition === "left" || iconPosition === "right") ? (iconPosition === "left") : oppositeDirection
readonly property bool openUpward: (iconPosition === "left" || iconPosition === "right") ? (iconPosition === "right") : !oppositeDirection
// Effective shown state (true if animated open or forced, but not if force closed)
readonly property bool revealed: !forceClose && (forceOpen || showPill)
@@ -15,6 +15,7 @@ Popup {
property string widgetId: ""
property string sectionId: ""
property var screen: null
property bool barIsVertical: false
property var settingsCache: ({})
readonly property real maxHeight: (screen ? screen.height : (parent ? parent.height : 800)) * 0.8
@@ -185,6 +186,7 @@ Popup {
}
settingsLoader.setSource(source, {
"screen": screen,
"barIsVertical": barIsVertical,
"widgetData": currentWidgetData,
"widgetMetadata": BarWidgetRegistry.widgetMetadata[widgetId]
});
@@ -17,6 +17,9 @@ ColumnLayout {
signal settingsChanged(var settings)
// Bar orientation (per-screen) - passed from parent
property bool barIsVertical: false
property string valueIcon: widgetData.icon !== undefined ? widgetData.icon : widgetMetadata.icon
property string valueIconPosition: widgetData.iconPosition !== undefined ? widgetData.iconPosition : widgetMetadata.iconPosition
property bool valueTextStream: widgetData.textStream !== undefined ? widgetData.textStream : widgetMetadata.textStream
@@ -101,9 +104,19 @@ ColumnLayout {
NComboBox {
id: iconPositionComboBox
visible: valueShowIcon
label: I18n.tr("bar.custom-button.icon-position-label")
description: I18n.tr("bar.custom-button.icon-position-description")
model: [
model: barIsVertical ? [
{
name: I18n.tr("bar.custom-button.icon-position-top"),
key: "left"
},
{
name: I18n.tr("bar.custom-button.icon-position-bottom"),
key: "right"
}
] : [
{
name: I18n.tr("bar.custom-button.icon-position-left"),
key: "left"
+2 -1
View File
@@ -267,7 +267,8 @@ NBox {
"widgetData": widgetData,
"widgetId": widgetData.id,
"sectionId": root.sectionId,
"screen": root.screen
"screen": root.screen,
"barIsVertical": root.barIsVertical
});
if (dialog) {