2 |
2 |
3 # Copyright (c) 2010 - 2011 Detlev Offenbach <detlev@die-offenbachs.de> |
3 # Copyright (c) 2010 - 2011 Detlev Offenbach <detlev@die-offenbachs.de> |
4 # |
4 # |
5 |
5 |
6 """ |
6 """ |
7 Module implementing dialog-like popup that displays messages without |
7 Module implementing dialog-like popup that displays messages without |
8 interrupting the user. |
8 interrupting the user. |
9 """ |
9 """ |
10 |
10 |
11 from PyQt4.QtCore import pyqtSignal, Qt, QTimer, QPoint, QRect |
11 from PyQt4.QtCore import pyqtSignal, Qt, QTimer, QPoint, QRect |
12 from PyQt4.QtGui import QFrame, QVBoxLayout, QApplication |
12 from PyQt4.QtGui import QFrame, QVBoxLayout, QApplication |
13 |
13 |
|
14 |
14 class E5PassivePopup(QFrame): |
15 class E5PassivePopup(QFrame): |
15 """ |
16 """ |
16 Class implementing dialog-like popup that displays messages without |
17 Class implementing dialog-like popup that displays messages without |
17 interrupting the user. |
18 interrupting the user. |
18 """ |
19 """ |
19 Boxed = 0 |
20 Boxed = 0 |
20 Custom = 128 |
21 Custom = 128 |
21 |
22 |
22 clicked = pyqtSignal((), (QPoint, )) |
23 clicked = pyqtSignal((), (QPoint, )) |
23 |
24 |
24 def __init__(self, parent = None): |
25 def __init__(self, parent=None): |
25 """ |
26 """ |
26 Constructor |
27 Constructor |
27 |
28 |
28 @param parent reference to the parent widget (QWidget) |
29 @param parent reference to the parent widget (QWidget) |
29 """ |
30 """ |
85 if delay < 0: |
86 if delay < 0: |
86 delay = DEFAULT_POPUP_TIME |
87 delay = DEFAULT_POPUP_TIME |
87 if delay > 0: |
88 if delay > 0: |
88 self.__hideTimer.start(delay) |
89 self.__hideTimer.start(delay) |
89 |
90 |
90 def show(self, p = None): |
91 def show(self, p=None): |
91 """ |
92 """ |
92 Public slot to show the popup. |
93 Public slot to show the popup. |
93 |
94 |
94 @param p position for the popup (QPoint) |
95 @param p position for the popup (QPoint) |
95 """ |
96 """ |
165 pos = self.__calculateNearbyPoint(target) |
166 pos = self.__calculateNearbyPoint(target) |
166 self.move(pos.x(), pos.y()) |
167 self.move(pos.x(), pos.y()) |
167 |
168 |
168 def __calculateNearbyPoint(self, target): |
169 def __calculateNearbyPoint(self, target): |
169 """ |
170 """ |
170 Private method to calculate the position to place the popup near the |
171 Private method to calculate the position to place the popup near the |
171 specified rectangle. |
172 specified rectangle. |
172 |
173 |
173 @param target rectangle to be placed at (QRect) |
174 @param target rectangle to be placed at (QRect) |
174 @return position to place the popup (QPoint) |
175 @return position to place the popup (QPoint) |
175 """ |
176 """ |