E5Gui/E5PassivePopup.py

changeset 2990
583beaf0b4b8
parent 2302
f29e9405c851
child 3022
57179e4cdadd
child 3057
10516539f238
equal deleted inserted replaced
2989:7efa8b8b6903 2990:583beaf0b4b8
46 46
47 def setView(self, child): 47 def setView(self, child):
48 """ 48 """
49 Public method to set the message view. 49 Public method to set the message view.
50 50
51 @param child reference to the widget to set as the message view (QWidget) 51 @param child reference to the widget to set as the message view
52 (QWidget)
52 """ 53 """
53 self.__msgView = child 54 self.__msgView = child
54 self.__topLayout = QVBoxLayout(self) 55 self.__topLayout = QVBoxLayout(self)
55 self.__topLayout.addWidget(self.__msgView) 56 self.__topLayout.addWidget(self.__msgView)
56 self.__topLayout.activate() 57 self.__topLayout.activate()
101 def setTimeout(self, delay): 102 def setTimeout(self, delay):
102 """ 103 """
103 Public method to set the delay for the popup is removed automatically. 104 Public method to set the delay for the popup is removed automatically.
104 105
105 Setting the delay to 0 disables the timeout. If you're doing this, you 106 Setting the delay to 0 disables the timeout. If you're doing this, you
106 may want to connect the clicked() signal to the hide() slot. Setting the 107 may want to connect the clicked() signal to the hide() slot. Setting
107 delay to -1 makes it use the default value. 108 the delay to -1 makes it use the default value.
108 109
109 @param delay value for the delay in milliseconds (integer) 110 @param delay value for the delay in milliseconds (integer)
110 """ 111 """
111 self.__hideDelay = delay 112 self.__hideDelay = delay
112 if self.__hideTimer.isActive(): 113 if self.__hideTimer.isActive():
117 else: 118 else:
118 self.__hideTimer.stop() 119 self.__hideTimer.stop()
119 120
120 def timeout(self): 121 def timeout(self):
121 """ 122 """
122 Public method to get the delay before the popup is removed automatically. 123 Public method to get the delay before the popup is removed
124 automatically.
123 125
124 @return the delay before the popup is removed automatically (integer) 126 @return the delay before the popup is removed automatically (integer)
125 """ 127 """
126 return self.__hideDelay 128 return self.__hideDelay
127 129
157 """ 159 """
158 self.__moveNear(self.__defaultArea()) 160 self.__moveNear(self.__defaultArea())
159 161
160 def __moveNear(self, target): 162 def __moveNear(self, target):
161 """ 163 """
162 Private method to move the popup to be adjacent to the specified rectangle. 164 Private method to move the popup to be adjacent to the specified
165 rectangle.
163 166
164 @param target rectangle to be placed at (QRect) 167 @param target rectangle to be placed at (QRect)
165 """ 168 """
166 pos = self.__calculateNearbyPoint(target) 169 pos = self.__calculateNearbyPoint(target)
167 self.move(pos.x(), pos.y()) 170 self.move(pos.x(), pos.y())
178 x = pos.x() 181 x = pos.x()
179 y = pos.y() 182 y = pos.y()
180 w = self.minimumSizeHint().width() 183 w = self.minimumSizeHint().width()
181 h = self.minimumSizeHint().height() 184 h = self.minimumSizeHint().height()
182 185
183 r = QApplication.desktop().screenGeometry(QPoint(x + w // 2, y + h // 2)) 186 r = QApplication.desktop().screenGeometry(
187 QPoint(x + w // 2, y + h // 2))
184 188
185 if x < r.center().x(): 189 if x < r.center().x():
186 x += target.width() 190 x += target.width()
187 else: 191 else:
188 x -= w 192 x -= w
189 193
190 # It's apparently trying to go off screen, so display it ALL at the bottom. 194 # It's apparently trying to go off screen, so display it ALL at the
195 # bottom.
191 if (y + h) > r.bottom(): 196 if (y + h) > r.bottom():
192 y = r.bottom() - h 197 y = r.bottom() - h
193 198
194 if (x + w) > r.right(): 199 if (x + w) > r.right():
195 x = r.right() - w 200 x = r.right() - w

eric ide

mercurial