コード例 #1
0
ファイル: view.py プロジェクト: ZackBinHill/Sins
    def __init__(self, *args, **kwargs):
        super(GraphicsView, self).__init__(*args, **kwargs)

        self.fillColor = QtGui.QColor(38, 38, 38)
        self.lineColor = QtGui.QColor(55, 55, 55)

        self.xStep = 20
        self.yStep = 20

        self.current_zoom = 1.0

        self.panningMult = 2.0 * self.current_zoom
        self.panning = False
        self.zoomStep = 1.1

        # Since we implement custom panning, we don't need the scrollbars.
        self.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
        self.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
        # self.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn)
        # self.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn)

        self.setDragMode(QtWidgets.QGraphicsView.RubberBandDrag)
        self.setTransformationAnchor(QtWidgets.QGraphicsView.AnchorUnderMouse)
        self.setViewportUpdateMode(self.SmartViewportUpdate)
        # self.glWidget = QtOpenGL.QGLWidget(QtOpenGL.QGLFormat(QtOpenGL.QGL.SampleBuffers))
        # self.glWidget.updateGL()
        # self.setViewport(self.glWidget)

        self.colorTable = ColorTable(self)
コード例 #2
0
 def __init__(self, *args, **kwargs):
     super(OutputKnob, self).__init__(*args, **kwargs)
     self.name = kwargs.get("name", "output")
     self.displayName = kwargs.get("displayName", self.name)
     self.fillColor = kwargs.get("fillColor", QtGui.QColor(230, 130, 130))
     self.fillColor = kwargs.get("fillColor", QtGui.QColor(50, 100, 80))
     self.flow = kwargs.get("flow", FLOW_RIGHT_TO_LEFT)
コード例 #3
0
    def __init__(self, **kwargs):
        kwargs.pop("name")

        super(Knob, self).__init__(**kwargs)
        self.x = 0
        self.y = 0
        self.w = 10
        self.h = 10

        self.margin = 5
        self.flow = FLOW_LEFT_TO_RIGHT

        self.maxConnections = -1  # A negative value means 'unlimited'.

        self.name = "value"
        self.displayName = self.name

        self.labelColor = QtGui.QColor(10, 10, 10)
        self.fillColor = QtGui.QColor(230, 230, 0)
        self.highlightColor = QtGui.QColor(255, 255, 0)

        # Temp store for Edge currently being created.
        self.newEdge = None

        self.edges = []

        self.setAcceptHoverEvents(True)
コード例 #4
0
 def paintEvent(self, event):
     painter = QtGui.QPainter(self)
     painter.setPen(QtCore.Qt.NoPen)
     painter.setBrush(
         QtGui.QBrush(
             QtGui.QColor(self.text_color.red(), self.text_color.green(),
                          self.text_color.blue(), 20)))
     painter.drawRoundedRect(0, 0, self.width(), self.height(), 5, 5)
     super(_BaseNoteWidget, self).paintEvent(event)
コード例 #5
0
    def paintEvent(self, event):
        if self.pixmap() is not None:
            painter = QtGui.QPainter(self)
            painter.setRenderHints(QtGui.QPainter.Antialiasing, True)

            path = QtGui.QPainterPath()
            path.addEllipse(0, 0, self.width(), self.height())
            painter.setClipPath(path)

            painter.drawPixmap(0, 0, self.pixmap())
コード例 #6
0
ファイル: item_widget.py プロジェクト: ZackBinHill/Sins
 def paintEvent(self, qpaintevent):
     painter = QtGui.QPainter(self)
     font = painter.font()
     fm = QtGui.QFontMetrics(font)
     w = fm.boundingRect(self.text()).width() + 10
     h = fm.boundingRect(self.text()).height()
     painter.setFont(font)
     # painter.setPen(QtGui.QPen(QtGui.QColor(10, 10, 10)))
     painter.drawText(0, 0, w, h, 0, self.text())
     super(Label, self).paintEvent(qpaintevent)
コード例 #7
0
 def set_color(self, step):
     if self.basset_name == 'cc_bundle':
         self.normal_color = QtGui.QLinearGradient(
             QtCore.QPointF(0, 0), QtCore.QPointF(self.w, 0))
         color1 = SPECIAL_COLOR['cc_bundle'][0]
         color2 = SPECIAL_COLOR['cc_bundle'][1]
         self.normal_color.setColorAt(
             0, QtGui.QColor(color1[0], color1[1], color1[2]))
         self.normal_color.setColorAt(
             1, QtGui.QColor(color2[0], color2[1], color2[2]))
         self.fill_color = self.normal_color
     else:
         super(PlaVersionItem, self).set_color(step)
コード例 #8
0
ファイル: gui.py プロジェクト: threadshare/gggg
    def __init__(self):
        self.mode_model = QtCore.QStringListModel(["Shot", "Asset"])
        self.upload_type = QtCore.QStringListModel(
            ["Attachment", "Thumbnail", "Reference_qt"])
        self.show_model = QtGui.QStandardItemModel()
        self.path_model = QtWidgets.QDirModel()

        shows = get_approved_shows()
        for show_item in shows.items():
            if show_item[1] in frozenset(['production', 'production2']):
                item = QtGui.QStandardItem(show_item[0])
                item.setData(show_item[1], SG_DATA)
                self.show_model.appendRow(item)
        self.tree_model = QtWidgets.QFileSystemModel()
        self.tree_model.setRootPath("/")
        self.none_tree = QtWidgets.QFileSystemModel()
コード例 #9
0
 def paintEvent(self, event):
     super(AttachmentLabel, self).paintEvent(event)
     if self.text() != '':
         painter = QtGui.QPainter(self)
         painter.drawLine(QtCore.QPoint(0,
                                        self.height() - 1),
                          QtCore.QPoint(self.width(),
                                        self.height() - 1))
コード例 #10
0
    def __init__(self, name='', icon=None, *args, **kwargs):
        super(LabelButton, self).__init__(*args, **kwargs)

        self.setToolTip(name)
        self.setMouseTracking(True)
        self.setFixedSize(20, 20)
        if icon is not None:
            if isinstance(icon, (basestring, str)) and os.path.exists(icon):
                self.setPixmap(QtGui.QPixmap(icon))
            elif isinstance(icon, QtGui.QPixmap):
                self.setPixmap(icon)
        self.setAlignment(QtCore.Qt.AlignCenter)
コード例 #11
0
    def paint(self, painter, option, widget):
        """Draw the Knob's shape and label."""
        bbox = self.boundingRect()

        # Draw a filled rectangle.
        # painter.setPen(QtGui.QPen(QtCore.Qt.NoPen))
        pen = QtGui.QPen(QtGui.QColor(200, 200, 250))
        pen.setWidth(1)
        painter.setPen(pen)
        painter.setBrush(QtGui.QBrush(self.fillColor))
        # painter.drawRect(bbox)
        painter.drawEllipse(bbox)

        # Draw a text label next to it. Position depends on the flow.
        if self.flow == FLOW_LEFT_TO_RIGHT:
            x = bbox.right() + self.margin
        elif self.flow == FLOW_RIGHT_TO_LEFT:
            x = bbox.left() - self.margin
        else:
            raise Exception("Flow not recognized: {0}".format(self.flow))
        y = bbox.bottom()
        self.setZValue(10)
コード例 #12
0
ファイル: view.py プロジェクト: ZackBinHill/Sins
    def drawBackground(self, painter, rect):
        painter.setBrush(QtGui.QBrush(self.fillColor))
        painter.setPen(QtGui.QPen(self.lineColor))

        painter.drawRect(rect)
        lines = []
        scale = max(int(1 / self.current_zoom / 2), 1)
        line_w = 200 * scale
        line_h = 80 * scale

        point1 = self.mapToScene(QtCore.QPoint(0, 0))
        point2 = self.mapToScene(
            QtCore.QPoint(self.viewport().width(),
                          self.viewport().height()))

        # for i in range(int(point1.y() / line_h), int(self.scene().height() / line_h)):
        for i in range(int(point1.y() / line_h), int(point2.y() / line_h)):
            lines.append(
                QtCore.QLineF(
                    QtCore.QPoint(rect.x(), i * line_h),
                    QtCore.QPoint(rect.x() + rect.width(), i * line_h)))
        # for i in range(int(self.scene().sceneRect().x()), int(self.scene().width() / line_w)):
        for i in range(int(point1.x() / line_w), int(point2.x() / line_w)):
            lines.append(
                QtCore.QLineF(
                    QtCore.QPoint(i * line_w, rect.y()),
                    QtCore.QPoint(i * line_w,
                                  rect.y() + rect.height())))
        painter.drawLines(lines)

        painter.setPen(QtGui.QPen(QtGui.QColor(80, 80, 60, 50)))
        painter.drawLine(
            QtCore.QLineF(QtCore.QPoint(rect.x(), 0),
                          QtCore.QPoint(rect.x() + rect.width(), 0)))
        painter.drawLine(
            QtCore.QLineF(QtCore.QPoint(0, rect.y()),
                          QtCore.QPoint(0,
                                        rect.y() + rect.height())))
コード例 #13
0
ファイル: item_widget.py プロジェクト: ZackBinHill/Sins
 def event(self, event):
     if event.type() == QtCore.QEvent.ToolTip:
         if self.tooltip_text is None:
             self.tooltip_text = u'id: {id}\ndate: {date}\nby: {create_by}\nnotes: {notes}'.\
                 format(id=self.version.id,
                        date=self.version.date_published,
                        create_by=self.version.creator.username,
                        notes=self.version.notes
                        )
             # print self.tooltip_text
         QtWidgets.QToolTip.showText(QtGui.QCursor().pos(),
                                     self.tooltip_text)
         return True
     return super(VersionItemWidget, self).event(event)
コード例 #14
0
    def __init__(self, shape=None, text=None, color=None, **kwargs):
        super(Tag, self).__init__(**kwargs)

        self.shape = shape
        self.text = text
        self.color = color

        self.x = 0
        self.y = 0
        self.w = TAG_W
        self.h = TAG_H

        self.margin = 5

        self.name = "value"
        self.displayName = self.name
        self.auto_hide = True

        self.textColor = QtGui.QColor(10, 10, 10)
        self.fillColor = self.color if self.color is not None else QtGui.QColor(
            170, 170, 170)
        self.highlightColor = QtGui.QColor(255, 255, 0)

        self.setAcceptHoverEvents(True)
コード例 #15
0
 def set_icon(self, icon):
     if icon.endswith('.svg'):
         self.setPixmap(
             get_pixmap(icon).scaled(
                 USER_ICON_SIZE,
                 USER_ICON_SIZE,
                 QtCore.Qt.KeepAspectRatioByExpanding,
                 QtCore.Qt.SmoothTransformation,
             ))
     else:
         self.setPixmap(
             QtGui.QPixmap(icon).scaled(
                 USER_ICON_SIZE,
                 USER_ICON_SIZE,
                 QtCore.Qt.KeepAspectRatioByExpanding,
                 QtCore.Qt.SmoothTransformation,
             ))
コード例 #16
0
    def paint(self, painter, option, widget):
        bbox = self.boundingRect()
        if self.isSelected():
            self.set_highlight()
            pen = QtGui.QPen(self.border_color)
            pen.setWidth(2)
            painter.setPen(pen)

            painter.setBrush(QtGui.QBrush(self.fill_color))
            painter.drawRoundedRect(self.x, self.y, bbox.width(), self.h,
                                    self.roundness, self.roundness)
        else:
            painter.setPen(QtGui.QPen(QtCore.Qt.NoPen))

            painter.setBrush(QtGui.QBrush(self.base_color))
            # painter.setBrush(QtGui.QBrush(self.fill_color))
            # painter.drawRoundedRect(self.x,
            #                         self.y,
            #                         bbox.width(),
            #                         self.h,
            #                         self.roundness,
            #                         self.roundness)
            #
            # painter.setBrush(QtGui.QBrush(self.fill_color))
            # painter.drawRect(self.x,
            #                  self.y + self.roundness,
            #                  bbox.width(),
            #                  self.h - 50 - self.roundness)
            # painter.drawRoundedRect(self.x,
            #                         self.y,
            #                         bbox.width(),
            #                         self.h - 50,
            #                         self.roundness,
            #                         self.roundness)

            painter.setBrush(QtGui.QBrush(self.fill_color))
            painter.drawRoundedRect(self.x, self.y, bbox.width(), self.h,
                                    self.roundness, self.roundness)
            painter.setBrush(QtGui.QBrush(self.base_color))
            painter.drawRect(self.x, self.y + 30, bbox.width(),
                             self.h - 30 - self.roundness)
            painter.drawRoundedRect(self.x, self.y + 30, bbox.width(),
                                    self.h - 30, self.roundness,
                                    self.roundness)
コード例 #17
0
    def paint(self, painter, option, widget):
        """Draw the Tag's shape and label."""
        bbox = self.boundingRect()

        if self.shape is not None:
            painter.setPen(QtGui.QPen(QtCore.Qt.NoPen))
            painter.setBrush(QtGui.QBrush(self.fillColor))

            # Draw a filled rectangle.
            if self.shape == 1:
                roundness = 3
                painter.drawRoundedRect(bbox, roundness, roundness)

            # Ellipse
            if self.shape == 2:
                painter.drawEllipse(bbox)

            # Triangle0
            if self.shape == 3:
                points, rects = get_shapes_of_triangle(self.w,
                                                       roundness=2,
                                                       direction=0)
                painter.drawPolygon(QtGui.QPolygonF(points))
                for rect in rects:
                    painter.drawEllipse(rect)

            # Triangle2
            if self.shape == 4:
                points, rects = get_shapes_of_triangle(self.w,
                                                       roundness=2,
                                                       direction=2)
                painter.drawPolygon(QtGui.QPolygonF(points))
                for rect in rects:
                    painter.drawEllipse(rect)

        if self.text is not None:
            painter.setPen(QtGui.QPen(self.textColor))
            font = painter.font()
            fm = QtGui.QFontMetrics(font)
            w = fm.boundingRect(self.text).width() + 10
            h = fm.boundingRect(self.text).height()
            rect = QtCore.QRectF(0 - (w - bbox.width()) / 2.0,
                                 0 - (h - bbox.height()) / 2.0, w, h)
            painter.drawText(rect, QtCore.Qt.AlignCenter, self.text)
コード例 #18
0
    def __init__(self, file_path, content_type='', *args, **kwargs):
        super(AttachmentLabel, self).__init__(*args, **kwargs)

        self.file_path = file_path
        if content_type.startswith('image'):
            pixmap = QtGui.QPixmap(file_path)
            if pixmap.width() > 0:
                pixmap = pixmap.scaledToWidth(
                    min(pixmap.width(), ATTACHMENT_WIDTH),
                    QtCore.Qt.SmoothTransformation)
                self.setPixmap(pixmap)
            else:
                self.setText(os.path.basename(file_path))
        else:
            self.setText(os.path.basename(file_path))

        # self.setStyleSheet("""
        # QLabel{
        # text-decoration:underline;
        # }
        # """)

        # self.setMouseTracking(True)
        self.setToolTip('Click to view')
コード例 #19
0
    def __init__(self, version, entity, asset, *args, **kwargs):
        super(VersionItem, self).__init__(*args, **kwargs)

        self.x = 0
        self.y = 0
        self.w = 220
        self.h = 80

        self._parent = None
        self._children = []

        self.version = version
        self.entity = entity
        self.asset = asset
        self.id = version.id
        self.edges = []
        self.orientation = 0

        self.margin = 6
        self.roundness = 10
        self.base_color = QtGui.QColor(210, 210, 210)
        self.base_color = QtGui.QColor(50, 60, 70)
        self.normal_color = self.base_color
        self.highlight_color = QtGui.QColor(250, 250, 150)
        self.highlight_color = QtGui.QColor(230, 230, 100)
        self.fill_color = self.normal_color
        self.border_color = QtGui.QColor(150, 150, 210)
        self.border_color = QtGui.QColor(180, 180, 250)

        self.setFlag(QtWidgets.QGraphicsItem.ItemIsMovable, True)
        self.setFlag(QtWidgets.QGraphicsItem.ItemIsSelectable, True)

        self.dependent_versions = self.version.sources
        self.dependent_versions_count = self.dependent_versions.count()

        self.destination_versions = self.version.destinations
        self.destination_versions_count = self.destination_versions.count()

        self.connected_sources = dict()
        self.connected_destinations = dict()

        self.children_populated = False
        self.parent_populated = False
コード例 #20
0
 def __init__(self, *args, **kwargs):
     super(InputKnob, self).__init__(*args, **kwargs)
     self.name = kwargs.get("name", "input")
     self.displayName = kwargs.get("displayName", self.name)
     self.fillColor = kwargs.get("fillColor", QtGui.QColor(130, 230, 130))
     self.fillColor = kwargs.get("fillColor", QtGui.QColor(40, 60, 100))
コード例 #21
0
ファイル: gui.py プロジェクト: threadshare/gggg
    def element_widget(self):
        show_label = QtWidgets.QLabel("Show")
        self.path_label = QtWidgets.QLabel("Reference Path")
        mode_label = QtWidgets.QLabel("Mode")
        upload_type = QtWidgets.QLabel("Type")

        self.tree_view = QtWidgets.QTreeView()
        self.tree_view.setModel(self.model.none_tree)
        self.tree_view.setSelectionMode(
            QtWidgets.QAbstractItemView.ExtendedSelection)
        self.tree_view.setSelectionBehavior(
            QtWidgets.QAbstractItemView.SelectItems)
        self.tree_view.setColumnWidth(0, 450)
        self.tree_view.setColumnWidth(1, 80)
        self.tree_view.setColumnWidth(2, 50)
        self.tree_view.setDragEnabled(True)
        self.tree_view.setAcceptDrops(True)
        rename_label = QtWidgets.QLabel("Selected File  ")
        rename_label.setFont(QtGui.QFont('Timer', 13))
        delete_action = QtWidgets.QAction('Delete row', self)
        delete_action.triggered.connect(self.delete_row)
        file_name_item = QtWidgets.QAction('Create alias name', self)
        file_name_item.triggered.connect(
            lambda: self.rename_dialog(type='alias_name'))
        alias_name_item = QtWidgets.QAction('Modify alias name', self)
        alias_name_item.triggered.connect(
            lambda: self.rename_dialog(type='modify_alias_name'))
        self.file_name_menu = QtWidgets.QMenu('Create alias name', self)
        self.file_name_menu.addAction(delete_action)
        self.file_name_menu.addAction(file_name_item)
        self.alias_name_menu = QtWidgets.QMenu('Modify alias name', self)
        self.alias_name_menu.addAction(delete_action)
        self.alias_name_menu.addAction(alias_name_item)

        self.rename_table = CustomTablewidget()
        self.rename_table.customDataChanged.connect(self.rename_command)
        self.rename_table.customContextMenuRequested.connect(
            self.set_item_menu)

        self.uploader_button = QtWidgets.QPushButton("Upload")
        self.uploader_button.setFont(QtGui.QFont('Timer', 13))
        self.uploader_button.setMinimumHeight(40)
        self.uploader_button.setEnabled(False)
        self.uploader_button.clicked.connect(self.upload_button_command)
        self.copy_file_path_label = QtWidgets.QLabel("Copy reference to:")
        self.copy_file_path_edit = QtWidgets.QLineEdit()
        self.copy_file_path_edit.setText("")
        self.show_line_combox = QtWidgets.QComboBox()
        self.show_line_combox.setModel(self.model.show_model)
        self.show_line_combox.currentIndexChanged.connect(
            self.show_line_command)
        self.show_line_combox.setFixedWidth(90)
        self.mode_combo_box = QtWidgets.QComboBox()
        self.mode_combo_box.setModel(self.model.mode_model)
        self.mode_combo_box.currentIndexChanged.connect(
            self.mode_combo_box_command)
        self.path_edit = QtWidgets.QLineEdit()
        self.path_completer = QtWidgets.QCompleter()
        self.path_completer.setModel(self.model.path_model)
        self.path_edit.setCompleter(self.path_completer)
        self.path_edit.returnPressed.connect(self.path_completion)
        self.path_edit.setFixedWidth(300)
        self.path_edit.textChanged.connect(self.set_root_path)

        self.file_select = QtWidgets.QToolButton()
        self.file_select.setIcon(QtGui.QIcon(FILE_ICON))
        self.file_select.setToolButtonStyle(QtCore.Qt.ToolButtonIconOnly)
        self.file_select.clicked.connect(self.open_file_path)
        self.upload_type = QtWidgets.QComboBox()
        self.upload_type.setFixedWidth(95)
        self.upload_type.setModel(self.model.upload_type)
        self.upload_type.currentIndexChanged.connect(self.upload_type_command)

        show_mode_hbox = QtWidgets.QHBoxLayout()
        show_hbox = QtWidgets.QHBoxLayout()
        show_hbox.addWidget(show_label)
        show_hbox.addWidget(self.show_line_combox)
        show_hbox.addStretch(1)
        mode_hbox = QtWidgets.QHBoxLayout()
        mode_hbox.addWidget(mode_label)
        mode_hbox.addWidget(self.mode_combo_box)
        mode_hbox.addStretch(1)
        type_hbox = QtWidgets.QHBoxLayout()
        type_hbox.addWidget(upload_type)
        type_hbox.addWidget(self.upload_type)
        type_hbox.addStretch(1)
        show_mode_hbox.addLayout(show_hbox)
        show_mode_hbox.addLayout(mode_hbox)
        show_mode_hbox.addLayout(type_hbox)

        path_file_select_hbox = QtWidgets.QHBoxLayout()
        path_file_select_hbox.addWidget(self.path_label)
        path_file_select_hbox.addWidget(self.path_edit)
        path_file_select_hbox.addWidget(self.file_select)
        show_mode_hbox.addLayout(path_file_select_hbox)

        copy_path_hbox = QtWidgets.QHBoxLayout()
        copy_path_hbox.addWidget(self.copy_file_path_label)
        copy_path_hbox.addWidget(self.copy_file_path_edit)

        vbox = QtWidgets.QVBoxLayout()
        vbox.addLayout(show_mode_hbox)
        vbox.addSpacing(10)
        vbox.addLayout(copy_path_hbox)
        vbox.addSpacing(10)
        vbox.addWidget(self.tree_view)
        vbox.addWidget(rename_label, 0, QtCore.Qt.AlignCenter)
        vbox.addWidget(self.rename_table)
        self.attachment_widget = QtWidgets.QWidget()
        attachment_vbox = QtWidgets.QVBoxLayout()
        self.attachment_widget.setLayout(attachment_vbox)
        self.attachment_widget.setVisible(True)
        vbox.addWidget(self.attachment_widget)
        vbox.addWidget(self.uploader_button)
        self.setLayout(vbox)

        self.show_line_combox.currentIndexChanged.emit(0)
コード例 #22
0
 def set_color(self, step):
     color = get_pipeline_color(step)
     self.normal_color = QtGui.QColor(color[0], color[1], color[2], 200)
     self.fill_color = self.normal_color
コード例 #23
0
ファイル: pyside_test.py プロジェクト: ZackBinHill/Sins
 def contextMenuEvent(self, event):
     super(VersionList, self).contextMenuEvent(event)
     self.menu.move(QtGui.QCursor().pos())
     self.menu.show()