Panels: implemented snapping to screen edges.

WallpaperPanel: settings to position the panel (similar to launcher)
This commit is contained in:
ItsLemmy
2025-11-03 15:21:05 -05:00
parent f46bb95274
commit 9f656829b1
9 changed files with 248 additions and 130 deletions
+1 -1
View File
@@ -17,7 +17,7 @@ NPanel {
property bool localInputVolumeChanging: false
preferredWidth: 380 * Style.uiScaleRatio
preferredHeight: 500 * Style.uiScaleRatio
preferredHeight: 420 * Style.uiScaleRatio
// Connections to update local volumes when AudioService changes
Connections {
+17 -7
View File
@@ -20,13 +20,23 @@ NPanel {
panelKeyboardFocus: true // Needs Exclusive focus for text input
// Positioning
readonly property string launcherPosition: Settings.data.appLauncher.position
panelAnchorHorizontalCenter: launcherPosition === "center" || launcherPosition.endsWith("_center")
panelAnchorVerticalCenter: launcherPosition === "center"
panelAnchorLeft: launcherPosition !== "center" && launcherPosition.endsWith("_left")
panelAnchorRight: launcherPosition !== "center" && launcherPosition.endsWith("_right")
panelAnchorBottom: launcherPosition.startsWith("bottom_")
panelAnchorTop: launcherPosition.startsWith("top_")
readonly property string panelPosition: {
if (Settings.data.appLauncher.position === "follow_bar") {
if (Settings.data.bar.position === "left" || Settings.data.bar.position === "right") {
return `center_${Settings.data.bar.position}`
} else {
return `${Settings.data.bar.position}_center`
}
} else {
return Settings.data.appLauncher.position
}
}
panelAnchorHorizontalCenter: panelPosition === "center" || panelPosition.endsWith("_center")
panelAnchorVerticalCenter: panelPosition === "center"
panelAnchorLeft: panelPosition !== "center" && panelPosition.endsWith("_left")
panelAnchorRight: panelPosition !== "center" && panelPosition.endsWith("_right")
panelAnchorBottom: panelPosition.startsWith("bottom_")
panelAnchorTop: panelPosition.startsWith("top_")
// Core state
property string searchText: ""
+3 -1
View File
@@ -15,11 +15,13 @@ ColumnLayout {
}
NComboBox {
id: launcherPosition
label: I18n.tr("settings.launcher.settings.position.label")
description: I18n.tr("settings.launcher.settings.position.description")
Layout.fillWidth: true
model: [{
"key": "follow_bar",
"name": I18n.tr("options.launcher.position.follow_bar")
}, {
"key": "center",
"name": I18n.tr("options.launcher.position.center")
}, {
+35
View File
@@ -103,6 +103,41 @@ ColumnLayout {
}
}
}
NComboBox {
label: I18n.tr("settings.wallpaper.settings.selector-position.label")
description: I18n.tr("settings.wallpaper.settings.selector-position.description")
Layout.fillWidth: true
model: [{
"key": "follow_bar",
"name": I18n.tr("options.launcher.position.follow_bar")
}, {
"key": "center",
"name": I18n.tr("options.launcher.position.center")
}, {
"key": "top_center",
"name": I18n.tr("options.launcher.position.top_center")
}, {
"key": "top_left",
"name": I18n.tr("options.launcher.position.top_left")
}, {
"key": "top_right",
"name": I18n.tr("options.launcher.position.top_right")
}, {
"key": "bottom_left",
"name": I18n.tr("options.launcher.position.bottom_left")
}, {
"key": "bottom_right",
"name": I18n.tr("options.launcher.position.bottom_right")
}, {
"key": "bottom_center",
"name": I18n.tr("options.launcher.position.bottom_center")
}]
currentKey: Settings.data.wallpaper.panelPosition
onSelected: function (key) {
Settings.data.wallpaper.panelPosition = key
}
}
}
NDivider {
+18 -10
View File
@@ -17,17 +17,25 @@ NPanel {
preferredWidthRatio: 0.5
preferredHeightRatio: 0.45
// Positioning - Use launcher position. This saves a setting...
readonly property string launcherPosition: Settings.data.appLauncher.position
panelAnchorHorizontalCenter: launcherPosition === "center" || launcherPosition.endsWith("_center")
panelAnchorVerticalCenter: launcherPosition === "center"
panelAnchorLeft: launcherPosition !== "center" && launcherPosition.endsWith("_left")
panelAnchorRight: launcherPosition !== "center" && launcherPosition.endsWith("_right")
panelAnchorBottom: launcherPosition.startsWith("bottom_")
panelAnchorTop: launcherPosition.startsWith("top_")
// Positioning
readonly property string panelPosition: {
if (Settings.data.wallpaper.panelPosition === "follow_bar") {
if (Settings.data.bar.position === "left" || Settings.data.bar.position === "right") {
return `center_${Settings.data.bar.position}`
} else {
return `${Settings.data.bar.position}_center`
}
} else {
return Settings.data.wallpaper.panelPosition
}
}
panelAnchorHorizontalCenter: panelPosition === "center" || panelPosition.endsWith("_center")
panelAnchorVerticalCenter: panelPosition === "center"
panelAnchorLeft: panelPosition !== "center" && panelPosition.endsWith("_left")
panelAnchorRight: panelPosition !== "center" && panelPosition.endsWith("_right")
panelAnchorBottom: panelPosition.startsWith("bottom_")
panelAnchorTop: panelPosition.startsWith("top_")
// panelAnchorHorizontalCenter: true
// panelAnchorVerticalCenter: true
panelKeyboardFocus: true // Needs Exclusive focus for text input (search)
// Store direct reference to content for instant access