102 Public method to set the tool button menu. |
102 Public method to set the tool button menu. |
103 |
103 |
104 @param menu reference to the tool button menu |
104 @param menu reference to the tool button menu |
105 @type QMenu |
105 @type QMenu |
106 """ |
106 """ |
107 if menu is not None: |
107 if menu is None: |
|
108 # show the default tool button context menu |
|
109 self.setContextMenuPolicy(Qt.ContextMenuPolicy.DefaultContextMenu) |
|
110 else: |
108 if self.__menu: |
111 if self.__menu: |
109 self.__menu.aboutToHide.disconnect(self.__menuAboutToHide) |
112 self.__menu.aboutToHide.disconnect(self.__menuAboutToHide) |
110 |
113 |
111 self.__menu = menu |
114 self.__menu = menu |
112 self.__menu.aboutToHide.connect(self.__menuAboutToHide) |
115 self.__menu.aboutToHide.connect(self.__menuAboutToHide) |
|
116 |
|
117 # prevent showing the context menu and the tool button menu |
|
118 self.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) |
113 |
119 |
114 def showMenuInside(self): |
120 def showMenuInside(self): |
115 """ |
121 """ |
116 Public method to check, if the menu edge shall be aligned with |
122 Public method to check, if the menu edge shall be aligned with |
117 the button. |
123 the button. |
259 self.__pressTimer.stop() |
265 self.__pressTimer.stop() |
260 |
266 |
261 if evt.buttons() == Qt.MouseButton.LeftButton: |
267 if evt.buttons() == Qt.MouseButton.LeftButton: |
262 self.doubleClicked.emit() |
268 self.doubleClicked.emit() |
263 |
269 |
264 def contextMenuEvent(self, evt): |
|
265 """ |
|
266 Protected method to handle context menu events. |
|
267 |
|
268 @param evt reference to the context menu event |
|
269 @type QContextMenuEvent |
|
270 """ |
|
271 # block to prevent showing the context menu and the tool button menu |
|
272 if self.__menu is not None: |
|
273 return |
|
274 |
|
275 super().contextMenuEvent(evt) |
|
276 |
|
277 ################################################################## |
270 ################################################################## |
278 ## Methods to handle the tool button badge |
271 ## Methods to handle the tool button badge |
279 ################################################################## |
272 ################################################################## |
280 |
273 |
281 def setBadgeText(self, text): |
274 def setBadgeText(self, text): |