ControlCenter: fix/improve opening position

This commit is contained in:
ItsLemmy
2025-11-07 10:47:28 -05:00
parent 03425f4260
commit 19463f4395
4 changed files with 42 additions and 28 deletions
+7 -5
View File
@@ -178,11 +178,13 @@ Item {
preventStealing: true
onClicked: function (mouse) {
if (mouse.button === Qt.RightButton) {
// Look up for any ControlCenter button on this bar
var widget = BarService.lookupWidget("ControlCenter", root.screen.name)
// Open the panel near the button if any
PanelService.getPanel("controlCenterPanel", root.screen)?.toggle(widget)
var controlCenterPanel = PanelService.getPanel("controlCenterPanel", screen)
if (Settings.data.controlCenter.position === "close_to_bar_button") {
// Will attempt to open the panel next to the bar button if any.
controlCenterPanel?.toggle(null, "ControlCenter")
} else {
controlCenterPanel?.toggle()
}
mouse.accepted = true
}
}
+16 -2
View File
@@ -286,7 +286,14 @@ Item {
var rightBarEdge = root.width - root.barMarginH - Style.barHeight
calculatedX = rightBarEdge - panelWidth
} else if (panelContent.couldAttach) {
calculatedX = root.width - panelWidth
// Account for corner inset when bar is floating, horizontal, AND panel is on same edge as bar
var panelOnSameEdgeAsBar = (root.barPosition === "top" && root.effectivePanelAnchorTop) || (root.barPosition === "bottom" && root.effectivePanelAnchorBottom)
if (!root.barIsVertical && root.barFloating && panelOnSameEdgeAsBar) {
var rightCornerInset = Style.radiusL * 2
calculatedX = root.width - root.barMarginH - rightCornerInset - panelWidth
} else {
calculatedX = root.width - panelWidth
}
} else {
calculatedX = root.width - panelWidth - Style.marginL
}
@@ -295,7 +302,14 @@ Item {
var leftBarEdge = root.barMarginH + Style.barHeight
calculatedX = leftBarEdge
} else if (panelContent.couldAttach) {
calculatedX = 0
// Account for corner inset when bar is floating, horizontal, AND panel is on same edge as bar
var panelOnSameEdgeAsBar = (root.barPosition === "top" && root.effectivePanelAnchorTop) || (root.barPosition === "bottom" && root.effectivePanelAnchorBottom)
if (!root.barIsVertical && root.barFloating && panelOnSameEdgeAsBar) {
var leftCornerInset = Style.radiusL * 2
calculatedX = root.barMarginH + leftCornerInset
} else {
calculatedX = 0
}
} else {
calculatedX = Style.marginL
}
@@ -11,8 +11,24 @@ import qs.Modules.Panels.ControlCenter.Cards
SmartPanel {
id: root
panelAnchorHorizontalCenter: true
panelAnchorVerticalCenter: true
// Positioning
readonly property string controlCenterPosition: Settings.data.controlCenter.position
// Check if there's a bar on this screen
readonly property bool hasBarOnScreen: {
var monitors = Settings.data.bar.monitors || []
return monitors.length === 0 || monitors.includes(screen?.name)
}
// When position is "close_to_bar_button" but there's no bar, fall back to center
readonly property bool shouldCenter: controlCenterPosition === "close_to_bar_button" && !hasBarOnScreen
panelAnchorHorizontalCenter: shouldCenter || (controlCenterPosition !== "close_to_bar_button" && (controlCenterPosition.endsWith("_center") || controlCenterPosition === "center"))
panelAnchorVerticalCenter: shouldCenter || controlCenterPosition === "center"
panelAnchorLeft: !shouldCenter && controlCenterPosition !== "close_to_bar_button" && controlCenterPosition.endsWith("_left")
panelAnchorRight: !shouldCenter && controlCenterPosition !== "close_to_bar_button" && controlCenterPosition.endsWith("_right")
panelAnchorBottom: !shouldCenter && controlCenterPosition !== "close_to_bar_button" && controlCenterPosition.startsWith("bottom_")
panelAnchorTop: !shouldCenter && controlCenterPosition !== "close_to_bar_button" && controlCenterPosition.startsWith("top_")
preferredWidth: Math.round(440 * Style.uiScaleRatio)
preferredHeight: {
@@ -51,24 +67,6 @@ SmartPanel {
return height + (count + 1) * Style.marginL
}
// Positioning
readonly property string controlCenterPosition: Settings.data.controlCenter.position
// Check if there's a bar on this screen
readonly property bool hasBarOnScreen: {
var monitors = Settings.data.bar.monitors || []
return monitors.length === 0 || monitors.includes(screen?.name)
}
// When position is "close_to_bar_button" but there's no bar, fall back to center
// readonly property bool shouldCenter: controlCenterPosition === "close_to_bar_button" && !hasBarOnScreen
// panelAnchorHorizontalCenter: shouldCenter || (controlCenterPosition !== "close_to_bar_button" && (controlCenterPosition.endsWith("_center") || controlCenterPosition === "center"))
// panelAnchorVerticalCenter: shouldCenter || controlCenterPosition === "center"
// panelAnchorLeft: !shouldCenter && controlCenterPosition !== "close_to_bar_button" && controlCenterPosition.endsWith("_left")
// panelAnchorRight: !shouldCenter && controlCenterPosition !== "close_to_bar_button" && controlCenterPosition.endsWith("_right")
// panelAnchorBottom: !shouldCenter && controlCenterPosition !== "close_to_bar_button" && controlCenterPosition.startsWith("bottom_")
// panelAnchorTop: !shouldCenter && controlCenterPosition !== "close_to_bar_button" && controlCenterPosition.startsWith("top_")
readonly property int profileHeight: Math.round(64 * Style.uiScaleRatio)
readonly property int shortcutsHeight: Math.round(52 * Style.uiScaleRatio)
readonly property int audioHeight: Math.round(60 * Style.uiScaleRatio)
+1 -1
View File
@@ -192,7 +192,7 @@ Item {
var controlCenterPanel = PanelService.getPanel("controlCenterPanel", screen)
if (Settings.data.controlCenter.position === "close_to_bar_button") {
// Will attempt to open the panel next to the bar button if any.
controlCenterPanel.toggle(null, "ControlCenter")
controlCenterPanel?.toggle(null, "ControlCenter")
} else {
controlCenterPanel?.toggle()
}