1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2025-12-07 05:55:37 -05:00

fix system trya item activation

This commit is contained in:
bbedward
2025-08-10 14:15:56 -04:00
parent 62e1aa8ae8
commit 1a4e16fc7a

View File

@@ -10,8 +10,8 @@ Rectangle {
property var parentScreen: null property var parentScreen: null
readonly property int calculatedWidth: SystemTray.items.values.length readonly property int calculatedWidth: SystemTray.items.values.length
> 0 ? SystemTray.items.values.length * 24 > 0 ? SystemTray.items.values.length
+ (SystemTray.items.values.length - 1) * 24 + (SystemTray.items.values.length - 1)
* Theme.spacingXS + Theme.spacingS * 2 : 0 * Theme.spacingXS + Theme.spacingS * 2 : 0
width: calculatedWidth width: calculatedWidth
@@ -47,7 +47,8 @@ Rectangle {
return icon return icon
const name = split[0] const name = split[0]
const path = split[1] const path = split[1]
const fileName = name.substring(name.lastIndexOf("/") + 1) const fileName = name.substring(
name.lastIndexOf("/") + 1)
return `file://${path}/${fileName}` return `file://${path}/${fileName}`
} }
return icon return icon
@@ -94,19 +95,24 @@ Rectangle {
if (!trayItem) if (!trayItem)
return return
if (mouse.button === Qt.LeftButon && !trayItem.onlyMenu) {
trayItem.activate()
return
}
if (trayItem.hasMenu) { if (trayItem.hasMenu) {
var globalPos = mapToGlobal(0, 0) var globalPos = mapToGlobal(0, 0)
var currentScreen = parentScreen || Screen var currentScreen = parentScreen
|| Screen
var screenX = currentScreen.x || 0 var screenX = currentScreen.x || 0
var relativeX = globalPos.x - screenX var relativeX = globalPos.x - screenX
menuAnchor.menu = trayItem.menu menuAnchor.menu = trayItem.menu
menuAnchor.anchor.window = parentWindow menuAnchor.anchor.window = parentWindow
menuAnchor.anchor.rect = Qt.rect( menuAnchor.anchor.rect = Qt.rect(
relativeX, Theme.barHeight + Theme.spacingS, relativeX,
Theme.barHeight + Theme.spacingS,
parent.width, 1) parent.width, 1)
menuAnchor.open() menuAnchor.open()
} else if (mouse.button === Qt.LeftButton) {
trayItem.activate()
} }
} }
} }