def save_option(self, state): if state == Qt.Checked: set_config(self.cfg_section, self.cfg_option, 'True') self.do_actions(self.checked_actions, self.checked_kwargs) else: set_config(self.cfg_section, self.cfg_option, 'False') self.do_actions(self.unchecked_actions, self.unchecked_kwargs)
def update_current_theme(self, theme_abs_path): """ Saves the current theme variant to config and self (using its absolute path) :param theme_abs_path: :return: """ self.current_theme = theme_abs_path set_config('Theme', 'last_theme', theme_abs_path)
def sort_playback_view_videos(self): """ Applies a sort-by rule to the PlaybackGridView videos list. update_sort is a tuple of priority sort categories, first element is highest, last is lowest. update_sort += operations requires at least two items on rhs. :return: """ sort_by_ascending_date = read_config('PlaySort', 'ascending_date') sort_by_channel = read_config('PlaySort', 'by_channel') self.logger.info( "Sorting PlaybackGridView Videos: date = {} | channel = {}".format( sort_by_ascending_date, sort_by_channel)) update_sort = (asc(Video.watch_prio), ) # Sort-by ascending date if sort_by_ascending_date: update_sort += (asc(Video.date_downloaded), asc(Video.date_published)) # Sort-by channel name (implied by default: then descending date) if sort_by_channel: update_sort += (desc(Video.channel_title), ) # Sort-by channel name then ascending date # FIXME: Implement handling both sorts toggled if sort_by_channel and sort_by_ascending_date: # update_sort += (asc(Video.channel_title),) self.logger.debug5("By-Channel|By-date update_sort: {}".format( str(update_sort))) for t in update_sort: self.logger.debug5(t.compile(dialect=postgresql.dialect())) # FIXME: workaround for not handling both: disable channel sort if both toggled, and run date sort set_config('PlaySort', 'by_channel', format(not read_config('PlaySort', 'by_channel'))) sort_by_channel = read_config('PlaySort', 'by_channel') update_sort += (asc(Video.date_downloaded), asc(Video.date_published)) # DEFAULT: Sort-by descending date else: update_sort += (desc(Video.date_downloaded), desc(Video.date_published)) self.logger.info( "Sorted PlaybackGridView Videos: date = {} | channel = {}".format( sort_by_ascending_date, sort_by_channel)) return update_sort
def open_font_dialog(self): """ Opens a QFontDialog and updates current font and config with the choice (if any). :return: """ font = QFont() font.fromString(read_config(self.cfg_section, self.cfg_option, literal_eval=False)) font, ok = QFontDialog.getFont() # If user selected a font. if ok: # Update current font ref. self.current_font = font # Save selected font to config. set_config(self.cfg_section, self.cfg_option, font.toString()) # Make button text reflect changes. self.update_info()
def update_current_style(self, style): self.current_style = style set_config('Theme', 'last_style', style)
def output_set_config(self, section, option, value): set_config(section, option, value)
def output_set_config(self, section, option, value): set_config(section, option, value, custom_ini="hotkeys")