Beispiel #1
0
    def enterEvent(self, event):
        """
        Overrides base QFrame enterEvenet function
        :param event: QEvent
        """

        QApplication.setOverrideCursor(Qt.SizeHorCursor)
Beispiel #2
0
 def mousePressEvent(self, event):
     if event.button() == Qt.LeftButton and self.can_scroll():
         self._scrolling = True
         self._scroll_init_y = event.globalY()
         self._scroll_init_val = self.verticalScrollBar().value()
         QApplication.setOverrideCursor(Qt.ClosedHandCursor)
     event.accept()
Beispiel #3
0
 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
Beispiel #5
0
def set_wait_cursor(state=True):
    """
    Sets the wait cursor as the cursor for current Qt application
    """

    if state:
        QApplication.setOverrideCursor(Qt.WaitCursor)
    else:
        restore_cursor()
Beispiel #6
0
    def enterEvent(self, event):
        """
        Overrides base QFrame enterEvenet function
        :param event: QEvent
        """

        if self._direction == ResizeDirection.Left | ResizeDirection.Top or \
                self._direction == ResizeDirection.Right | ResizeDirection.Bottom:
            QApplication.setOverrideCursor(Qt.SizeFDiagCursor)
        elif self._direction == ResizeDirection.Right | ResizeDirection.Top or \
                self._direction == ResizeDirection.Left | ResizeDirection.Bottom:
            QApplication.setOverrideCursor(Qt.SizeBDiagCursor)
Beispiel #7
0
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()
Beispiel #8
0
    def doOverrideCursor(self):
        if self._overridden:
            return
        if self.dragCursor == self.CURSOR_BLANK:
            QApplication.setOverrideCursor(Qt.BlankCursor)
        elif self.dragCursor == self.CURSOR_ARROWS:
            if self._dragType == self.DRAG_VERTICAL:
                QApplication.setOverrideCursor(Qt.SizeVerCursor)
            elif self._dragType == self.DRAG_HORIZONTAL:
                QApplication.setOverrideCursor(Qt.SizeHorCursor)

        self._overridden = True
Beispiel #9
0
 def enterEvent(self, event):
     if self.can_scroll():
         QApplication.setOverrideCursor(Qt.OpenHandCursor)