def mouseReleaseEvent(self, event): if self._scrolling: QApplication.restoreOverrideCursor() self._scrolling = False self._scroll_init_y = 0 self._scroll_init_val = 0 event.accept()
def leaveEvent(self, event): """ Overrides base QFrame leaveEvent function :param event: QEvent """ QApplication.restoreOverrideCursor()
def wrapper(*args, **kwargs): cursor = QCursor(Qt.ArrowCursor) QApplication.setOverrideCursor(cursor) try: return fn(*args, **kwargs) finally: QApplication.restoreOverrideCursor()
def show_already_existing_dialog(self): """ Shows a warning dialog if the item already exists on save """ if not self.library_window(): raise exceptions.ItemSaveError('Item already exists!') buttons = QDialogButtonBox.Yes | QDialogButtonBox.Cancel try: QApplication.setOverrideCursor(Qt.ArrowCursor) button = self.library_window().show_question_dialog( 'Item already exists', 'Would you like to move the existing item "{}" to trash?'.format(os.path.basename(self.path())), buttons ) finally: QApplication.restoreOverrideCursor() if button == QDialogButtonBox.Yes: self._move_to_trash() elif button == QMessageBox.Cancel: return button else: raise exceptions.ItemSaveError('You cannot save over an existing item.') return button
def overrideCursor(cursor=QtCore.Qt.WaitCursor): """ For use with the "with" keyword, so the override cursor is always restored via a try/finally block, even if the commands in-between fail. Example: with overrideCursor(): # do something that may raise an error """ from Qt.QtWidgets import QApplication QApplication.setOverrideCursor(cursor) try: yield finally: QApplication.restoreOverrideCursor()
def restoreOverrideCursor(self): if not self._overridden: return QApplication.restoreOverrideCursor() self._overridden = False
def leaveEvent(self, event): if self.can_scroll(): QApplication.restoreOverrideCursor()
def restore_cursor(): """ Restores current Qt application cursor """ QApplication.restoreOverrideCursor()