eric6/E5Gui/E5PassivePopup.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 7945
76daafe10009
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).

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
7923
91e843545d9a Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7780
diff changeset
3 # Copyright (c) 2010 - 2021 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
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
11 from PyQt5.QtCore import pyqtSignal, Qt, QTimer, QPoint, QRect
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
12 from PyQt5.QtWidgets import QFrame, QVBoxLayout, QApplication
634
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13
6915
57f7afc788e4 E5PassivePopup: fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6911
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.
5726
e1dbd217214a Fixed a few source docu issues (forgotten signals and exceptions).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
19
e1dbd217214a Fixed a few source docu issues (forgotten signals and exceptions).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
20 @signal clicked emitted to indicate a mouse button click
634
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 """
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 Boxed = 0
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 Custom = 128
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 clicked = pyqtSignal((), (QPoint, ))
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
27 def __init__(self, parent=None):
634
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 Constructor
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 @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
32 """
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2302
diff changeset
33 super(E5PassivePopup, self).__init__(None)
634
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 self.__popupStyle = DEFAULT_POPUP_TYPE
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 self.__msgView = None
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 self.__topLayout = None
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 self.__hideDelay = DEFAULT_POPUP_TIME
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 self.__hideTimer = QTimer(self)
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 self.__autoDelete = False
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 self.__fixedPosition = QPoint()
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 self.setWindowFlags(POPUP_FLAGS)
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 self.setFrameStyle(QFrame.Box | QFrame.Plain)
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 self.setLineWidth(2)
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46 self.__hideTimer.timeout.connect(self.hide)
3345
071afe8be2a1 Changed signal/slot usage to not use constructs like 'triggered[()].connect(...)' anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
47 self.clicked.connect(self.hide)
6125
bb1c79bf4f33 Fixed an issue with the web tab preview on low performance machines.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
48
bb1c79bf4f33 Fixed an issue with the web tab preview on low performance machines.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
49 self.__customData = {} # dictionary to store some custom data
634
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 def setView(self, child):
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 """
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53 Public method to set the message view.
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54
2990
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
55 @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
56 (QWidget)
634
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57 """
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 self.__msgView = child
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 self.__topLayout = QVBoxLayout(self)
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 self.__topLayout.addWidget(self.__msgView)
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61 self.__topLayout.activate()
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 def view(self):
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 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
66
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67 @return reference to the message view (QWidget)
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 return self.__msgView
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 def setVisible(self, visible):
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 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
74
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 @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
76 """
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77 if not visible:
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2302
diff changeset
78 super(E5PassivePopup, self).setVisible(visible)
634
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79 return
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81 if self.size() != self.sizeHint():
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82 self.resize(self.sizeHint())
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84 if self.__fixedPosition.isNull():
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85 self.__positionSelf()
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86 else:
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
87 self.move(self.__fixedPosition)
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2302
diff changeset
88 super(E5PassivePopup, self).setVisible(True)
634
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
89
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
90 delay = self.__hideDelay
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91 if delay < 0:
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92 delay = DEFAULT_POPUP_TIME
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93 if delay > 0:
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94 self.__hideTimer.start(delay)
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
95
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
96 def show(self, p=None):
634
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 Public slot to show the popup.
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
99
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
100 @param p position for the popup (QPoint)
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 if p is not None:
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
103 self.__fixedPosition = p
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2302
diff changeset
104 super(E5PassivePopup, self).show()
634
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 def setTimeout(self, delay):
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107 """
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
108 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
109
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
110 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
111 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
112 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
113
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
114 @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
115 """
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
116 self.__hideDelay = delay
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117 if self.__hideTimer.isActive():
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
118 if delay:
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119 if delay == -1:
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120 delay = DEFAULT_POPUP_TIME
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
121 self.__hideTimer.start(delay)
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
122 else:
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
123 self.__hideTimer.stop()
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
124
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
125 def timeout(self):
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
126 """
2990
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
127 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
128 automatically.
634
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 @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
131 """
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
132 return self.__hideDelay
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 def mouseReleaseEvent(self, evt):
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 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
137
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
138 @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
139 """
3345
071afe8be2a1 Changed signal/slot usage to not use constructs like 'triggered[()].connect(...)' anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
140 self.clicked.emit()
071afe8be2a1 Changed signal/slot usage to not use constructs like 'triggered[()].connect(...)' anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
141 self.clicked.emit(evt.pos())
634
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 def hideEvent(self, evt):
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 Protected method to handle the hide event.
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 @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
148 """
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
149 self.__hideTimer.stop()
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
150
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
151 def __defaultArea(self):
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
152 """
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
153 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
154 moveNear().
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 @return default rectangle (QRect)
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 return QRect(100, 100, 200, 200)
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 def __positionSelf(self):
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 Private method to position the popup.
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
163 """
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
164 self.__moveNear(self.__defaultArea())
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
165
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
166 def __moveNear(self, target):
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
167 """
2990
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
168 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
169 rectangle.
634
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
170
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
171 @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
172 """
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
173 pos = self.__calculateNearbyPoint(target)
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
174 self.move(pos.x(), pos.y())
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
175
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
176 def __calculateNearbyPoint(self, target):
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
177 """
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
178 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
179 specified rectangle.
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
180
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
181 @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
182 @return position to place the popup (QPoint)
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
183 """
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
184 pos = target.topLeft()
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
185 x = pos.x()
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
186 y = pos.y()
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
187 w = self.minimumSizeHint().width()
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
188 h = self.minimumSizeHint().height()
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
189
7945
76daafe10009 Removed code dealing with Qt versions less than the required one and removed use of QDesktopWidget or QApplication.desktop().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
190 r = QApplication.screenAt(QPoint(x + w // 2, y + h // 2)).geometry()
634
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
191
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
192 if x < r.center().x():
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
193 x += target.width()
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
194 else:
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
195 x -= w
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
196
2990
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
197 # 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
198 # bottom.
634
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
199 if (y + h) > r.bottom():
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
200 y = r.bottom() - h
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 (x + w) > r.right():
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
203 x = r.right() - w
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 y < r.top():
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
206 y = r.top()
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 if x < r.left():
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
209 x = r.left()
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
210
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
211 return QPoint(x, y)
6125
bb1c79bf4f33 Fixed an issue with the web tab preview on low performance machines.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
212
bb1c79bf4f33 Fixed an issue with the web tab preview on low performance machines.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
213 def setCustomData(self, key, data):
bb1c79bf4f33 Fixed an issue with the web tab preview on low performance machines.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
214 """
bb1c79bf4f33 Fixed an issue with the web tab preview on low performance machines.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
215 Public method to set some custom data.
bb1c79bf4f33 Fixed an issue with the web tab preview on low performance machines.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
216
bb1c79bf4f33 Fixed an issue with the web tab preview on low performance machines.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
217 @param key key for the custom data
bb1c79bf4f33 Fixed an issue with the web tab preview on low performance machines.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
218 @type str
bb1c79bf4f33 Fixed an issue with the web tab preview on low performance machines.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
219 @param data data to be stored
bb1c79bf4f33 Fixed an issue with the web tab preview on low performance machines.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
220 @type any
bb1c79bf4f33 Fixed an issue with the web tab preview on low performance machines.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
221 """
bb1c79bf4f33 Fixed an issue with the web tab preview on low performance machines.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
222 self.__customData[key] = data
bb1c79bf4f33 Fixed an issue with the web tab preview on low performance machines.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
223
bb1c79bf4f33 Fixed an issue with the web tab preview on low performance machines.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
224 def getCustomData(self, key):
bb1c79bf4f33 Fixed an issue with the web tab preview on low performance machines.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
225 """
bb1c79bf4f33 Fixed an issue with the web tab preview on low performance machines.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
226 Public method to get some custom data.
bb1c79bf4f33 Fixed an issue with the web tab preview on low performance machines.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
227
bb1c79bf4f33 Fixed an issue with the web tab preview on low performance machines.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
228 @param key key for the custom data
bb1c79bf4f33 Fixed an issue with the web tab preview on low performance machines.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
229 @type str
bb1c79bf4f33 Fixed an issue with the web tab preview on low performance machines.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
230 @return stored data
bb1c79bf4f33 Fixed an issue with the web tab preview on low performance machines.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
231 @rtype any
bb1c79bf4f33 Fixed an issue with the web tab preview on low performance machines.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
232 """
bb1c79bf4f33 Fixed an issue with the web tab preview on low performance machines.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
233 return self.__customData[key]
634
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
234
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
235 DEFAULT_POPUP_TYPE = E5PassivePopup.Boxed
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
236 DEFAULT_POPUP_TIME = 6 * 1000
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2990
diff changeset
237 POPUP_FLAGS = Qt.WindowFlags(
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3022
diff changeset
238 Qt.Tool | Qt.X11BypassWindowManagerHint |
634
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
239 Qt.WindowStaysOnTopHint | Qt.FramelessWindowHint)

eric ide

mercurial