Beispiel #1
0
    def mousePressEvent(self, event):
        self.prevValue = self.value()
        self.startDragpos = event.pos()

        emodif = event.modifiers()
        modif = [
            QtCore.Qt.ControlModifier, QtCore.Qt.ShiftModifier,
            QtCore.Qt.ControlModifier | QtCore.Qt.ShiftModifier
        ]

        if event.button() == QtCore.Qt.MidButton:
            if self.draggers is None:
                self.draggers = draggers(self,
                                         self.isFloat,
                                         draggerSteps=self.draggerSteps)
                self.draggers.increment.connect(self.valueIncremented.emit)
            self.draggers.show()
            if self.isFloat:
                self.draggers.move(
                    self.mapToGlobal(
                        QtCore.QPoint(
                            event.pos().x() - 1,
                            event.pos().y() - self.draggers.height() / 2)))
            else:
                self.draggers.move(
                    self.mapToGlobal(
                        QtCore.QPoint(
                            event.pos().x() - 1,
                            event.pos().y() - (self.draggers.height() -
                                               self.draggers.height() / 6))))

        elif event.button() == self.LeftButton and emodif not in modif:
            butts = QtCore.Qt.MouseButtons(self.MidButton)
            nevent = QtGui.QMouseEvent(event.type(),
                                       event.pos(), self.MidButton, butts,
                                       event.modifiers())
            super(slider, self).mousePressEvent(nevent)

        elif emodif in modif:
            st_slider = QtWidgets.QStyleOptionSlider()
            st_slider.initFrom(self)
            st_slider.orientation = self.orientation()
            available = self.style().pixelMetric(
                QtWidgets.QStyle.PM_SliderSpaceAvailable, st_slider, self)
            xloc = QtWidgets.QStyle.sliderPositionFromValue(
                self.minimum(), self.maximum(),
                super(slider, self).value(), available)
            butts = QtCore.Qt.MouseButtons(self.MidButton)
            newPos = QtCore.QPointF()
            newPos.setX(xloc)
            nevent = QtGui.QMouseEvent(event.type(), newPos, self.MidButton,
                                       butts, event.modifiers())
            self.startDragpos = newPos
            self.realStartDragpos = event.pos()
            super(slider, self).mousePressEvent(nevent)
            self.deltaValue = self.value() - self.prevValue
            self.setValue(self.prevValue)
        else:
            super(slider, self).mousePressEvent(event)
Beispiel #2
0
    def drawShape(self, painter):
        borderWidth = 1
        w = self.width() - borderWidth
        h = self.height() - borderWidth

        triangle = QtGui.QPolygon([QtCore.QPoint(-1, 0),
                                  QtCore.QPoint(-1, h - 1),
                                  QtCore.QPoint(w - 1, h / 2)])
        path = QtGui.QPainterPath()
        path.addPolygon(triangle)
        self.drawPathWithBorder(painter, path, borderWidth)
        painter.setClipRegion(triangle, QtCore.Qt.ReplaceClip)
Beispiel #3
0
    def _layer_menu(self, QPos):
        """Create the layers rightclick menu

        Args:
            QPos (QPos): Position

        Returns:
            None: None
        """
        lyr_widget = self.crankUIWInst.layers_listView
        currentSelection = lyr_widget.selectedIndexes()
        if currentSelection is None:
            return
        self.lyr_menu = QtWidgets.QMenu()
        parentPosition = lyr_widget.mapToGlobal(QtCore.QPoint(0, 0))
        menu_item_01 = self.lyr_menu.addAction("Select Members")
        self.lyr_menu.addSeparator()
        menu_item_02 = self.lyr_menu.addAction("Selected Layer Edit OFF")
        menu_item_03 = self.lyr_menu.addAction("All Layers Edit OFF")
        self.lyr_menu.addSeparator()

        menu_item_01.triggered.connect(self.select_members)
        menu_item_02.triggered.connect(self.edit_layer_off)
        menu_item_03.triggered.connect(self.edit_all_off)

        self.lyr_menu.move(parentPosition + QPos)
        self.lyr_menu.show()
    def _search_menu(self, QPos):
        search_widget = self.gmcUIInst.search_lineEdit

        self.search_menu = QtWidgets.QMenu()
        parentPosition = search_widget.mapToGlobal(QtCore.QPoint(0, 0))
        menu_item_01 = self.search_menu.addAction("Clear")
        menu_item_01.triggered.connect(search_widget.clear)
        self.search_menu.move(parentPosition + QPos)
        self.search_menu.show()
Beispiel #5
0
    def __init__(self, *args, **kwargs):
        # type: () -> None

        super(SynopticTabWrapper, self).__init__(*args, **kwargs)

        self.setAttribute(QtCore.Qt.WA_DeleteOnClose)

        self.rubberband = QtWidgets.QRubberBand(
            QtWidgets.QRubberBand.Rectangle, self)

        self.offset = QtCore.QPoint()
Beispiel #6
0
 def eventFilter(self, object, event):
     if event.type() == QtCore.QEvent.MouseButtonPress:
         if event.button() == QtCore.Qt.MiddleButton:
             if self.draggers is None:
                 self.draggers = draggers(self,
                                          self.isFloat,
                                          draggerSteps=self.draggerSteps)
                 self.draggers.increment.connect(self.onValueIncremented)
             self.draggers.show()
             if self.isFloat:
                 self.draggers.move(
                     self.mapToGlobal(
                         QtCore.QPoint(
                             event.pos().x() - 1,
                             event.pos().y() - self.draggers.height() / 2)))
             else:
                 self.draggers.move(
                     self.mapToGlobal(
                         QtCore.QPoint(
                             event.pos().x() - 1,
                             event.pos().y() - self.draggers.height() +
                             15)))
     return False
    def _component_menu(self, QPos):
        """Create the component list rightclick menu

        Args:
            QPos (QPos): Position

        Returns:
            None: None
        """
        comp_widget = self.gmcUIInst.component_listView
        currentSelection = comp_widget.selectedIndexes()
        if currentSelection is None:
            return
        self.comp_menu = QtWidgets.QMenu()
        parentPosition = comp_widget.mapToGlobal(QtCore.QPoint(0, 0))
        menu_item_01 = self.comp_menu.addAction("Draw Component")
        self.comp_menu.addSeparator()
        menu_item_02 = self.comp_menu.addAction("Refresh List")

        menu_item_01.triggered.connect(self.draw_component)
        menu_item_02.triggered.connect(self._refreshList)

        self.comp_menu.move(parentPosition + QPos)
        self.comp_menu.show()
Beispiel #8
0
    def calculateOffset(self):
        # type: () -> QtCore.QPoint

        w = self.spacer.geometry().width()
        return QtCore.QPoint(w * -1, 0)