Tue, 07 Jan 2014 09:23:24 +0100
Prepared release 5.4.0 of eric5.
634
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1 | # -*- coding: utf-8 -*- |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2 | |
3160
209a07d7e401
Updated copyright for 2014.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3034
diff
changeset
|
3 | # Copyright (c) 2010 - 2014 Detlev Offenbach <detlev@die-offenbachs.de> |
634
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
4 | # |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
5 | |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
6 | """ |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
7 | Module implementing dialog-like popup that displays messages without |
634
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
8 | interrupting the user. |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
9 | """ |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
10 | |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
11 | from PyQt4.QtCore import pyqtSignal, Qt, QTimer, QPoint, QRect |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
12 | from PyQt4.QtGui import QFrame, QVBoxLayout, QApplication |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
13 | |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
14 | |
634
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
15 | class E5PassivePopup(QFrame): |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
16 | """ |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
17 | Class implementing dialog-like popup that displays messages without |
634
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
18 | interrupting the user. |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
19 | """ |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
20 | Boxed = 0 |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
21 | Custom = 128 |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
22 | |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
23 | clicked = pyqtSignal((), (QPoint, )) |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
24 | |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
25 | def __init__(self, parent=None): |
634
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
26 | """ |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
27 | Constructor |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
28 | |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
29 | @param parent reference to the parent widget (QWidget) |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
30 | """ |
1131
7781e396c903
Changed the code to use super() to access the superclass.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
31 | super().__init__(None) |
634
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
32 | |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
33 | self.__popupStyle = DEFAULT_POPUP_TYPE |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
34 | self.__msgView = None |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
35 | self.__topLayout = None |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
36 | self.__hideDelay = DEFAULT_POPUP_TIME |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
37 | self.__hideTimer = QTimer(self) |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
38 | self.__autoDelete = False |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
39 | self.__fixedPosition = QPoint() |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
40 | |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
41 | self.setWindowFlags(POPUP_FLAGS) |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
42 | self.setFrameStyle(QFrame.Box | QFrame.Plain) |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
43 | self.setLineWidth(2) |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
44 | self.__hideTimer.timeout.connect(self.hide) |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
45 | self.clicked[()].connect(self.hide) |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
46 | |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
47 | def setView(self, child): |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
48 | """ |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
49 | Public method to set the message view. |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
50 | |
2990
583beaf0b4b8
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2302
diff
changeset
|
51 | @param child reference to the widget to set as the message view |
583beaf0b4b8
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2302
diff
changeset
|
52 | (QWidget) |
634
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
53 | """ |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
54 | self.__msgView = child |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
55 | self.__topLayout = QVBoxLayout(self) |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
56 | self.__topLayout.addWidget(self.__msgView) |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
57 | self.__topLayout.activate() |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
58 | |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
59 | def view(self): |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
60 | """ |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
61 | Public method to get a reference to the message view. |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
62 | |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
63 | @return reference to the message view (QWidget) |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
64 | """ |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
65 | return self.__msgView |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
66 | |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
67 | def setVisible(self, visible): |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
68 | """ |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
69 | Public method to show or hide the popup. |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
70 | |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
71 | @param visible flag indicating the visibility status (boolean) |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
72 | """ |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
73 | if not visible: |
1131
7781e396c903
Changed the code to use super() to access the superclass.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
74 | super().setVisible(visible) |
634
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
75 | return |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
76 | |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
77 | if self.size() != self.sizeHint(): |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
78 | self.resize(self.sizeHint()) |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
79 | |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
80 | if self.__fixedPosition.isNull(): |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
81 | self.__positionSelf() |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
82 | else: |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
83 | self.move(self.__fixedPosition) |
1131
7781e396c903
Changed the code to use super() to access the superclass.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
84 | super().setVisible(True) |
634
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
85 | |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
86 | delay = self.__hideDelay |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
87 | if delay < 0: |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
88 | delay = DEFAULT_POPUP_TIME |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
89 | if delay > 0: |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
90 | self.__hideTimer.start(delay) |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
91 | |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
92 | def show(self, p=None): |
634
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
93 | """ |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
94 | Public slot to show the popup. |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
95 | |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
96 | @param p position for the popup (QPoint) |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
97 | """ |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
98 | if p is not None: |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
99 | self.__fixedPosition = p |
1131
7781e396c903
Changed the code to use super() to access the superclass.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
100 | super().show() |
634
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
101 | |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
102 | def setTimeout(self, delay): |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
103 | """ |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
104 | Public method to set the delay for the popup is removed automatically. |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
105 | |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
106 | Setting the delay to 0 disables the timeout. If you're doing this, you |
2990
583beaf0b4b8
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2302
diff
changeset
|
107 | may want to connect the clicked() signal to the hide() slot. Setting |
583beaf0b4b8
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2302
diff
changeset
|
108 | the delay to -1 makes it use the default value. |
634
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
109 | |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
110 | @param delay value for the delay in milliseconds (integer) |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
111 | """ |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
112 | self.__hideDelay = delay |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
113 | if self.__hideTimer.isActive(): |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
114 | if delay: |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
115 | if delay == -1: |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
116 | delay = DEFAULT_POPUP_TIME |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
117 | self.__hideTimer.start(delay) |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
118 | else: |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
119 | self.__hideTimer.stop() |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
120 | |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
121 | def timeout(self): |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
122 | """ |
2990
583beaf0b4b8
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2302
diff
changeset
|
123 | Public method to get the delay before the popup is removed |
583beaf0b4b8
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2302
diff
changeset
|
124 | automatically. |
634
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
125 | |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
126 | @return the delay before the popup is removed automatically (integer) |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
127 | """ |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
128 | return self.__hideDelay |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
129 | |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
130 | def mouseReleaseEvent(self, evt): |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
131 | """ |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
132 | Protected method to handle a mouse release event. |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
133 | |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
134 | @param evt reference to the mouse event (QMouseEvent) |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
135 | """ |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
136 | self.clicked[()].emit() |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
137 | self.clicked[(QPoint, )].emit(evt.pos()) |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
138 | |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
139 | def hideEvent(self, evt): |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
140 | """ |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
141 | Protected method to handle the hide event. |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
142 | |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
143 | @param evt reference to the hide event (QHideEvent) |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
144 | """ |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
145 | self.__hideTimer.stop() |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
146 | |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
147 | def __defaultArea(self): |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
148 | """ |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
149 | Private method to determine the default rectangle to be passed to |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
150 | moveNear(). |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
151 | |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
152 | @return default rectangle (QRect) |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
153 | """ |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
154 | return QRect(100, 100, 200, 200) |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
155 | |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
156 | def __positionSelf(self): |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
157 | """ |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
158 | Private method to position the popup. |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
159 | """ |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
160 | self.__moveNear(self.__defaultArea()) |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
161 | |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
162 | def __moveNear(self, target): |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
163 | """ |
2990
583beaf0b4b8
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2302
diff
changeset
|
164 | Private method to move the popup to be adjacent to the specified |
583beaf0b4b8
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2302
diff
changeset
|
165 | rectangle. |
634
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
166 | |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
167 | @param target rectangle to be placed at (QRect) |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
168 | """ |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
169 | pos = self.__calculateNearbyPoint(target) |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
170 | self.move(pos.x(), pos.y()) |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
171 | |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
172 | def __calculateNearbyPoint(self, target): |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
173 | """ |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
174 | Private method to calculate the position to place the popup near the |
634
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
175 | specified rectangle. |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
176 | |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
177 | @param target rectangle to be placed at (QRect) |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
178 | @return position to place the popup (QPoint) |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
179 | """ |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
180 | pos = target.topLeft() |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
181 | x = pos.x() |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
182 | y = pos.y() |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
183 | w = self.minimumSizeHint().width() |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
184 | h = self.minimumSizeHint().height() |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
185 | |
2990
583beaf0b4b8
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2302
diff
changeset
|
186 | r = QApplication.desktop().screenGeometry( |
583beaf0b4b8
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2302
diff
changeset
|
187 | QPoint(x + w // 2, y + h // 2)) |
634
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
188 | |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
189 | if x < r.center().x(): |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
190 | x += target.width() |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
191 | else: |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
192 | x -= w |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
193 | |
2990
583beaf0b4b8
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2302
diff
changeset
|
194 | # It's apparently trying to go off screen, so display it ALL at the |
583beaf0b4b8
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2302
diff
changeset
|
195 | # bottom. |
634
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
196 | if (y + h) > r.bottom(): |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
197 | y = r.bottom() - h |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
198 | |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
199 | if (x + w) > r.right(): |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
200 | x = r.right() - w |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
201 | |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
202 | if y < r.top(): |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
203 | y = r.top() |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
204 | |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
205 | if x < r.left(): |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
206 | x = r.left() |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
207 | |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
208 | return QPoint(x, y) |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
209 | |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
210 | DEFAULT_POPUP_TYPE = E5PassivePopup.Boxed |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
211 | DEFAULT_POPUP_TIME = 6 * 1000 |
3022
57179e4cdadd
Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2990
diff
changeset
|
212 | POPUP_FLAGS = Qt.WindowFlags( |
3034
7ce719013078
Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3022
diff
changeset
|
213 | Qt.Tool | Qt.X11BypassWindowManagerHint | |
634
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
214 | Qt.WindowStaysOnTopHint | Qt.FramelessWindowHint) |