def __init__(self, parent, delegate):
        QWidget.__init__(self, parent)
        self.delegate = delegate
        self.emitted = False
        self.ui = Ui_AskVerdict()
        self.ui.setupUi(self)
        # build verdict icons
        if not AskVerdict.icons_cache:
            for text in VERDICTS:
                color = VERDICT_TO_ROW_COLORS.get(text[0])
                pixmap = QPixmap(16, 16)
                pixmap.fill(Qt.transparent)
                if color:
                    painter = QPainter(pixmap)
                    painter.setPen(Qt.black)
                    painter.setBrush(color)
                    painter.drawEllipse(0, 0, 15, 15)
                    painter.end()
                AskVerdict.icons_cache[text] = QIcon(pixmap)

        # set combo verdict
        for text in ('other...', 'skip', 'retry'):
            self.ui.comboVerdict.addItem(AskVerdict.icons_cache[text], text)
        model = self.ui.comboVerdict.model()
        model.itemFromIndex(model.index(0, 0)).setSelectable(False)

        self.ui.comboVerdict.activated.connect(self.on_dropdown_item_activated)

        self.ui.goodVerdict.clicked.connect(self.on_good_bad_button_clicked)
        self.ui.goodVerdict.setIcon(AskVerdict.icons_cache["good"])

        self.ui.badVerdict.clicked.connect(self.on_good_bad_button_clicked)
        self.ui.badVerdict.setIcon(AskVerdict.icons_cache["bad"])
コード例 #2
0
    def __init__(self, parent, delegate):
        QWidget.__init__(self, parent)
        self.delegate = delegate
        self.emitted = False
        self.ui = Ui_AskVerdict()
        self.ui.setupUi(self)
        # build verdict icons
        if not AskVerdict.icons_cache:
            for i in range(self.ui.comboVerdict.count()):
                text = str(self.ui.comboVerdict.itemText(i))
                color = VERDICT_TO_ROW_COLORS.get(text[0])
                pixmap = QPixmap(16, 16)
                pixmap.fill(Qt.transparent)
                if color:
                    painter = QPainter(pixmap)
                    painter.setPen(Qt.black)
                    painter.setBrush(color)
                    painter.drawEllipse(0, 0, 15, 15)
                    painter.end()
                AskVerdict.icons_cache[text] = QIcon(pixmap)
        # set verdict icons
        for i in range(self.ui.comboVerdict.count()):
            text = str(self.ui.comboVerdict.itemText(i))
            self.ui.comboVerdict.setItemIcon(i, AskVerdict.icons_cache[text])

        self.ui.evaluate.clicked.connect(self.on_evaluate_clicked)
コード例 #3
0
class AskVerdict(QWidget):
    icons_cache = {}

    def __init__(self, parent, delegate):
        QWidget.__init__(self, parent)
        self.delegate = delegate
        self.emitted = False
        self.ui = Ui_AskVerdict()
        self.ui.setupUi(self)
        # build verdict icons
        if not AskVerdict.icons_cache:
            for text in VERDICTS:
                color = VERDICT_TO_ROW_COLORS.get(text[0])
                pixmap = QPixmap(16, 16)
                pixmap.fill(Qt.transparent)
                if color:
                    painter = QPainter(pixmap)
                    painter.setPen(Qt.black)
                    painter.setBrush(color)
                    painter.drawEllipse(0, 0, 15, 15)
                    painter.end()
                AskVerdict.icons_cache[text] = QIcon(pixmap)

        # set combo verdict
        for text in ('other...', 'skip', 'retry'):
            self.ui.comboVerdict.addItem(AskVerdict.icons_cache[text], text)
        model = self.ui.comboVerdict.model()
        model.itemFromIndex(model.index(0, 0)).setSelectable(False)

        self.ui.comboVerdict.activated.connect(self.on_dropdown_item_activated)

        self.ui.goodVerdict.clicked.connect(self.on_good_bad_button_clicked)
        self.ui.goodVerdict.setIcon(AskVerdict.icons_cache["good"])

        self.ui.badVerdict.clicked.connect(self.on_good_bad_button_clicked)
        self.ui.badVerdict.setIcon(AskVerdict.icons_cache["bad"])

    def on_dropdown_item_activated(self):
        self.delegate.got_verdict.emit(
            str(self.ui.comboVerdict.currentText())[0]
        )
        self.emitted = True

    def on_good_bad_button_clicked(self):
        self.delegate.got_verdict.emit(
            str(self.sender().text())[0]
        )
        self.emitted = True
コード例 #4
0
    def __init__(self, parent, delegate):
        QWidget.__init__(self, parent)
        self.delegate = delegate
        self.emitted = False
        self.ui = Ui_AskVerdict()
        self.ui.setupUi(self)
        # build verdict icons
        if not AskVerdict.icons_cache:
            for i in range(self.ui.comboVerdict.count()):
                text = str(self.ui.comboVerdict.itemText(i))
                color = VERDICT_TO_ROW_COLORS.get(text[0])
                pixmap = QPixmap(16, 16)
                pixmap.fill(Qt.transparent)
                if color:
                    painter = QPainter(pixmap)
                    painter.setPen(Qt.black)
                    painter.setBrush(color)
                    painter.drawEllipse(0, 0, 15, 15)
                    painter.end()
                AskVerdict.icons_cache[text] = QIcon(pixmap)
        # set verdict icons
        for i in range(self.ui.comboVerdict.count()):
            text = str(self.ui.comboVerdict.itemText(i))
            self.ui.comboVerdict.setItemIcon(i, AskVerdict.icons_cache[text])

        self.ui.evaluate.clicked.connect(self.on_evaluate_clicked)
コード例 #5
0
class AskVerdict(QWidget):
    icons_cache = {}

    def __init__(self, parent, delegate):
        QWidget.__init__(self, parent)
        self.delegate = delegate
        self.emitted = False
        self.ui = Ui_AskVerdict()
        self.ui.setupUi(self)
        # build verdict icons
        if not AskVerdict.icons_cache:
            for i in range(self.ui.comboVerdict.count()):
                text = str(self.ui.comboVerdict.itemText(i))
                color = VERDICT_TO_ROW_COLORS.get(text[0])
                pixmap = QPixmap(16, 16)
                pixmap.fill(Qt.transparent)
                if color:
                    painter = QPainter(pixmap)
                    painter.setPen(Qt.black)
                    painter.setBrush(color)
                    painter.drawEllipse(0, 0, 15, 15)
                    painter.end()
                AskVerdict.icons_cache[text] = QIcon(pixmap)
        # set verdict icons
        for i in range(self.ui.comboVerdict.count()):
            text = str(self.ui.comboVerdict.itemText(i))
            self.ui.comboVerdict.setItemIcon(i, AskVerdict.icons_cache[text])

        self.ui.evaluate.clicked.connect(self.on_evaluate_clicked)

    def on_evaluate_clicked(self):
        if not self.emitted:
            # not sure why, but this signal is emitted three times
            # (though the connection is made once, and I click one time)
            # self.emitted is a workaround.
            self.delegate.got_verdict.emit(
                str(self.ui.comboVerdict.currentText())[0]
            )
            self.emitted = True
コード例 #6
0
class AskVerdict(QWidget):
    icons_cache = {}

    def __init__(self, parent, delegate):
        QWidget.__init__(self, parent)
        self.delegate = delegate
        self.emitted = False
        self.ui = Ui_AskVerdict()
        self.ui.setupUi(self)
        # build verdict icons
        if not AskVerdict.icons_cache:
            for i in range(self.ui.comboVerdict.count()):
                text = str(self.ui.comboVerdict.itemText(i))
                color = VERDICT_TO_ROW_COLORS.get(text[0])
                pixmap = QPixmap(16, 16)
                pixmap.fill(Qt.transparent)
                if color:
                    painter = QPainter(pixmap)
                    painter.setPen(Qt.black)
                    painter.setBrush(color)
                    painter.drawEllipse(0, 0, 15, 15)
                    painter.end()
                AskVerdict.icons_cache[text] = QIcon(pixmap)
        # set verdict icons
        for i in range(self.ui.comboVerdict.count()):
            text = str(self.ui.comboVerdict.itemText(i))
            self.ui.comboVerdict.setItemIcon(i, AskVerdict.icons_cache[text])

        self.ui.evaluate.clicked.connect(self.on_evaluate_clicked)

    def on_evaluate_clicked(self):
        if not self.emitted:
            # not sure why, but this signal is emitted three times
            # (though the connection is made once, and I click one time)
            # self.emitted is a workaround.
            self.delegate.got_verdict.emit(
                str(self.ui.comboVerdict.currentText())[0])
            self.emitted = True