def update_locations(self): self.locations_table.setUpdatesEnabled(False) self.locations_table.setRowCount(0) for i in range(2): if i == 0: if self.scope() == QSettings.SystemScope: continue actualScope = QSettings.UserScope else: actualScope = QSettings.SystemScope for j in range(2): if j == 0: if not self.application(): continue actualApplication = self.application() else: actualApplication = '' settings = QSettings(self.format(), actualScope, self.organization(), actualApplication) row = self.locations_table.rowCount() self.locations_table.setRowCount(row + 1) item0 = QTableWidgetItem() item0.setText(settings.fileName()) item1 = QTableWidgetItem() disable = not (settings.childKeys() or settings.childGroups()) if row == 0: if settings.isWritable(): item1.setText("Read-write") disable = False else: item1.setText("Read-only") self.button_box.button(QDialogButtonBox.Ok).setDisabled(disable) else: item1.setText("Read-only fallback") if disable: item0.setFlags(item0.flags() & ~Qt.ItemIsEnabled) item1.setFlags(item1.flags() & ~Qt.ItemIsEnabled) self.locations_table.setItem(row, 0, item0) self.locations_table.setItem(row, 1, item1) self.locations_table.setUpdatesEnabled(True)
def list_app(self, root: str) -> Iterator[Tuple[str, Union[AppManifest, None]]]: settings = QSettings() settings.beginGroup(f"apps/_folder/" + root) for key in settings.childGroups(): yield key, None for key in settings.childKeys(): try: int(key) except ValueError: continue appid = settings.value(key) yield appid, self[appid]
def load(self): settings = QSettings() settings.beginGroup('profiles') groups = settings.childGroups() self.profiles = [ Profile(p, settings.value(f'{p}/path'), settings.value(f'{p}/mask'), settings.value(f'{p}/pattern')) for p in groups ] settings.endGroup() self.actGroup = QActionGroup(self.parent) self.actGroup.triggered.connect(self.set_active_profile) active = settings.value('active_profile') self.active_profile = self.get_profile(active) if len(self.profiles) > 0: for name in self.names(): action = self.do_add_action(name) if name == active: action.setChecked(True)