def _apply_prefs(self, prefs): for x in ('title', 'subtitle', 'footer'): attr = '%s_font_family' % x getattr(self, attr).font_family = prefs[attr] attr = '%s_font_size' % x getattr(self, attr).setValue(prefs[attr]) for x in ('title', 'subtitle', 'footer'): x += '_template' getattr(self, x).setText(prefs[x]) for x in ('width', 'height'): x = 'cover_' + x getattr(self, x).setValue(prefs[x]) color_themes = prefs['color_themes'].copy() color_themes.update(default_color_themes) disabled = set(prefs['disabled_color_themes']) self.colors_list.clear() self.colors_map = {} for name in sorted(color_themes, key=sort_key): self.colors_map[name] = li = QListWidgetItem( name, self.colors_list) li.setFlags(li.flags() | Qt.ItemFlag.ItemIsUserCheckable) li.setCheckState(Qt.CheckState.Unchecked if name in disabled else Qt.CheckState.Checked) li.setData(Qt.ItemDataRole.UserRole, color_themes[name]) lu = prefs.get('last_used_colors') if not self.for_global_prefs and lu in self.colors_map and self.colors_map[ lu].checkState() == Qt.CheckState.Checked: self.colors_map[lu].setSelected(True) else: for name, li in iteritems(self.colors_map): if li.checkState() == Qt.CheckState.Checked: li.setSelected(True) break else: next(itervalues(self.colors_map)).setSelected(True) disabled = set(prefs['disabled_styles']) self.styles_list.clear() self.style_map.clear() for name in sorted(all_styles(), key=sort_key): self.style_map[name] = li = QListWidgetItem(name, self.styles_list) li.setFlags(li.flags() | Qt.ItemFlag.ItemIsUserCheckable) li.setCheckState(Qt.CheckState.Unchecked if name in disabled else Qt.CheckState.Checked) lu = prefs.get('last_used_style') if not self.for_global_prefs and lu in self.style_map and self.style_map[ lu].checkState() == Qt.CheckState.Checked: self.style_map[lu].setSelected(True) else: for name, li in iteritems(self.style_map): if li.checkState() == Qt.CheckState.Checked: li.setSelected(True) break else: next(itervalues(self.style_map)).setSelected(True)
def _apply_prefs(self, prefs): for x in ('title', 'subtitle', 'footer'): attr = '%s_font_family' % x getattr(self, attr).font_family = prefs[attr] attr = '%s_font_size' % x getattr(self, attr).setValue(prefs[attr]) for x in ('title', 'subtitle', 'footer'): x += '_template' getattr(self, x).setText(prefs[x]) for x in ('width', 'height'): x = 'cover_' + x getattr(self, x).setValue(prefs[x]) color_themes = prefs['color_themes'].copy() color_themes.update(default_color_themes) disabled = set(prefs['disabled_color_themes']) self.colors_list.clear() self.colors_map = {} for name in sorted(color_themes, key=sort_key): self.colors_map[name] = li = QListWidgetItem( name, self.colors_list) li.setFlags(li.flags() | Qt.ItemIsUserCheckable) li.setCheckState(Qt.Unchecked if name in disabled else Qt.Checked) li.setData(Qt.UserRole, color_themes[name]) lu = prefs.get('last_used_colors') if not self.for_global_prefs and lu in self.colors_map and self.colors_map[ lu].checkState() == Qt.Checked: self.colors_map[lu].setSelected(True) else: for name, li in self.colors_map.iteritems(): if li.checkState() == Qt.Checked: li.setSelected(True) break else: next(self.colors_map.itervalues()).setSelected(True) disabled = set(prefs['disabled_styles']) self.styles_list.clear() self.style_map.clear() for name in sorted(all_styles(), key=sort_key): self.style_map[name] = li = QListWidgetItem(name, self.styles_list) li.setFlags(li.flags() | Qt.ItemIsUserCheckable) li.setCheckState(Qt.Unchecked if name in disabled else Qt.Checked) lu = prefs.get('last_used_style') if not self.for_global_prefs and lu in self.style_map and self.style_map[ lu].checkState() == Qt.Checked: self.style_map[lu].setSelected(True) else: for name, li in self.style_map.iteritems(): if li.checkState() == Qt.Checked: li.setSelected(True) break else: next(self.style_map.itervalues()).setSelected(True)