def __init__(self, log=None): super().__init__() if log: self.log = log.getChild('Conf') self.log.setLevel(30) else: self.log = logging.getLogger() self.log.setLevel(99) self.log.debug('Initializing') self.qsettings = QSettings() self.qsettings.setIniCodec('UTF-8') self.options = None self.option_spec = self.load_option_spec() self.options = self.load_options() self.full_name = "{} {}".format(QCoreApplication.applicationName(), QCoreApplication.applicationVersion()) # options that need fast access are also defined as attributes, which # are updated by calling update_attributes() # (on paper it's 4 times faster, but I don't think it matters in my case) self.logger_table_font = None self.logger_table_font_size = None self.logger_row_height = None self.benchmark_interval = None self.update_attributes()
def refresh_window_title(self): s = "%s %s" % (QCoreApplication.applicationName(), QCoreApplication.applicationVersion()) if self.filename is not None: s += " - " + self.filename if self.dirty: s += "*" self.setWindowTitle(s)
def save_running_version(self): version = QCoreApplication.applicationVersion() self.log.debug("Updating the config version to {}".format(version)) s = self.qsettings s.beginGroup('Configuration') s.setValue('cutelog_version', version) self.options['cutelog_version'] = version s.endGroup() self.sync()
def show_info(self): QMessageBox.about( self, QApplication.applicationName(), "%s %s\n" "Copyright (c) by %s" % ( QCoreApplication.applicationName(), QCoreApplication.applicationVersion(), QCoreApplication.organizationName(), ) )
def post_init(self): running_version = StrictVersion(QCoreApplication.applicationVersion()) config_version = self.options['cutelog_version'] if config_version == "" or config_version != running_version: self.save_running_version()