def types_as_string(self, translate=True, separator=', '): if self.types: types = self.types elif self.is_front_image(): types = [u'front'] else: types = [u'-'] if translate: types = [translate_caa_type(type) for type in types] return separator.join(types)
def _add_item(self, typ, enabled=False): item = QtGui.QListWidgetItem(self.widget) title = translate_caa_type(typ['name']) item.setText(title) tooltip = u"CAA: %(name)s" % typ item.setToolTip(tooltip) if enabled: state = QtCore.Qt.Checked else: state = QtCore.Qt.Unchecked item.setCheckState(state) self._items[item] = typ
def __init__(self, parent=None, types=[]): super(CAATypesSelectorDialog, self).__init__(parent) self.setWindowTitle(_("Cover art types")) self._items = {} self.layout = QtGui.QVBoxLayout(self) grid = QtGui.QWidget() gridlayout = QtGui.QGridLayout() grid.setLayout(gridlayout) rows = len(CAA_TYPES) // self._columns + 1 positions = [(i, j) for i in range(rows) for j in range(self._columns)] for position, caa_type in zip(positions, CAA_TYPES): name = caa_type["name"] text = translate_caa_type(name) item = QtGui.QCheckBox(text) item.setChecked(name in types) self._items[item] = caa_type gridlayout.addWidget(item, *position) self.layout.addWidget(grid) self.buttonbox = QtGui.QDialogButtonBox(self) self.buttonbox.setOrientation(QtCore.Qt.Horizontal) self.buttonbox.addButton( StandardButton(StandardButton.OK), QtGui.QDialogButtonBox.AcceptRole) self.buttonbox.addButton(StandardButton(StandardButton.CANCEL), QtGui.QDialogButtonBox.RejectRole) self.buttonbox.addButton( StandardButton(StandardButton.HELP), QtGui.QDialogButtonBox.HelpRole) self.buttonbox.accepted.connect(self.accept) self.buttonbox.rejected.connect(self.reject) self.buttonbox.helpRequested.connect(self.help) extrabuttons = [ (N_("Chec&k all"), self.checkall), (N_("&Uncheck all"), self.uncheckall), ] for label, callback in extrabuttons: button = QtGui.QPushButton(_(label)) button.setSizePolicy( QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Expanding) self.buttonbox.addButton(button, QtGui.QDialogButtonBox.ActionRole) button.clicked.connect(callback) self.layout.addWidget(self.buttonbox) self.buttonbox.accepted.connect(self.accept) self.buttonbox.rejected.connect(self.reject)