chore(StatusNavBarTabButton): delay the context menu creation

until it's actually right clicked
This commit is contained in:
Lukáš Tinkl 2023-01-10 14:17:54 +01:00 committed by Lukáš Tinkl
parent 6d2ea528ac
commit 5a69cde2bc
1 changed files with 6 additions and 10 deletions

View File

@ -9,14 +9,6 @@ StatusIconTabButton {
property alias tooltip: statusTooltip
property Component popupMenu
signal clicked(var mouse)
onPopupMenuChanged: {
if (!!popupMenu) {
popupMenuSlot.sourceComponent = popupMenu
}
}
StatusToolTip {
id: statusTooltip
visible: statusNavBarTabButton.hovered && !!statusTooltip.text
@ -49,6 +41,8 @@ StatusIconTabButton {
acceptedButtons: Qt.LeftButton | Qt.RightButton
onClicked: {
if (mouse.button === Qt.RightButton) {
if (typeof popupMenuSlot.sourceComponent !== "undefined" && !popupMenuSlot.active)
popupMenuSlot.active = true
if (popupMenuSlot.active) {
statusNavBarTabButton.highlighted = true
let btnWidth = statusNavBarTabButton.width
@ -56,16 +50,18 @@ StatusIconTabButton {
return
}
}
statusNavBarTabButton.clicked(mouse)
statusNavBarTabButton.clicked()
}
}
Loader {
id: popupMenuSlot
active: !!statusNavBarTabButton.popupMenu
sourceComponent: statusNavBarTabButton.popupMenu
active: false
onLoaded: {
popupMenuSlot.item.closeHandler = function () {
statusNavBarTabButton.highlighted = false
popupMenuSlot.active = false
}
}
}