Ejemplo n.º 1
0
 def resizeEvent(self, r: QResizeEvent) -> None:
     """
     Qt Resize Event - does two things:
     1) applies rounded corners if window transparency has been disabled
     2) ensures resizer widgets and titlebar buttons stay in place
     TODO: the 'rounded_corner_px' value is harcoded. It relates to in '.TitleTabBar::tab' in
           widgetstyle/tabwidget_titlebar.py (border-width and border-image QSS attribute).
           Action: investigate a way so that this value doesn't have to be hard-coded.
     """
     # if transparency is turned off, set a mask for some basic rounded corners:
     if not self.__transparent_window and self.__style.window.WINDOW_CORNER_RADIUS_PX > 0:
         path = QPainterPath()
         path.addRoundedRect(
             QRectF(self.rect()),
             self.__style.window.WINDOW_CORNER_RADIUS_PX +
             1,  # add 1 to avoid drawing artifacts
             self.__style.window.WINDOW_CORNER_RADIUS_PX + 1)
         reg = QRegion(path.toFillPolygon().toPolygon())
         self.setMask(reg)
     # adjust window button positions
     if not isinstance(self.__window, QDIALOG_TYPES):
         self.resizer_bl.adjust_resizers(self.geometry(
         ))  # adjusting one resizer adjusts all other resizers too
     if self.__window_buttons_position == WINDOW_BUTTONS_RIGHT:
         self.__move_window_buttons()
     # if a titlebar tab widget is set, mask it so that the empty area can be used to drag the window
     if self.__tab_widget is not None:
         width = 0
         tab_bar = self.__tab_widget.tabBar()
         for i in range(0,
                        tab_bar.count() -
                        1):  # don't count invisible tab at end
             if tab_bar.isTabVisible(i):
                 width += tab_bar.tabRect(i).width()
         rounder_corner_px = 8  # TODO  # related to hardcoded border-image value in widgetstyle/tabwidget_titlebar.py
         r = QRect(0, 0, width + rounder_corner_px, self.__titlebar_height)
         self.__tab_widget.tabBar().setMask(r)
Ejemplo n.º 2
0
    def setupUI(self):
        currentFilePath = os.path.dirname(__file__)

        # .uiファイルを読み込み
        loader = QUiLoader()
        uiFilePath = os.path.join(currentFilePath,
                                  'kkDisplayVertexColorSeparatelyGUI.ui')
        self.uiFIle = loader.load(uiFilePath)
        self.setCentralWidget(self.uiFIle)

        # scriptJobのparent設定のためにオブジェクト名を設定
        self.setObjectName("kkDisplayVertexColorSeparatelyWindow")

        # ウインドウのタイトルを指定
        self.setWindowTitle("kkDisplayVertexColorSeparately")

        # ウインドウのサイズを指定
        self.resize(200, 300)

        # UI要素にシグナルを追加
        self.setSignals()

        # SelectedNameに選択オブジェクト名を表示
        self.uiFIle.lineEdit_SelObj.setText(self.targetObj.name())

        # 内蔵のpaintVertexColourツールアイコンをセットする
        self.uiFIle.btn_PaintTool.setIcon(QIcon(':/paintVertexColour.png'))

        # フレームレスにする
        self.setWindowFlags(Qt.Window | Qt.FramelessWindowHint)

        # ウィンドウ自体の角を丸くする
        path = QPainterPath()
        path.addRoundedRect(self.rect(), 10, 10)
        region = QRegion(path.toFillPolygon().toPolygon())
        self.setMask(region)
Ejemplo n.º 3
0
    def __init__(self, targetImage=None, axeSize=500, layer=None, parent=None):
        super().__init__(layer=layer, targetImage=targetImage, parent=parent)
        self.options = None
        pushButton1 = QPushButton(' Undo ')
        pushButton1.adjustSize()
        pushButton2 = QPushButton(' Redo ')
        pushButton2.adjustSize()

        pushButton1.clicked.connect(self.undo)
        pushButton2.clicked.connect(self.redo)

        spacingSlider = QSlider(Qt.Horizontal)
        spacingSlider.setObjectName('spacingSlider')
        spacingSlider.setRange(1,60)
        spacingSlider.setTickPosition(QSlider.TicksBelow)
        spacingSlider.setSliderPosition(10)
        spacingSlider.sliderReleased.connect(self.parent().label.brushUpdate)
        self.spacingSlider = spacingSlider

        jitterSlider = QSlider(Qt.Horizontal)
        jitterSlider.setObjectName('jitterSlider')
        jitterSlider.setRange(0, 100)
        jitterSlider.setTickPosition(QSlider.TicksBelow)
        jitterSlider.setSliderPosition(0)
        jitterSlider.sliderReleased.connect(self.parent().label.brushUpdate)
        self.jitterSlider = jitterSlider

        orientationSlider = QSlider(Qt.Horizontal)
        orientationSlider.setObjectName('orientationSlider')
        orientationSlider.setRange(0, 360)
        orientationSlider.setTickPosition(QSlider.TicksBelow)
        orientationSlider.setSliderPosition(180)
        orientationSlider.sliderReleased.connect(self.parent().label.brushUpdate)
        self.orientationSlider = orientationSlider

        # sample
        self.sample = QLabel()
        #self.sample.setMinimumSize(200, 100)
        pxmp = QPixmap(250,100)
        pxmp.fill(QColor(255, 255, 255, 255))
        self.sample.setPixmap(pxmp)
        qpp = QPainterPath()
        qpp.moveTo(QPointF(20, 50))
        qpp.cubicTo(QPointF(80, 25), QPointF(145, 70), QPointF(230, 60))  # c1, c2, endPoint
        self.samplePoly = qpp.toFillPolygon(QTransform())
        # we want an unclosed polygon
        self.samplePoly.removeLast()

        # layout
        l = QVBoxLayout()
        l.setAlignment(Qt.AlignTop)
        hl = QHBoxLayout()
        hl.setAlignment(Qt.AlignHCenter)
        hl.addWidget(pushButton1)
        hl.addWidget(pushButton2)
        l.addLayout(hl)
        l.addWidget(QLabel('Brush Dynamics'))
        hl1 = QHBoxLayout()
        hl1.addWidget(QLabel('Spacing'))
        hl1.addWidget(spacingSlider)
        l.addLayout(hl1)
        hl2 = QHBoxLayout()
        hl2.addWidget(QLabel('Jitter'))
        hl2.addWidget(jitterSlider)
        l.addLayout(hl2)
        hl3 = QHBoxLayout()
        hl3.addWidget(QLabel('Orientation'))
        hl3.addWidget(self.orientationSlider)
        l.addLayout(hl3)
        l.addWidget(self.sample)
        self.setLayout(l)
        self.adjustSize()

        self.setDefaults()
        self.setWhatsThis(
                        """
                        <b>Drawing :</b><br>
                          Choose a brush family, flow, hardness and opacity.
                        """
                        )  # end of setWhatsThis