--- a/src/eric7/EricGui/EricOverrideCursor.py Wed Jul 13 11:16:20 2022 +0200 +++ b/src/eric7/EricGui/EricOverrideCursor.py Wed Jul 13 14:55:47 2022 +0200 @@ -18,32 +18,34 @@ """ Class implementing a context manager class for an override cursor. """ + def __init__(self, cursorShape=Qt.CursorShape.WaitCursor): """ Constructor - + @param cursorShape shape of the override cursor @type Qt.CursorShape """ self.__cursorShape = cursorShape - + def __enter__(self): """ Special method called when entering the runtime ccontext. - + @return reference to the context manager object @rtype EricOverrideCursor """ QGuiApplication.setOverrideCursor(QCursor(self.__cursorShape)) QGuiApplication.processEvents( - QEventLoop.ProcessEventsFlag.ExcludeUserInputEvents) - + QEventLoop.ProcessEventsFlag.ExcludeUserInputEvents + ) + return self - + def __exit__(self, exc_type, exc_value, traceback): """ Special method called when exiting the runtime ccontext. - + @param exc_type type of an exception raised in the runtime context @param exc_value value of an exception raised in the runtime context @param traceback traceback of an exception raised in the runtime @@ -53,28 +55,30 @@ """ QGuiApplication.restoreOverrideCursor() QGuiApplication.processEvents( - QEventLoop.ProcessEventsFlag.ExcludeUserInputEvents) - - return None # __IGNORE_WARNING_M831__ + QEventLoop.ProcessEventsFlag.ExcludeUserInputEvents + ) + + return None # __IGNORE_WARNING_M831__ class EricOverridenCursor(contextlib.AbstractContextManager): """ Class implementing a context manager class for an overriden cursor. - + The cursor is reset upon entering the runtime context and restored upon exiting it. """ + def __init__(self): """ Constructor """ self.__cursorShape = None - + def __enter__(self): """ Special method called when entering the runtime ccontext. - + @return reference to the context manager object @rtype EricOverrideCursor """ @@ -83,14 +87,15 @@ self.__cursorShape = cursor.shape() QGuiApplication.restoreOverrideCursor() QGuiApplication.processEvents( - QEventLoop.ProcessEventsFlag.ExcludeUserInputEvents) - + QEventLoop.ProcessEventsFlag.ExcludeUserInputEvents + ) + return self - + def __exit__(self, exc_type, exc_value, traceback): """ Special method called when exiting the runtime ccontext. - + @param exc_type type of an exception raised in the runtime context @param exc_value value of an exception raised in the runtime context @param traceback traceback of an exception raised in the runtime @@ -101,31 +106,33 @@ if self.__cursorShape is not None: QGuiApplication.setOverrideCursor(QCursor(self.__cursorShape)) QGuiApplication.processEvents( - QEventLoop.ProcessEventsFlag.ExcludeUserInputEvents) - - return None # __IGNORE_WARNING_M831__ + QEventLoop.ProcessEventsFlag.ExcludeUserInputEvents + ) + + return None # __IGNORE_WARNING_M831__ class EricOverrideCursorProcess(QProcess): """ Class implementing a QProcess subclass controlling an override cursor. """ + def __init__(self, parent=None, cursorShape=Qt.CursorShape.WaitCursor): """ Constructor - + @param parent reference to the parent object @type QObject @param cursorShape shape of the override cursor @type Qt.CursorShape """ super().__init__(parent) - + self.__cursorShape = cursorShape - + self.started.connect(self.__processStarted) self.finished.connect(self.__processFinished) - + @pyqtSlot() def __processStarted(self): """ @@ -133,8 +140,9 @@ """ QGuiApplication.setOverrideCursor(QCursor(self.__cursorShape)) QGuiApplication.processEvents( - QEventLoop.ProcessEventsFlag.ExcludeUserInputEvents) - + QEventLoop.ProcessEventsFlag.ExcludeUserInputEvents + ) + @pyqtSlot() def __processFinished(self): """ @@ -142,4 +150,5 @@ """ QGuiApplication.restoreOverrideCursor() QGuiApplication.processEvents( - QEventLoop.ProcessEventsFlag.ExcludeUserInputEvents) + QEventLoop.ProcessEventsFlag.ExcludeUserInputEvents + )