HTile: prevent opening multiple context menus
If a context menu is already opened for that HTile when right clicking or using a keybind like Alt+P (openPresenceMenu), close it instead of just creating a duplicate one.
This commit is contained in:
parent
e6499d8fba
commit
2664bf1e93
|
@ -10,6 +10,7 @@ HButton {
|
|||
property bool compact: window.settings.compactMode
|
||||
property real contentOpacity: 1
|
||||
property Component contextMenu: null
|
||||
property HMenu openedMenu: null
|
||||
|
||||
signal leftClicked()
|
||||
signal middleClicked()
|
||||
|
@ -18,9 +19,18 @@ HButton {
|
|||
|
||||
function openMenu(atCursor=true) {
|
||||
if (! contextMenu) return
|
||||
const menu = contextMenu.createObject(tile)
|
||||
menu.closed.connect(() => menu.destroy())
|
||||
atCursor ? menu.popup() : menu.popup(tile.width / 2, tile.height / 2)
|
||||
|
||||
if (openedMenu) {
|
||||
openedMenu.close()
|
||||
return
|
||||
}
|
||||
|
||||
openedMenu = contextMenu.createObject(tile)
|
||||
openedMenu.closed.connect(() => openedMenu.destroy())
|
||||
|
||||
atCursor ?
|
||||
openedMenu.popup() :
|
||||
openedMenu.popup(tile.width / 2, tile.height / 2)
|
||||
}
|
||||
|
||||
function doRightClick(menuAtCursor=true) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user