TrayMenu: improve tray opening direction in vertical bar more
This commit is contained in:
parent
53d0c3943d
commit
f399a6d9f5
4 changed files with 53 additions and 16 deletions
|
|
@ -220,9 +220,32 @@ PopupWindow {
|
||||||
const submenuWidth = menuWidth * scaling // Assuming a similar width as the parent
|
const submenuWidth = menuWidth * scaling // Assuming a similar width as the parent
|
||||||
const overlap = 4 * scaling // A small overlap to bridge the mouse path
|
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 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
|
// Position with overlap
|
||||||
const anchorX = openLeft ? -submenuWidth + overlap : entry.width - overlap
|
const anchorX = openLeft ? -submenuWidth + overlap : entry.width - overlap
|
||||||
|
|
|
||||||
|
|
@ -41,15 +41,29 @@ Slider {
|
||||||
GradientStop {
|
GradientStop {
|
||||||
position: 0.0
|
position: 0.0
|
||||||
color: Qt.darker(Color.mPrimary, 1.2)
|
color: Qt.darker(Color.mPrimary, 1.2)
|
||||||
Behavior on color { ColorAnimation { duration: 300 } }
|
Behavior on color {
|
||||||
|
ColorAnimation {
|
||||||
|
duration: 300
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
GradientStop {
|
GradientStop {
|
||||||
position: 0.5
|
position: 0.5
|
||||||
color: Color.mPrimary
|
color: Color.mPrimary
|
||||||
SequentialAnimation on position {
|
SequentialAnimation on position {
|
||||||
loops: Animation.Infinite
|
loops: Animation.Infinite
|
||||||
NumberAnimation { from: 0.3; to: 0.7; duration: 2000; easing.type: Easing.InOutSine }
|
NumberAnimation {
|
||||||
NumberAnimation { from: 0.7; to: 0.3; duration: 2000; easing.type: Easing.InOutSine }
|
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 {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue