def conf_read(self): Configuration().read() if Configuration().parser.has_section(ConfigFile.PATH): try: recent_files = ast.literal_eval(Configuration().parser.get( ConfigFile.PATH, 'recent_files', fallback='[]')) if isinstance(recent_files, list): self.recent_files = recent_files except Exception as e: logging.error(str(e))
def _setup_ui(self): geometry = ConfigFile.GEOMETRY x = Configuration().parser.getint(geometry, 'x', fallback=480) y = Configuration().parser.getint(geometry, 'y', fallback=320) width = Configuration().parser.getint(geometry, 'width', fallback=880) height = Configuration().parser.getint(geometry, 'height', fallback=474) self.setMinimumSize(QtCore.QSize(480, 320)) self.setGeometry(x, y, 480, 320) self.setWindowIcon(QtGui.QIcon(config.ICON)) self.set_title() self.resize(width, height) self.setLayoutDirection(QtCore.Qt.LeftToRight) self.setDockNestingEnabled(False) self.setDockOptions(QtWidgets.QMainWindow.AllowTabbedDocks | QtWidgets.QMainWindow.AnimatedDocks | QtWidgets.QMainWindow.ForceTabbedDocks)
def show_window(self): try: self.conf_read() except Exception as e: logging.error(e) self._setup_ui() self._setup_menu() if Configuration().configuration.get('show_toolbar'): self._setup_toolbar() self._setup_tab() self._setup_statusbar() self.show() self.post_show()
def post_show(self): if self.file: self.open_file(self.file) elif Configuration().configuration.get('open_recent_file'): if len(self.recent_files): self.open_file(self.recent_files[0]) Teamwork().set_call(self.teamwork) SIReaderClient().set_call(self.add_sportident_result_from_sireader) SportiduinoClient().set_call(self.add_sportiduino_result_from_reader) SFRReaderClient().set_call(self.add_sfr_result_from_reader) ServiceListenerThread().interval.connect(self.interval) ServiceListenerThread().start()
def add_recent_file(self, file): self.delete_from_recent_files(file) self.recent_files.insert(0, file) Configuration().parser[ConfigFile.PATH] = { 'recent_files': self.recent_files }
def get_configuration(): return Configuration().configuration
def conf_write(self): Configuration().parser[ConfigFile.GEOMETRY] = self.get_size() Configuration().save()