def initialize(self): self.confirms_reset = False self.devices.blockSignals(True) self.devices.clear() for dev in self.gui.device_manager.devices: for d, name in iteritems(dev.get_user_blacklisted_devices()): item = QListWidgetItem('%s [%s]' % (name, d), self.devices) item.setData(Qt.ItemDataRole.UserRole, (dev, d)) item.setFlags(Qt.ItemFlag.ItemIsEnabled | Qt.ItemFlag.ItemIsUserCheckable | Qt.ItemFlag.ItemIsSelectable) item.setCheckState(Qt.CheckState.Checked) self.devices.blockSignals(False) self.device_plugins.blockSignals(True) for dev in self.gui.device_manager.disabled_device_plugins: n = dev.get_gui_name() item = QListWidgetItem(n, self.device_plugins) item.setData(Qt.ItemDataRole.UserRole, dev) item.setFlags(Qt.ItemFlag.ItemIsEnabled | Qt.ItemFlag.ItemIsUserCheckable | Qt.ItemFlag.ItemIsSelectable) item.setCheckState(Qt.CheckState.Checked) item.setIcon(QIcon(I('plugins.png'))) self.device_plugins.sortItems() self.device_plugins.blockSignals(False)
def setup_export_panel(self): self.export_panel = w = QWidget(self) self.stack.addWidget(w) w.l = l = QVBoxLayout(w) w.la = la = QLabel( _('Select which libraries you want to export below')) la.setWordWrap(True), l.addWidget(la) self.lib_list = ll = QListWidget(self) l.addWidget(ll) ll.setSelectionMode(QAbstractItemView.SelectionMode.ExtendedSelection) ll.setStyleSheet('QListView::item { padding: 5px }') ll.setAlternatingRowColors(True) lpaths = all_known_libraries() for lpath in sorted( lpaths, key=lambda x: numeric_sort_key(os.path.basename(x))): i = QListWidgetItem(self.export_lib_text(lpath), ll) i.setData(Qt.ItemDataRole.UserRole, lpath) i.setData(Qt.ItemDataRole.UserRole + 1, lpaths[lpath]) i.setIcon(QIcon(I('lt.png'))) i.setSelected(True) self.update_disk_usage.connect( (lambda i, sz: self.lib_list.item(i).setText( self.export_lib_text( self.lib_list.item(i).data(Qt.ItemDataRole.UserRole), sz)) ), type=Qt.ConnectionType.QueuedConnection)
def add_result(self, result): i = QListWidgetItem(' ', self) i.setData(Qt.UserRole, result) i.setIcon(self.blank_icon) if getattr(result, 'file_name'): i.setData(Qt.ToolTipRole, _('In internal file: {}').format(result.file_name)) return self.count()
def run_checks(self, container): with BusyCursor(): self.show_busy() QApplication.processEvents() errors = run_checks(container) self.hide_busy() for err in sorted(errors, key=lambda e:(100 - e.level, e.name)): i = QListWidgetItem('%s\xa0\xa0\xa0\xa0[%s]' % (err.msg, err.name), self.items) i.setData(Qt.UserRole, err) i.setIcon(icon_for_level(err.level)) if errors: self.items.setCurrentRow(0) self.current_item_changed() self.items.setFocus(Qt.OtherFocusReason) else: self.clear_help()
def setup_export_panel(self): self.export_panel = w = QWidget(self) self.stack.addWidget(w) w.l = l = QVBoxLayout(w) w.la = la = QLabel(_('Select which libraries you want to export below')) la.setWordWrap(True), l.addWidget(la) self.lib_list = ll = QListWidget(self) l.addWidget(ll) ll.setSelectionMode(ll.ExtendedSelection) ll.setStyleSheet('QListView::item { padding: 5px }') ll.setAlternatingRowColors(True) lpaths = all_known_libraries() for lpath in sorted(lpaths, key=lambda x:numeric_sort_key(os.path.basename(x))): i = QListWidgetItem(self.export_lib_text(lpath), ll) i.setData(Qt.UserRole, lpath) i.setData(Qt.UserRole+1, lpaths[lpath]) i.setIcon(QIcon(I('lt.png'))) i.setSelected(True) self.update_disk_usage.connect(( lambda i, sz: self.lib_list.item(i).setText(self.export_lib_text(self.lib_list.item(i).data(Qt.UserRole), sz))), type=Qt.QueuedConnection)
def initialize(self): self.devices.blockSignals(True) self.devices.clear() for dev in self.gui.device_manager.devices: for d, name in dev.get_user_blacklisted_devices().iteritems(): item = QListWidgetItem('%s [%s]'%(name, d), self.devices) item.setData(Qt.UserRole, (dev, d)) item.setFlags(Qt.ItemIsEnabled|Qt.ItemIsUserCheckable|Qt.ItemIsSelectable) item.setCheckState(Qt.Checked) self.devices.blockSignals(False) self.device_plugins.blockSignals(True) for dev in self.gui.device_manager.disabled_device_plugins: n = dev.get_gui_name() item = QListWidgetItem(n, self.device_plugins) item.setData(Qt.UserRole, dev) item.setFlags(Qt.ItemIsEnabled|Qt.ItemIsUserCheckable|Qt.ItemIsSelectable) item.setCheckState(Qt.Checked) item.setIcon(QIcon(I('plugins.png'))) self.device_plugins.sortItems() self.device_plugins.blockSignals(False)
def populate_list_item(self, fav_menu, idx= -1): self.blockSignals(True) if fav_menu is None: item = QListWidgetItem(self.SEP) item.setIcon(self.blank_icon) else: text = fav_menu['display'] item = QListWidgetItem(text) item.setFlags(Qt.ItemIsEditable | item.flags()) paths = fav_menu['path'] item.setToolTip(' -> '.join(paths)) item.setData(Qt.UserRole, (fav_menu,)) icon = fav_menu.get('icon', None) if icon is None: # This is a menu item that hasn't been found in this session # We will display it with a blank icon and disabled icon = self.blank_icon item.setForeground(QBrush(Qt.darkGray)) item.setIcon(icon) if idx < 0: self.addItem(item) else: self.insertItem(idx + 1, item) self.blockSignals(False)
def add_result(self, result): i = QListWidgetItem(' ', self) i.setData(Qt.UserRole, result) i.setIcon(self.blank_icon) return self.count()
def add_item(self, player_name): item = QListWidgetItem() item.setText(player_name) item.setIcon(self.get_icon('head.png')) self.addItem(item)