From ca55d84f5d063e8216c196adc19c86618d61a467 Mon Sep 17 00:00:00 2001 From: Patryk Date: Tue, 2 Aug 2022 07:55:53 +0200 Subject: [PATCH 1/2] =?UTF-8?q?Wyeliminowanie=20b=C5=82=C4=99d=C3=B3w=20py?= =?UTF-8?q?thon=20przy=20braku=20pliku=20json?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- QuickPrint.py | 11 ++++++++--- giap_dynamic_layout.py | 16 +++++++++++----- giap_layout.py | 12 +++++++++--- 3 files changed, 28 insertions(+), 11 deletions(-) diff --git a/QuickPrint.py b/QuickPrint.py index f3ae0fe..cbfa0a6 100644 --- a/QuickPrint.py +++ b/QuickPrint.py @@ -93,10 +93,15 @@ def __init__(self, iface : QgisInterface, parent : QtWidgets=None) -> None: self.dialog.paperFormatComboBox.currentIndexChanged.connect( self.create_composer) self.setup_rubberband() - if Config().setts['font_changed']: - self.set_font_quickprint(QSettings().value("qgis/stylesheet/fontPointSize")) + self.conf = Config() + try: + if self.conf.setts['font_changed']: + self.set_font_quickprint(QSettings().value("qgis/stylesheet/fontPointSize")) + except KeyError: + self.conf.set_value('font_changed', False) + self.conf.save_config() - def set_font_quickprint(self, font_size): + def set_font_quickprint(self, font_size: str) -> None: attributes = [self.dialog.label_side, self.dialog.title_label, self.dialog.cancelPushButton, self.dialog.previewPushButton, self.dialog.savePushButton, self.dialog.calendar] diff --git a/giap_dynamic_layout.py b/giap_dynamic_layout.py index a8fb01d..f28f4d7 100644 --- a/giap_dynamic_layout.py +++ b/giap_dynamic_layout.py @@ -151,7 +151,7 @@ def edit_session_toggle(self, ask: bool=False) -> None: self.edit_session = not self.edit_session if not hasattr(self, 'conf'): self.conf = Config() - if ask and self.conf.setts[ + if 'ribbons_config' in self.conf.setts and ask and self.conf.setts[ 'ribbons_config'] != self.generate_ribbon_config(): self.save = CustomMessageBox(None, tr( "Do you want to save your changes?")).button_yes_no() @@ -206,8 +206,11 @@ def _section_control(self, tabind: int) -> None: scrll = QScrollArea(self) scrll.setWidgetResizable(True) scrll.setWidget(self.instr) - value = QSettings().value("qgis/stylesheet/fontPointSize") if \ - self.conf.setts["font_changed"] else 9 + try: + value = QSettings().value("qgis/stylesheet/fontPointSize") if \ + self.conf.setts["font_changed"] else 9 + except KeyError: + value = 9 self.instr.setStyleSheet( f"""QFrame, QLabel, QToolTip, QTextEdit{{ font:{value}pt}}""" @@ -1158,8 +1161,11 @@ def __init__(self, lab: str, parent: QtWidgets=None) -> None: self.setAttribute(Qt.WA_DeleteOnClose) self.setText(lab) self.conf = Config() - value = QSettings().value("qgis/stylesheet/fontPointSize") if \ - self.conf.setts["font_changed"] else 10 + try: + value = QSettings().value("qgis/stylesheet/fontPointSize") if \ + self.conf.setts["font_changed"] else 10 + except KeyError: + value = 10 self.setStyleSheet( f'font:{value}pt "Segoe UI"; font-weight: normal; ' ) diff --git a/giap_layout.py b/giap_layout.py index befa2ed..8efc599 100644 --- a/giap_layout.py +++ b/giap_layout.py @@ -68,10 +68,16 @@ def __init__(self, iface: iface) -> None: self.style_manager_dlg = StyleManagerDialog(self.style_manager) self.font_size = QSettings().value("qgis/stylesheet/fontPointSize") self.kompozycje = CompositionsTool(self.iface, self) + if "font_changed" not in self.config.setts: + self.config.set_value('font_changed', False) + self.config.save_config() if self.config.setts['font_changed']: - CustomLabel(tr('New section')).setStyleSheet(f'font: {self.font_size}pt;') - self.kompozycje_widget.setStyleSheet(f'font: {self.font_size}pt;') - self.main_widget.pokaz_warstwy.setStyleSheet(f'font: {self.font_size}pt;') + CustomLabel(tr('New section')).setStyleSheet( + f'font: {self.font_size}pt;') + self.kompozycje_widget.setStyleSheet( + f'font: {self.font_size}pt;') + self.main_widget.pokaz_warstwy.setStyleSheet( + f'font: {self.font_size}pt;') self.setfont_settings_dialog() self.setfont_styles_dialog() From efe5d37cf769a734dbe14130b032a1a50dd53e2f Mon Sep 17 00:00:00 2001 From: Patryk Date: Tue, 2 Aug 2022 08:27:23 +0200 Subject: [PATCH 2/2] =?UTF-8?q?Wyeliminowanie=20b=C5=82=C4=99d=C3=B3w=20py?= =?UTF-8?q?thon=20przy=20braku=20pliku=20json?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- QuickPrint.py | 4 ++-- giap_dynamic_layout.py | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/QuickPrint.py b/QuickPrint.py index cbfa0a6..3634fed 100644 --- a/QuickPrint.py +++ b/QuickPrint.py @@ -94,10 +94,10 @@ def __init__(self, iface : QgisInterface, parent : QtWidgets=None) -> None: self.create_composer) self.setup_rubberband() self.conf = Config() - try: + if 'font_changed' in self.conf.setts.keys(): if self.conf.setts['font_changed']: self.set_font_quickprint(QSettings().value("qgis/stylesheet/fontPointSize")) - except KeyError: + else: self.conf.set_value('font_changed', False) self.conf.save_config() diff --git a/giap_dynamic_layout.py b/giap_dynamic_layout.py index f28f4d7..7ea2920 100644 --- a/giap_dynamic_layout.py +++ b/giap_dynamic_layout.py @@ -206,10 +206,10 @@ def _section_control(self, tabind: int) -> None: scrll = QScrollArea(self) scrll.setWidgetResizable(True) scrll.setWidget(self.instr) - try: + if 'font_changed' in self.conf.setts.keys(): value = QSettings().value("qgis/stylesheet/fontPointSize") if \ self.conf.setts["font_changed"] else 9 - except KeyError: + else: value = 9 self.instr.setStyleSheet( f"""QFrame, QLabel, QToolTip, QTextEdit{{ @@ -1161,10 +1161,10 @@ def __init__(self, lab: str, parent: QtWidgets=None) -> None: self.setAttribute(Qt.WA_DeleteOnClose) self.setText(lab) self.conf = Config() - try: + if 'font_changed' in self.conf.setts.keys(): value = QSettings().value("qgis/stylesheet/fontPointSize") if \ self.conf.setts["font_changed"] else 10 - except KeyError: + else: value = 10 self.setStyleSheet( f'font:{value}pt "Segoe UI"; font-weight: normal; '