Ejemplo n.º 1
0
def consumeKey(ctxt, pressed):
    """
    build the proper QKeyEvent from Softimage key event and send the it along to the focused widget
    """
    kcode = ctxt.GetAttribute("KeyCode")
    mask = ctxt.GetAttribute("ShiftMask")

    # Build the modifiers
    modifier = Qt.NoModifier
    if mask and C.siShiftMask:
        if kcode + 300 in KEY_MAPPING:
            kcode += 300

        modifier |= Qt.ShiftModifier

    if mask and C.siCtrlMask:
        modifier |= Qt.ControlModifier

    if mask and C.siAltMask:
        modifier |= Qt.AltModifier

    # Generate a Qt Key Event to be processed
    result = KEY_MAPPING.get(kcode)
    if result:
        if pressed:
            event = QKeyEvent.KeyPress
        else:
            event = QKeyEvent.KeyRelease

        if result[2]:
            modifier |= result[2]

        # Send the event along to the focused widget
        QApplication.sendEvent(QApplication.instance().focusWidget(), QKeyEvent(event, result[0], modifier, result[1]))
Ejemplo n.º 2
0
    def mouseReleaseEvent( self, event ):
        if self._scrolling:
            QApplication.restoreOverrideCursor()

        self._scrolling = False
        self._scrollInitY = 0
        self._scrollInitVal = 0
        event.accept()
Ejemplo n.º 3
0
    def mousePressEvent( self, event ):
        # handle a scroll event
        if event.button() == Qt.LeftButton and self.canScroll():
            self._scrolling = True
            self._scrollInitY = event.globalY()
            self._scrollInitVal = self.verticalScrollBar().value()

            QApplication.setOverrideCursor(Qt.ClosedHandCursor)

        event.accept()
Ejemplo n.º 4
0
def isFocusWidget():
    """
    return true if the global qApp has any focused widgets
    """
    focus = False
    if QApplication.instance():
        if QApplication.instance().focusWidget():
            window = QApplication.instance().focusWidget().window()
            geom = window.geometry()
            focus = geom.contains(QCursor.pos())

    return focus
Ejemplo n.º 5
0
def isFocusWidget():
    """
    return true if the global qApp has any focused widgets
    """
    focus = False
    if QApplication.instance():
        if QApplication.instance().focusWidget():
            window = QApplication.instance().focusWidget().window()
            geom = window.geometry()
            focus = not window.isMinimized() and geom.contains(QCursor.pos())

    return focus
Ejemplo n.º 6
0
    def generateScheme(self, apply=True):
        """Generate color palette
        By default the generated palette is also applied to the whole application
        To override supply the apply=False argument
        """
        BASE_COLOR = self.baseColor
        HIGHLIGHT_COLOR = self.highlightColor
        BRIGHTNESS_SPREAD = self.spread

        if self.__lightness(BASE_COLOR) > 0.5:
            SPREAD = 100 / BRIGHTNESS_SPREAD
        else:
            SPREAD = 100 * BRIGHTNESS_SPREAD

        if self.__lightness(HIGHLIGHT_COLOR) > 0.6:
            HIGHLIGHTEDTEXT_COLOR = BASE_COLOR.darker(SPREAD * 2)
        else:
            HIGHLIGHTEDTEXT_COLOR = BASE_COLOR.lighter(SPREAD * 2)

        self.palette.setBrush(QPalette.Window, QBrush(BASE_COLOR))

        self.palette.setBrush(QPalette.WindowText,
                              QBrush(BASE_COLOR.lighter(SPREAD * 2)))
        self.palette.setBrush(QPalette.Foreground,
                              QBrush(BASE_COLOR.lighter(SPREAD)))
        self.palette.setBrush(QPalette.Base, QBrush(BASE_COLOR))
        self.palette.setBrush(QPalette.AlternateBase,
                              QBrush(BASE_COLOR.darker(SPREAD)))
        self.palette.setBrush(QPalette.ToolTipBase, QBrush(BASE_COLOR))
        self.palette.setBrush(QPalette.ToolTipText,
                              QBrush(BASE_COLOR.lighter(SPREAD)))
        self.palette.setBrush(QPalette.Text,
                              QBrush(BASE_COLOR.lighter(SPREAD * 1.8)))
        self.palette.setBrush(QPalette.Button, QBrush(BASE_COLOR))
        self.palette.setBrush(QPalette.ButtonText,
                              QBrush(BASE_COLOR.lighter(SPREAD * 1.2)))
        self.palette.setBrush(QPalette.BrightText, QBrush(QColor("#ffffff")))

        self.palette.setBrush(QPalette.Light,
                              QBrush(BASE_COLOR.lighter(SPREAD)))
        self.palette.setBrush(QPalette.Midlight,
                              QBrush(BASE_COLOR.lighter(SPREAD / 2)))
        self.palette.setBrush(QPalette.Dark, QBrush(BASE_COLOR.darker(SPREAD)))
        self.palette.setBrush(QPalette.Mid, QBrush(BASE_COLOR))
        self.palette.setBrush(QPalette.Shadow,
                              QBrush(BASE_COLOR.darker(SPREAD * 2)))

        self.palette.setBrush(QPalette.Highlight, QBrush(HIGHLIGHT_COLOR))
        self.palette.setBrush(QPalette.HighlightedText,
                              QBrush(HIGHLIGHTEDTEXT_COLOR))
        if apply:
            QApplication.setPalette(self.palette)
Ejemplo n.º 7
0
 def __init__(self,
              baseColor=QColor("#f7f7f7"),
              highlightColor=QColor("#2196F3"),
              spread=2.5):
     """Constructor
     By default a nukeish color scheme (dark slate + orange highlight) is created
     This can be overriden by either supplying colors or by loading a different
     scheme from disc via the load settings
     """
     self.palette = QPalette()
     self.baseColor = baseColor
     self.highlightColor = highlightColor
     self.spread = spread
     self.generateScheme()
     QApplication.setStyle("Plastique")
Ejemplo n.º 8
0
def start_test_app(target, width=500, *args):
    """Start a single window test application with a form automatically
    generated for the driver.

    :param target: a driver object or a collection of drivers.
    :param width: to be used as minimum width of the window.
    :param args: arguments to be passed to QApplication.
    """
    app = QApplication(list(args))
    if isinstance(target, Driver):
        main = DriverTestWidget(None, target)
    else:
        main = SetupTestWidget(None, target)
    main.setMinimumWidth(width)
    main.setWindowTitle('Lantz Driver Test Panel')
    main.show()
    if sys.platform.startswith('darwin'):
        main.raise_()
    app.exec_()
Ejemplo n.º 9
0
def start_test_app(target, width=500, *args):
    """Start a single window test application with a form automatically
    generated for the driver.

    :param target: a driver object or a collection of drivers.
    :param width: to be used as minimum width of the window.
    :param args: arguments to be passed to QApplication.
    """
    app = QApplication(list(args))
    if isinstance(target, Driver):
        main = DriverTestWidget(None, target)
    else:
        main = SetupTestWidget(None, target)
    main.setMinimumWidth(width)
    main.setWindowTitle('Lantz Driver Test Panel')
    main.show()
    if sys.platform.startswith('darwin'):
        main.raise_()
    app.exec_()
Ejemplo n.º 10
0
def consumeKey(ctxt, pressed):
    """
    build the proper QKeyEvent from Softimage key event and send the it along to the focused widget
    """
    kcode = ctxt.GetAttribute("KeyCode")
    mask = ctxt.GetAttribute("ShiftMask")

    # Build the modifiers
    modifier = Qt.NoModifier
    if mask & C.siShiftMask:
        if kcode + 300 in KEY_MAPPING:
            kcode += 300

        modifier |= Qt.ShiftModifier

    if mask & C.siCtrlMask:
        modifier |= Qt.ControlModifier

    if mask & C.siAltMask:
        modifier |= Qt.AltModifier

    # Generate a Qt Key Event to be processed
    result = KEY_MAPPING.get(kcode)
    if result:
        if pressed:
            event = QKeyEvent.KeyPress
        else:
            event = QKeyEvent.KeyRelease

        if result[2]:
            modifier |= result[2]

        # Send the event along to the focused widget
        QApplication.sendEvent(
            QApplication.instance().focusWidget(),
            QKeyEvent(event, result[0], modifier, result[1]))
Ejemplo n.º 11
0
 def leaveEvent( self, event ):
     if self.canScroll():
         QApplication.restoreOverrideCursor()
Ejemplo n.º 12
0
 def enterEvent( self, event ):
     if self.canScroll():
         QApplication.setOverrideCursor(Qt.OpenHandCursor)