Esempio n. 1
0
    def _handle_enabled_toggle(self, value, force=False):
        icon = QtGui.QIcon(":/icons/off.png") if not value else QtGui.QIcon(":/icons/on.png")
        self._enabled_button.setIcon(icon)
        self._enabled = value

        if force and value:
            self._enabled_button.setChecked(True)
Esempio n. 2
0
    def _handle_relative_toggle(self, value, force=False):
        icon =  QtGui.QIcon(":/icons/light/references.svg") if not value else QtGui.QIcon(":/icons/references_pushed.png")
        self._relative_button.setIcon(icon)
        self._relative = value

        if force and value:
            self._relative_button.setChecked(True)
Esempio n. 3
0
    def start(self):
        """Main method of this class
        It will create a BackgroundProcess that will be interacting with Deadline.
        The Background process is a Daemon Thread. It will be triggered every 30 secs.
        It will get any new job that is Active (Rendering, Queried) or Pending

        Once this BackgroundProcess timedout, it will automatically pass all the results
        through the method ``_results_emitted``
        """
        if not self._started:
            if not self._background_process:
                only_new_jobs = self.actionWrangler_only_jobs_from_now_on.isChecked()
                self._background_process = BackgroundProcess(only_new_jobs=only_new_jobs, parent=self)
                self._background_process.finished.connect(self._thread_finished)
                self._background_process.emit_results.connect(self._results_emitted)

                self._timer = QtCore.QTimer(self)
                self._timer.setInterval(30000)
                # self._timer.setSingleShot(True)
                self._timer.timeout.connect(self._background_process.start)
            
            self._timer.start()        
            self._started = True
            self.actionStart.setText("Pause")
            self.actionStart.setIcon(QtGui.QIcon(":/icons/light/pause.svg"))
            logger.info("Starting")
        else:
            self._timer.stop()
            self._background_process.terminate()
            self._background_process.wait()
            self.actionStart.setText("Start")
            self.actionStart.setIcon(QtGui.QIcon(":/icons/light/play.svg"))
            self._started = False        
            logger.info("Pausing")
        self.rules_tabs_widget.setDisabled(self._started)            
Esempio n. 4
0
    def _add_tag(self, tag_name=None, tag_color=None):
        if not tag_name or not tag_color:
            dialog = CreateTagDialog(self)
            dialog.exec_()
            result = dialog.result()
            if result:
                tag_color = dialog._color
                tag_name = dialog._name
            else:
                return

        item = QtWidgets.QListWidgetItem()
        item.setText(tag_name)
        item.setData(QtCore.Qt.BackgroundRole, QtGui.QBrush(QtGui.QColor(tag_color)))
        self.tags_lw.addItem(item)
Esempio n. 5
0
    def _draw_background(self, painter, option, index):
        rect = deepcopy(option.rect)
        path = QtGui.QPainterPath()
        path.addRoundedRect(rect, 3, 3)
        if option.state & QtWidgets.QStyle.State_Selected:
            background_color = QtGui.QBrush(
                option.palette.color(QtGui.QPalette.Highlight))
        else:
            background_color = index.data(QtCore.Qt.BackgroundRole)

        r, g, b, a = background_color.color().getRgb()
        color_luminance = TagDelegate.color_luminance(r, g, b)
        brightness = 50
        if color_luminance > 150:
            brightness = -50
        pen = QtGui.QPen(
            QtGui.QColor(*TagDelegate.color_variant(
                background_color.color().name(), brightness)))
        painter.setPen(pen)
        painter.fillPath(path, background_color)
        painter.drawPath(path)
Esempio n. 6
0
 def _setup_info_button(self):
     self._info = QtWidgets.QPushButton()
     self._info.setMinimumSize(QtCore.QSize(20, 20))
     self._info.setMaximumSize(QtCore.QSize(20, 20))
     # self._info.setCheckable(True)
     self._info.setIconSize(QtCore.QSize(20, 20))
     self._info.setStyleSheet(CHECK_TOOLBUTTON_STYLESHEET)
     self._info.setIcon(QtGui.QIcon(":/icons/light/info.svg"))
     self._info.setFocusPolicy(QtCore.Qt.NoFocus)
     self._info.setCursor(QtCore.Qt.PointingHandCursor)       
     self._info.clicked.connect(self.show_description)
     # self._info.setAutoRaise(True)
     return self._info
Esempio n. 7
0
 def _setup_relative_button(self):
     self._relative_button = QtWidgets.QPushButton()
     self._relative_button.setMinimumSize(QtCore.QSize(20, 20))
     self._relative_button.setMaximumSize(QtCore.QSize(20, 20))
     self._relative_button.setCheckable(True)
     self._relative_button.setIconSize(QtCore.QSize(20, 20))
     self._relative_button.setIcon(QtGui.QIcon(":/icons/light/references.svg"))
     # self._relative_button.setAutoRaise(True)
     self._relative_button.setStyleSheet(CHECK_TOOLBUTTON_STYLESHEET)
     self._relative_button.toggled.connect(self._handle_relative_toggle)
     self._relative_button.setFocusPolicy(QtCore.Qt.NoFocus)
     self._relative_button.setCursor(QtCore.Qt.PointingHandCursor)        
     return self._relative_button
Esempio n. 8
0
 def _setup_enable_button(self):
     self._enabled_button = QtWidgets.QPushButton()
     self._enabled_button.setMinimumSize(QtCore.QSize(35, 25))
     self._enabled_button.setMaximumSize(QtCore.QSize(35, 25))
     self._enabled_button.setCheckable(True)
     self._enabled_button.setIconSize(QtCore.QSize(34, 25))
     self._enabled_button.setIcon(QtGui.QIcon(":/icons/off.png"))
     # self._enabled_button.setAutoRaise(True)       
     self._enabled_button.setStyleSheet(CHECK_TOOLBUTTON_STYLESHEET)
     self._enabled_button.toggled.connect(self._handle_enabled_toggle)
     self._enabled_button.setFocusPolicy(QtCore.Qt.NoFocus)
     self._enabled_button.setCursor(QtCore.Qt.PointingHandCursor)
     return self._enabled_button
Esempio n. 9
0
        painter.drawPath(path)

    def _draw_text(self, painter, option, index):
        rect = deepcopy(option.rect)
        name = index.data(QtCore.Qt.DisplayRole)
        # pen = QtGui.QPen(QtCore.Qt.black)
        # painter.setPen(pen)
        painter.drawText(rect, QtCore.Qt.AlignHCenter | QtCore.Qt.AlignVCenter,
                         name)

    def sizeHint(self, option, index):
        name = index.data(QtCore.Qt.DisplayRole)
        return QtCore.QSize(option.fontMetrics.width(name) + 8, 21)


if __name__ == "__main__":
    import sys
    app = QtWidgets.QApplication(sys.argv)
    listwidget = QtWidgets.QListWidget()
    listwidget.setFlow(QtWidgets.QListView.LeftToRight)
    listwidget.setSpacing(3)
    listwidget.setItemDelegate(TagDelegate())
    for x in xrange(5):
        item = QtWidgets.QListWidgetItem()
        item.setText("Item number {}".format(x))
        item.setData(QtCore.Qt.BackgroundRole,
                     QtGui.QBrush(QtGui.QColor("#444444")))
        listwidget.addItem(item)
    listwidget.show()
    app.exec_()