eric6/E5Gui/E5ToolButton.py

Sat, 27 Feb 2021 12:08:23 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 27 Feb 2021 12:08:23 +0100
changeset 8138
169e65a6787c
parent 7923
91e843545d9a
child 8143
2c730d5fd177
permissions
-rw-r--r--

Shell: added functionality to show a prompt when the main client process has exited (e.g. a script ended).

5745
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
7923
91e843545d9a Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7780
diff changeset
3 # Copyright (c) 2017 - 2021 Detlev Offenbach <detlev@die-offenbachs.de>
5745
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing a specialized tool button subclass.
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10 from PyQt5.QtCore import pyqtSlot, pyqtSignal, Qt, QTimer, QSize
7252
c5e3705073eb Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
11 from PyQt5.QtWidgets import (
c5e3705073eb Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
12 QToolButton, QStyle, QStyleOptionToolButton, QStyleOption, QApplication,
c5e3705073eb Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
13 QLabel
c5e3705073eb Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
14 )
5745
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17 class E5ToolButton(QToolButton):
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18 """
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19 Class implementing a specialized tool button subclass.
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 @signal aboutToShowMenu() emitted before the tool button menu is shown
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 @signal aboutToHideMenu() emitted before the tool button menu is hidden
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 @signal middleClicked() emitted when the middle mouse button was clicked
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 @signal controlClicked() emitted when the left mouse button was
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 clicked while pressing the Ctrl key
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 @signal doubleClicked() emitted when the left mouse button was
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 double clicked
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 """
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 NoOptions = 0
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 ShowMenuInsideOption = 1
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 ToolBarLookOption = 2
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 aboutToShowMenu = pyqtSignal()
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 aboutToHideMenu = pyqtSignal()
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 middleClicked = pyqtSignal()
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 controlClicked = pyqtSignal()
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 doubleClicked = pyqtSignal()
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 def __init__(self, parent=None):
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 """
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 Constructor
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 @param parent reference to the parent widget
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 @type QWidget
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 """
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46 super(E5ToolButton, self).__init__(parent)
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 self.setMinimumWidth(16)
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 self.__menu = None
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 self.__options = E5ToolButton.NoOptions
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52
6134
cb0985e8da91 Introduced a navigation bar button to open the downloads manager window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
53 self.__badgeLabel = QLabel(self)
cb0985e8da91 Introduced a navigation bar button to open the downloads manager window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
54 font = self.__badgeLabel.font()
cb0985e8da91 Introduced a navigation bar button to open the downloads manager window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
55 font.setPixelSize(self.__badgeLabel.height() / 2.5)
cb0985e8da91 Introduced a navigation bar button to open the downloads manager window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
56 self.__badgeLabel.setFont(font)
cb0985e8da91 Introduced a navigation bar button to open the downloads manager window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
57 self.__badgeLabel.hide()
cb0985e8da91 Introduced a navigation bar button to open the downloads manager window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
58
5745
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 opt = QStyleOptionToolButton()
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 self.initStyleOption(opt)
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62 self.__pressTimer = QTimer()
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63 self.__pressTimer.setSingleShot(True)
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64 self.__pressTimer.setInterval(
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 QApplication.style().styleHint(
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66 QStyle.SH_ToolButton_PopupDelay, opt, self))
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67 self.__pressTimer.timeout.connect(self.__showMenu)
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69 ##################################################################
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70 ## Menu handling methods below.
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71 ##
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72 ## The menu is handled in E5ToolButton and is not passed to
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73 ## QToolButton. No menu indicator will be shown in the button.
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74 ##################################################################
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76 def menu(self):
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77 """
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78 Public method to get a reference to the tool button menu.
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80 @return reference to the tool button menu
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81 @rtype QMenu
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82 """
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83 return self.__menu
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85 def setMenu(self, menu):
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86 """
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
87 Public method to set the tool button menu.
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
88
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
89 @param menu reference to the tool button menu
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
90 @type QMenu
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91 """
7628
f904d0eef264 Checked the reported security related issue reports generated by the new security checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
92 if menu is not None:
f904d0eef264 Checked the reported security related issue reports generated by the new security checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
93 if self.__menu:
f904d0eef264 Checked the reported security related issue reports generated by the new security checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
94 self.__menu.aboutToHide.disconnect(self.__menuAboutToHide)
f904d0eef264 Checked the reported security related issue reports generated by the new security checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
95
f904d0eef264 Checked the reported security related issue reports generated by the new security checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
96 self.__menu = menu
f904d0eef264 Checked the reported security related issue reports generated by the new security checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
97 self.__menu.aboutToHide.connect(self.__menuAboutToHide)
5745
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
98
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
99 def showMenuInside(self):
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
100 """
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101 Public method to check, if the menu edge shall be aligned with
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
102 the button.
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
103
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
104 @return flag indicating that the menu edge shall be aligned
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105 @rtype bool
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106 """
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107 return bool(self.__options & E5ToolButton.ShowMenuInsideOption)
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
108
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
109 def setShowMenuInside(self, enable):
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
110 """
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
111 Public method to set a flag to show the menu edge aligned with
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
112 the button.
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
113
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
114 @param enable flag indicating to align the menu edge to the button
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
115 @type bool
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
116 """
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117 if enable:
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
118 self.__options |= E5ToolButton.ShowMenuInsideOption
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119 else:
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120 self.__options &= ~E5ToolButton.ShowMenuInsideOption
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
121
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
122 @pyqtSlot()
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
123 def __showMenu(self):
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
124 """
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
125 Private slot to show the tool button menu.
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
126 """
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
127 if self.__menu is None or self.__menu.isVisible():
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
128 return
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
129
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
130 self.aboutToShowMenu.emit()
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
131
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
132 if self.__options & E5ToolButton.ShowMenuInsideOption:
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
133 pos = self.mapToGlobal(self.rect().bottomRight())
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
134 if QApplication.layoutDirection() == Qt.RightToLeft:
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
135 pos.setX(pos.x() - self.rect().width())
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
136 else:
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
137 pos.setX(pos.x() - self.__menu.sizeHint().width())
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
138 else:
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
139 pos = self.mapToGlobal(self.rect().bottomLeft())
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
140
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
141 self.__menu.popup(pos)
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
142
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
143 @pyqtSlot()
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
144 def __menuAboutToHide(self):
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
145 """
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
146 Private slot to handle the tool button menu about to be hidden.
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
147 """
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
148 self.setDown(False)
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
149 self.aboutToHideMenu.emit()
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
150
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
151 ##################################################################
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
152 ## Methods to handle the tool button look
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
153 ##################################################################
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
154
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
155 def toolbarButtonLook(self):
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
156 """
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
157 Public method to check, if the button has the toolbar look.
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
158
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
159 @return flag indicating toolbar look
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
160 @rtype bool
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
161 """
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
162 return bool(self.__options & E5ToolButton.ToolBarLookOption)
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
163
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
164 def setToolbarButtonLook(self, enable):
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
165 """
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
166 Public method to set the toolbar look state.
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
167
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
168 @param enable flag indicating toolbar look
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
169 @type bool
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
170 """
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
171 if enable:
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
172 self.__options |= E5ToolButton.ToolBarLookOption
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
173
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
174 opt = QStyleOption()
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
175 opt.initFrom(self)
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
176 size = self.style().pixelMetric(
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
177 QStyle.PM_ToolBarIconSize, opt, self)
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
178 self.setIconSize(QSize(size, size))
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
179 else:
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
180 self.__options &= ~E5ToolButton.ToolBarLookOption
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
181
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
182 self.setProperty("toolbar-look", enable)
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
183 self.style().unpolish(self)
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
184 self.style().polish(self)
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
185
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
186 ##################################################################
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
187 ## Methods to handle some event types
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
188 ##################################################################
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
189
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
190 def mousePressEvent(self, evt):
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
191 """
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
192 Protected method to handle mouse press events.
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
193
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
194 @param evt reference to the mouse event
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
195 @type QMouseEvent
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
196 """
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
197 if self.popupMode() == QToolButton.DelayedPopup:
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
198 self.__pressTimer.start()
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
199
7252
c5e3705073eb Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
200 if (
c5e3705073eb Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
201 evt.buttons() == Qt.LeftButton and
c5e3705073eb Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
202 self.__menu is not None and
c5e3705073eb Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
203 self.popupMode() == QToolButton.InstantPopup
c5e3705073eb Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
204 ):
5745
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
205 self.setDown(True)
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
206 self.__showMenu()
7252
c5e3705073eb Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
207 elif (
c5e3705073eb Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
208 evt.buttons() == Qt.RightButton and
c5e3705073eb Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
209 self.__menu is not None
c5e3705073eb Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
210 ):
5745
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
211 self.setDown(True)
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
212 self.__showMenu()
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
213 else:
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
214 super(E5ToolButton, self).mousePressEvent(evt)
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
215
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
216 def mouseReleaseEvent(self, evt):
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
217 """
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
218 Protected method to handle mouse release events.
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
219
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
220 @param evt reference to the mouse event
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
221 @type QMouseEvent
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
222 """
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
223 self.__pressTimer.stop()
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
224
7252
c5e3705073eb Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
225 if (
c5e3705073eb Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
226 evt.button() == Qt.MiddleButton and
c5e3705073eb Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
227 self.rect().contains(evt.pos())
c5e3705073eb Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
228 ):
5745
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
229 self.middleClicked.emit()
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
230 self.setDown(False)
7252
c5e3705073eb Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
231 elif (
c5e3705073eb Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
232 evt.button() == Qt.LeftButton and
c5e3705073eb Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
233 self.rect().contains(evt.pos()) and
c5e3705073eb Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
234 evt.modifiers() == Qt.ControlModifier
c5e3705073eb Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
235 ):
5745
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
236 self.controlClicked.emit()
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
237 self.setDown(False)
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
238 else:
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
239 super(E5ToolButton, self).mouseReleaseEvent(evt)
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
240
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
241 def mouseDoubleClickEvent(self, evt):
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
242 """
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
243 Protected method to handle mouse double click events.
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
244
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
245 @param evt reference to the mouse event
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
246 @type QMouseEvent
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
247 """
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
248 super(E5ToolButton, self).mouseDoubleClickEvent(evt)
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
249
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
250 self.__pressTimer.stop()
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
251
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
252 if evt.buttons() == Qt.LeftButton:
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
253 self.doubleClicked.emit()
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
254
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
255 def contextMenuEvent(self, evt):
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
256 """
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
257 Protected method to handle context menu events.
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
258
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
259 @param evt reference to the context menu event
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
260 @type QContextMenuEvent
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
261 """
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
262 # block to prevent showing the context menu and the tool button menu
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
263 if self.__menu is not None:
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
264 return
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
265
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
266 super(E5ToolButton, self).contextMenuEvent(evt)
6134
cb0985e8da91 Introduced a navigation bar button to open the downloads manager window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
267
cb0985e8da91 Introduced a navigation bar button to open the downloads manager window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
268 ##################################################################
cb0985e8da91 Introduced a navigation bar button to open the downloads manager window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
269 ## Methods to handle the tool button badge
cb0985e8da91 Introduced a navigation bar button to open the downloads manager window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
270 ##################################################################
cb0985e8da91 Introduced a navigation bar button to open the downloads manager window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
271
cb0985e8da91 Introduced a navigation bar button to open the downloads manager window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
272 def setBadgeText(self, text):
cb0985e8da91 Introduced a navigation bar button to open the downloads manager window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
273 """
cb0985e8da91 Introduced a navigation bar button to open the downloads manager window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
274 Public method to set the badge text.
cb0985e8da91 Introduced a navigation bar button to open the downloads manager window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
275
cb0985e8da91 Introduced a navigation bar button to open the downloads manager window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
276 @param text badge text to be set
cb0985e8da91 Introduced a navigation bar button to open the downloads manager window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
277 @type str
cb0985e8da91 Introduced a navigation bar button to open the downloads manager window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
278 """
cb0985e8da91 Introduced a navigation bar button to open the downloads manager window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
279 if text:
cb0985e8da91 Introduced a navigation bar button to open the downloads manager window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
280 self.__badgeLabel.setText(text)
cb0985e8da91 Introduced a navigation bar button to open the downloads manager window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
281 self.__badgeLabel.resize(self.__badgeLabel.sizeHint())
cb0985e8da91 Introduced a navigation bar button to open the downloads manager window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
282 self.__badgeLabel.move(self.width() - self.__badgeLabel.width(), 0)
cb0985e8da91 Introduced a navigation bar button to open the downloads manager window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
283 self.__badgeLabel.show()
cb0985e8da91 Introduced a navigation bar button to open the downloads manager window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
284 else:
cb0985e8da91 Introduced a navigation bar button to open the downloads manager window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
285 self.__badgeLabel.clear()
cb0985e8da91 Introduced a navigation bar button to open the downloads manager window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
286 self.__badgeLabel.hide()
cb0985e8da91 Introduced a navigation bar button to open the downloads manager window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
287
cb0985e8da91 Introduced a navigation bar button to open the downloads manager window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
288 def badgeText(self):
cb0985e8da91 Introduced a navigation bar button to open the downloads manager window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
289 """
cb0985e8da91 Introduced a navigation bar button to open the downloads manager window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
290 Public method to get the badge text.
cb0985e8da91 Introduced a navigation bar button to open the downloads manager window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
291
cb0985e8da91 Introduced a navigation bar button to open the downloads manager window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
292 @return badge text
cb0985e8da91 Introduced a navigation bar button to open the downloads manager window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
293 @rtype str
cb0985e8da91 Introduced a navigation bar button to open the downloads manager window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
294 """
cb0985e8da91 Introduced a navigation bar button to open the downloads manager window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
295 return self.__badgeLabel.text()

eric ide

mercurial