TrayMenu: improve tray opening direction in vertical bar more

This commit is contained in:
LemmyCook 2025-09-14 22:44:27 -04:00
parent 53d0c3943d
commit f399a6d9f5
4 changed files with 53 additions and 16 deletions

View file

@ -109,7 +109,7 @@ Variants {
"sectionWidgetIndex": index,
"sectionWidgetsCount": Settings.data.bar.widgets.left.length
}
Layout.alignment: Qt.AlignHCenter
Layout.alignment: Qt.AlignHCenter
}
}
}
@ -132,7 +132,7 @@ Variants {
"sectionWidgetIndex": index,
"sectionWidgetsCount": Settings.data.bar.widgets.center.length
}
Layout.alignment: Qt.AlignHCenter
Layout.alignment: Qt.AlignHCenter
}
}
}
@ -156,7 +156,7 @@ Variants {
"sectionWidgetIndex": index,
"sectionWidgetsCount": Settings.data.bar.widgets.right.length
}
Layout.alignment: Qt.AlignHCenter
Layout.alignment: Qt.AlignHCenter
}
}
}
@ -169,7 +169,7 @@ Variants {
anchors.fill: parent
// Left Section
RowLayout{
RowLayout {
id: leftSection
objectName: "leftSection"
anchors.left: parent.left

View file

@ -178,7 +178,7 @@ PopupWindow {
font.pointSize: Style.fontSizeS * scaling
verticalAlignment: Text.AlignVCenter
visible: modelData?.hasChildren ?? false
color: (mouseArea.containsMouse ? Color.mOnTertiary : Color.mOnSurface)
color: (mouseArea.containsMouse ? Color.mOnTertiary : Color.mOnSurface)
}
}
@ -220,9 +220,32 @@ PopupWindow {
const submenuWidth = menuWidth * scaling // Assuming a similar width as the parent
const overlap = 4 * scaling // A small overlap to bridge the mouse path
// Check if there's enough space on the right
// Determine submenu opening direction based on bar position and available space
let openLeft = false
// Check bar position first
const barPosition = Settings.data.bar.position
const globalPos = entry.mapToGlobal(0, 0)
const openLeft = (globalPos.x + entry.width + submenuWidth > (screen ? screen.width : Screen.width))
if (barPosition === "right") {
// Bar is on the right, prefer opening submenus to the left
openLeft = true
} else if (barPosition === "left") {
// Bar is on the left, prefer opening submenus to the right
openLeft = false
} else {
// Bar is horizontal (top/bottom) or undefined, use space-based logic
openLeft = (globalPos.x + entry.width + submenuWidth > (screen ? screen.width : Screen.width))
// Secondary check: ensure we don't open off-screen
if (openLeft && globalPos.x - submenuWidth < 0) {
// Would open off the left edge, force right opening
openLeft = false
} else if (!openLeft && globalPos.x + entry.width + submenuWidth > (screen ? screen.width : Screen.width)) {
// Would open off the right edge, force left opening
openLeft = true
}
}
// Position with overlap
const anchorX = openLeft ? -submenuWidth + overlap : entry.width - overlap

View file

@ -78,7 +78,7 @@ Item {
font.family: Settings.data.ui.fontFixed
font.pointSize: Style.fontSizeXS * scaling
font.weight: Style.fontWeightBold
color: forceOpen ? Color.mOnSurface : Color.mPrimary
color: forceOpen ? Color.mOnSurface : Color.mPrimary
visible: revealed
}

View file

@ -34,25 +34,39 @@ Slider {
width: root.visualPosition * parent.width
height: parent.height
radius: parent.radius
// Animated gradient fill
gradient: Gradient {
orientation: Gradient.Horizontal
GradientStop {
GradientStop {
position: 0.0
color: Qt.darker(Color.mPrimary, 1.2)
Behavior on color { ColorAnimation { duration: 300 } }
Behavior on color {
ColorAnimation {
duration: 300
}
}
}
GradientStop {
GradientStop {
position: 0.5
color: Color.mPrimary
SequentialAnimation on position {
loops: Animation.Infinite
NumberAnimation { from: 0.3; to: 0.7; duration: 2000; easing.type: Easing.InOutSine }
NumberAnimation { from: 0.7; to: 0.3; duration: 2000; easing.type: Easing.InOutSine }
NumberAnimation {
from: 0.3
to: 0.7
duration: 2000
easing.type: Easing.InOutSine
}
NumberAnimation {
from: 0.7
to: 0.3
duration: 2000
easing.type: Easing.InOutSine
}
}
}
GradientStop {
GradientStop {
position: 1.0
color: Qt.lighter(Color.mPrimary, 1.2)
}
@ -94,4 +108,4 @@ Slider {
}
}
}
}
}