Ejemplo n.º 1
0
    def paintEvent(self, event):
        mouse_pos = self.mapFromGlobal(QtGui.QCursor.pos())
        click_pos = None
        if self.click_position is not None:
            click_pos = self.mapFromGlobal(self.click_position)

        qp = QtGui.QPainter(self)
        # initialize the crosshairs
        qp.setBrush(QtGui.QColor(0, 0, 0, 1))
        qp.setPen(QtCore.Qt.NoPen)
        qp.drawRect(event.rect())

        # Clear the capture area

        if click_pos is not None:
            self.rectangle = QtCore.QRect(click_pos, mouse_pos)
            qp.setCompositionMode(QtGui.QPainter.CompositionMode_Clear)
            qp.drawRect(self.rectangle)
            qp.setCompositionMode(QtGui.QPainter.CompositionMode_SourceOver)

        pen = QtGui.QPen(QtGui.QColor('white'), 3, QtCore.Qt.SolidLine)
        qp.setPen(pen)
        # Draw cropping markers at click position
        if click_pos is not None:
            # left line
            qp.drawLine(mouse_pos.x(), click_pos.y(), mouse_pos.x(), mouse_pos.y())
            # top line
            qp.drawLine(click_pos.x(), click_pos.y(), mouse_pos.x(), click_pos.y())
            # right line
            qp.drawLine(click_pos.x(), click_pos.y(), click_pos.x(), mouse_pos.y())
            # bottom line
            qp.drawLine(click_pos.x(), mouse_pos.y(), mouse_pos.x(), mouse_pos.y())
Ejemplo n.º 2
0
 def load_assets(self):
     red_palette = QtGui.QPalette()
     red_palette.setColor(self.foregroundRole(), QtGui.QColor(255, 0, 0))
     self.assets.data_table.clearSpans()
     items = glob.glob(self.path_object.path_root)
     data = []
     temp_ = []
     self.assets.add_button.clicked.connect(self.on_create_asset)
     d = None
     if items:
         self.assets.data_table.show()
         self.assets.search_box.show()
         self.assets.message.hide()
         self.assets.message.setText('')
         for each in items:
             obj_ = PathObject(str(each))
             d = obj_.data
             shot_name = '%s_%s' % (d['seq'], d['shot'])
             if shot_name not in temp_:
                 temp_.append(shot_name)
                 if d['scope'] == 'assets':
                     data.append([d['seq'], d['shot'], each, '', '', ''])
                 elif d['scope'] == 'shots':
                     data.append([d['seq'], shot_name, each, '', '', ''])
         if d['scope'] == 'assets':
             self.assets.setup(
                 ListItemModel(data, [
                     'Category', 'Name', 'Path', 'Due Date', 'Status',
                     'Task'
                 ]))
         elif d['scope'] == 'shots':
             self.assets.setup(
                 ListItemModel(
                     data,
                     ['Seq', 'Shot', 'Path', 'Due Date', 'Status', 'Task']))
         self.assets.data_table.hideColumn(0)
         self.assets.data_table.hideColumn(2)
         self.assets.data_table.hideColumn(3)
         self.assets.data_table.hideColumn(5)
     else:
         self.assets.data_table.hide()
         self.assets.message.setText(
             'No %s Found! \nClick + button to create %s' %
             (self.path_object.scope.title(), self.path_object.scope))
         self.assets.message.setPalette(red_palette)
         self.assets.message.show()