eric6/E5Gui/E5OverrideCursor.py

changeset 8143
2c730d5fd177
parent 8118
0ecebcd8875e
child 8218
7c09585bd960
equal deleted inserted replaced
8141:27f636beebad 8143:2c730d5fd177
16 16
17 class E5OverrideCursor(contextlib.AbstractContextManager): 17 class E5OverrideCursor(contextlib.AbstractContextManager):
18 """ 18 """
19 Class implementing a context manager class for an override cursor. 19 Class implementing a context manager class for an override cursor.
20 """ 20 """
21 def __init__(self, cursorShape=Qt.WaitCursor): 21 def __init__(self, cursorShape=Qt.CursorShape.WaitCursor):
22 """ 22 """
23 Constructor 23 Constructor
24 24
25 @param cursorShape shape of the override cursor 25 @param cursorShape shape of the override cursor
26 @type Qt.CursorShape 26 @type Qt.CursorShape
33 33
34 @return reference to the context manager object 34 @return reference to the context manager object
35 @rtype E5OverrideCursor 35 @rtype E5OverrideCursor
36 """ 36 """
37 QGuiApplication.setOverrideCursor(QCursor(self.__cursorShape)) 37 QGuiApplication.setOverrideCursor(QCursor(self.__cursorShape))
38 QGuiApplication.processEvents(QEventLoop.ExcludeUserInputEvents) 38 QGuiApplication.processEvents(
39 QEventLoop.ProcessEventsFlag.ExcludeUserInputEvents)
39 40
40 return self 41 return self
41 42
42 def __exit__(self, exc_type, exc_value, traceback): 43 def __exit__(self, exc_type, exc_value, traceback):
43 """ 44 """
49 context 50 context
50 @return always returns None to not suppress any exception 51 @return always returns None to not suppress any exception
51 @rtype None 52 @rtype None
52 """ 53 """
53 QGuiApplication.restoreOverrideCursor() 54 QGuiApplication.restoreOverrideCursor()
54 QGuiApplication.processEvents(QEventLoop.ExcludeUserInputEvents) 55 QGuiApplication.processEvents(
56 QEventLoop.ProcessEventsFlag.ExcludeUserInputEvents)
55 57
56 return None # __IGNORE_WARNING_M831__ 58 return None # __IGNORE_WARNING_M831__
57 59
58 60
59 class E5OverridenCursor(contextlib.AbstractContextManager): 61 class E5OverridenCursor(contextlib.AbstractContextManager):
78 """ 80 """
79 cursor = QGuiApplication.overrideCursor() 81 cursor = QGuiApplication.overrideCursor()
80 if cursor is not None: 82 if cursor is not None:
81 self.__cursorShape = cursor.shape() 83 self.__cursorShape = cursor.shape()
82 QGuiApplication.restoreOverrideCursor() 84 QGuiApplication.restoreOverrideCursor()
83 QGuiApplication.processEvents(QEventLoop.ExcludeUserInputEvents) 85 QGuiApplication.processEvents(
86 QEventLoop.ProcessEventsFlag.ExcludeUserInputEvents)
84 87
85 return self 88 return self
86 89
87 def __exit__(self, exc_type, exc_value, traceback): 90 def __exit__(self, exc_type, exc_value, traceback):
88 """ 91 """
95 @return always returns None to not suppress any exception 98 @return always returns None to not suppress any exception
96 @rtype None 99 @rtype None
97 """ 100 """
98 if self.__cursorShape is not None: 101 if self.__cursorShape is not None:
99 QGuiApplication.setOverrideCursor(QCursor(self.__cursorShape)) 102 QGuiApplication.setOverrideCursor(QCursor(self.__cursorShape))
100 QGuiApplication.processEvents(QEventLoop.ExcludeUserInputEvents) 103 QGuiApplication.processEvents(
104 QEventLoop.ProcessEventsFlag.ExcludeUserInputEvents)
101 105
102 return None # __IGNORE_WARNING_M831__ 106 return None # __IGNORE_WARNING_M831__
103 107
104 108
105 class E5OverrideCursorProcess(QProcess): 109 class E5OverrideCursorProcess(QProcess):
106 """ 110 """
107 Class implementing a QProcess subclass controlling an override cursor. 111 Class implementing a QProcess subclass controlling an override cursor.
108 """ 112 """
109 def __init__(self, parent=None, cursorShape=Qt.WaitCursor): 113 def __init__(self, parent=None, cursorShape=Qt.CursorShape.WaitCursor):
110 """ 114 """
111 Constructor 115 Constructor
112 116
113 @param parent reference to the parent object 117 @param parent reference to the parent object
114 @type QObject 118 @type QObject
126 def __processStarted(self): 130 def __processStarted(self):
127 """ 131 """
128 Private slot setting the cursor after the process has started. 132 Private slot setting the cursor after the process has started.
129 """ 133 """
130 QGuiApplication.setOverrideCursor(QCursor(self.__cursorShape)) 134 QGuiApplication.setOverrideCursor(QCursor(self.__cursorShape))
131 QGuiApplication.processEvents(QEventLoop.ExcludeUserInputEvents) 135 QGuiApplication.processEvents(
136 QEventLoop.ProcessEventsFlag.ExcludeUserInputEvents)
132 137
133 @pyqtSlot() 138 @pyqtSlot()
134 def __processFinished(self): 139 def __processFinished(self):
135 """ 140 """
136 Private slot resetting the cursor when the process finished. 141 Private slot resetting the cursor when the process finished.
137 """ 142 """
138 QGuiApplication.restoreOverrideCursor() 143 QGuiApplication.restoreOverrideCursor()
139 QGuiApplication.processEvents(QEventLoop.ExcludeUserInputEvents) 144 QGuiApplication.processEvents(
145 QEventLoop.ProcessEventsFlag.ExcludeUserInputEvents)

eric ide

mercurial