qs: update
This commit is contained in:
@@ -14,6 +14,7 @@ Rectangle {
|
|||||||
id: root
|
id: root
|
||||||
|
|
||||||
property ShellScreen screen
|
property ShellScreen screen
|
||||||
|
property var activeTrayItem: null
|
||||||
|
|
||||||
implicitWidth: trayFlow.implicitWidth + 20
|
implicitWidth: trayFlow.implicitWidth + 20
|
||||||
implicitHeight: parent.height
|
implicitHeight: parent.height
|
||||||
@@ -90,10 +91,15 @@ Rectangle {
|
|||||||
|
|
||||||
modelData.secondaryActivate && modelData.secondaryActivate()
|
modelData.secondaryActivate && modelData.secondaryActivate()
|
||||||
} else if (mouse.button === Qt.RightButton) {
|
} else if (mouse.button === Qt.RightButton) {
|
||||||
// Close the menu if it was visible
|
|
||||||
if (trayPanel && trayPanel.visible) {
|
if (trayPanel && trayPanel.visible) {
|
||||||
|
// Right-click the same icon toggles menu off.
|
||||||
|
if (root.activeTrayItem === modelData) {
|
||||||
|
trayPanel.close()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Switch directly to another tray item's menu.
|
||||||
trayPanel.close()
|
trayPanel.close()
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (modelData.hasMenu && modelData.menu && trayMenu.item) {
|
if (modelData.hasMenu && modelData.menu && trayMenu.item) {
|
||||||
@@ -105,15 +111,13 @@ Rectangle {
|
|||||||
menuX = (width / 2) - (trayMenu.item.width / 2)
|
menuX = (width / 2) - (trayMenu.item.width / 2)
|
||||||
menuY = root.height
|
menuY = root.height
|
||||||
trayMenu.item.menu = modelData.menu
|
trayMenu.item.menu = modelData.menu
|
||||||
|
root.activeTrayItem = modelData
|
||||||
trayMenu.item.showAt(parent, menuX, menuY)
|
trayMenu.item.showAt(parent, menuX, menuY)
|
||||||
} else {
|
} else {
|
||||||
Logger.d("Tray", "No menu available for", modelData.id, "or trayMenu not set")
|
Logger.d("Tray", "No menu available for", modelData.id, "or trayMenu not set")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onEntered: {
|
|
||||||
trayPanel.close()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -136,6 +140,7 @@ Rectangle {
|
|||||||
|
|
||||||
function close() {
|
function close() {
|
||||||
visible = false
|
visible = false
|
||||||
|
root.activeTrayItem = null
|
||||||
if (trayMenu.item) {
|
if (trayMenu.item) {
|
||||||
trayMenu.item.hideMenu()
|
trayMenu.item.hideMenu()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ PopupWindow {
|
|||||||
property real anchorX
|
property real anchorX
|
||||||
property real anchorY
|
property real anchorY
|
||||||
property bool isSubMenu: false
|
property bool isSubMenu: false
|
||||||
property bool isHovered: rootMouseArea.containsMouse
|
|
||||||
property ShellScreen screen
|
property ShellScreen screen
|
||||||
|
|
||||||
readonly property int menuWidth: 180
|
readonly property int menuWidth: 180
|
||||||
@@ -67,11 +66,15 @@ PopupWindow {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Full-sized, transparent MouseArea to track the mouse.
|
function closeSiblingSubMenus(currentEntry) {
|
||||||
MouseArea {
|
for (var i = 0; i < columnLayout.children.length; i++) {
|
||||||
id: rootMouseArea
|
const sibling = columnLayout.children[i]
|
||||||
anchors.fill: parent
|
if (sibling !== currentEntry && sibling?.subMenu) {
|
||||||
hoverEnabled: true
|
sibling.subMenu.hideMenu()
|
||||||
|
sibling.subMenu.destroy()
|
||||||
|
sibling.subMenu = null
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
@@ -176,66 +179,46 @@ PopupWindow {
|
|||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
enabled: (modelData?.enabled ?? true) && !(modelData?.isSeparator ?? false) && root.visible
|
enabled: (modelData?.enabled ?? true) && !(modelData?.isSeparator ?? false) && root.visible
|
||||||
|
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
||||||
|
|
||||||
onClicked: {
|
onClicked: mouse => {
|
||||||
if (modelData && !modelData.isSeparator && !modelData.hasChildren) {
|
if (!modelData || modelData.isSeparator) {
|
||||||
modelData.triggered()
|
|
||||||
root.hideMenu()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
onEntered: {
|
|
||||||
if (!root.visible)
|
|
||||||
return
|
return
|
||||||
|
|
||||||
// Close all sibling submenus
|
|
||||||
for (var i = 0; i < columnLayout.children.length; i++) {
|
|
||||||
const sibling = columnLayout.children[i]
|
|
||||||
if (sibling !== entry && sibling?.subMenu) {
|
|
||||||
sibling.subMenu.hideMenu()
|
|
||||||
sibling.subMenu.destroy()
|
|
||||||
sibling.subMenu = null
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create submenu if needed
|
if (modelData.hasChildren) {
|
||||||
if (modelData?.hasChildren) {
|
|
||||||
if (entry.subMenu) {
|
if (entry.subMenu) {
|
||||||
entry.subMenu.hideMenu()
|
entry.subMenu.hideMenu()
|
||||||
entry.subMenu.destroy()
|
entry.subMenu.destroy()
|
||||||
|
entry.subMenu = null
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Need a slight overlap so that menu don't close when moving the mouse to a submenu
|
root.closeSiblingSubMenus(entry)
|
||||||
const submenuWidth = menuWidth // Assuming a similar width as the parent
|
|
||||||
const overlap = 4 // A small overlap to bridge the mouse path
|
|
||||||
|
|
||||||
// Position with overlap
|
const submenuWidth = menuWidth
|
||||||
const anchorX = -submenuWidth + overlap
|
const overlap = 12
|
||||||
|
const subAnchorX = -submenuWidth + overlap
|
||||||
|
|
||||||
// Create submenu
|
|
||||||
entry.subMenu = Qt.createComponent("TrayMenu.qml").createObject(root, {
|
entry.subMenu = Qt.createComponent("TrayMenu.qml").createObject(root, {
|
||||||
"menu": modelData,
|
"menu": modelData,
|
||||||
"anchorItem": entry,
|
"anchorItem": entry,
|
||||||
"anchorX": anchorX,
|
"anchorX": subAnchorX,
|
||||||
"anchorY": 0,
|
"anchorY": 0,
|
||||||
"isSubMenu": true,
|
"isSubMenu": true,
|
||||||
"screen": root.screen
|
"screen": root.screen
|
||||||
})
|
})
|
||||||
|
|
||||||
if (entry.subMenu) {
|
if (entry.subMenu) {
|
||||||
entry.subMenu.showAt(entry, anchorX, 0)
|
entry.subMenu.showAt(entry, subAnchorX, 0)
|
||||||
}
|
}
|
||||||
|
return
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
onExited: {
|
if (mouse.button === Qt.LeftButton || mouse.button === Qt.RightButton) {
|
||||||
Qt.callLater(() => {
|
modelData.triggered()
|
||||||
if (entry.subMenu && !entry.subMenu.isHovered) {
|
root.hideMenu()
|
||||||
entry.subMenu.hideMenu()
|
}
|
||||||
entry.subMenu.destroy()
|
|
||||||
entry.subMenu = null
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -251,7 +251,7 @@ Singleton {
|
|||||||
}
|
}
|
||||||
const player = this.queuedPlayer.toLowerCase();
|
const player = this.queuedPlayer.toLowerCase();
|
||||||
this.queuedPlayer = "";
|
this.queuedPlayer = "";
|
||||||
this.command = ["lrx", "--player", player, "fetch"];
|
this.command = ["lrx", "--player", player, "fetch", "--normalize"];
|
||||||
this.running = true;
|
this.running = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user