From ab835857fb7de967124fbf3005ab8d15e7952ba0 Mon Sep 17 00:00:00 2001 From: Sale Djenic Date: Tue, 21 Dec 2021 14:58:36 +0100 Subject: [PATCH] refactor(StatusChatToolBar): open/close handlers get called if they are set for `popupMenu` of `StatusChatToolBar` component --- .../StatusQ/Components/StatusChatToolBar.qml | 28 +++++++++++++------ 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/ui/StatusQ/src/StatusQ/Components/StatusChatToolBar.qml b/ui/StatusQ/src/StatusQ/Components/StatusChatToolBar.qml index cbc3c6f817..ead08e1d2c 100644 --- a/ui/StatusQ/src/StatusQ/Components/StatusChatToolBar.qml +++ b/ui/StatusQ/src/StatusQ/Components/StatusChatToolBar.qml @@ -93,6 +93,25 @@ Rectangle { property bool showMoreMenu: false onClicked: { + menuButton.highlighted = true + + let originalOpenHandler = popupMenuSlot.item.openHandler + let originalCloseHandler = popupMenuSlot.item.closeHandler + + popupMenuSlot.item.openHandler = function () { + if (!!originalOpenHandler) { + originalOpenHandler() + } + } + + popupMenuSlot.item.closeHandler = function () { + menuButton.highlighted = false + if (!!originalCloseHandler) { + originalCloseHandler() + } + } + + popupMenuSlot.item.openHandler = originalOpenHandler popupMenuSlot.item.popup(-popupMenuSlot.item.width + menuButton.width, menuButton.height + 4) statusChatToolBar.menuButtonClicked() } @@ -100,15 +119,6 @@ Rectangle { Loader { id: popupMenuSlot active: !!statusChatToolBar.popupMenu - onLoaded: { - popupMenuSlot.item.closeHandler = function () { - menuButton.highlighted = false - } - - popupMenuSlot.item.openHandler = function () { - menuButton.highlighted = true - } - } } }