Loading ui/configpanel.py +12 −3 Original line number Diff line number Diff line Loading @@ -350,6 +350,7 @@ class ConfigPanel(Widget): save_config = Signal() unload_models = Signal() reload_textstyle = Signal(bool) def __init__(self, *args, **kwargs) -> None: super().__init__(*args, **kwargs) Loading @@ -365,7 +366,7 @@ class ConfigPanel(Widget): label_inpaint = self.tr('Inpaint') label_translator = self.tr('Translator') label_startup = self.tr('Startup') label_lettering = self.tr('Typesetting') label_typesetting = self.tr('Typesetting') label_save = self.tr('Save') label_saladict = self.tr('SalaDict') Loading @@ -377,7 +378,7 @@ class ConfigPanel(Widget): ]) generalTableItem.appendRows([ TableItem(label_startup, CONFIG_FONTSIZE_TABLE), TableItem(label_lettering, CONFIG_FONTSIZE_TABLE), TableItem(label_typesetting, CONFIG_FONTSIZE_TABLE), TableItem(label_save, CONFIG_FONTSIZE_TABLE), TableItem(label_saladict, CONFIG_FONTSIZE_TABLE), ]) Loading Loading @@ -414,7 +415,7 @@ class ConfigPanel(Widget): self.open_on_startup_checker, _ = generalConfigPanel.addCheckBox(self.tr('Reopen last project on startup')) self.open_on_startup_checker.stateChanged.connect(self.on_open_onstartup_changed) generalConfigPanel.addTextLabel(label_lettering) generalConfigPanel.addTextLabel(label_typesetting) dec_program_str = self.tr('decide by program') use_global_str = self.tr('use global setting') Loading Loading @@ -466,6 +467,9 @@ class ConfigPanel(Widget): self.let_uppercase_checker, _ = generalConfigPanel.addCheckBox(self.tr('To uppercase')) self.let_uppercase_checker.stateChanged.connect(self.on_uppercase_changed) self.let_textstyle_indep_checker, _ = generalConfigPanel.addCheckBox(self.tr('Independent text styles for each projects')) self.let_textstyle_indep_checker.stateChanged.connect(self.on_textstyle_indep_changed) generalConfigPanel.addTextLabel(label_save) self.rst_imgformat_combobox, imsave_sublock = generalConfigPanel.addCombobox(['PNG', 'JPG', 'WEBP'], self.tr('Result image format')) self.rst_imgformat_combobox.currentIndexChanged.connect(self.on_rst_imgformat_changed) Loading Loading @@ -549,6 +553,10 @@ class ConfigPanel(Widget): def on_uppercase_changed(self): pcfg.let_uppercase_flag = self.let_uppercase_checker.isChecked() def on_textstyle_indep_changed(self): pcfg.let_textstyle_indep_flag = self.let_textstyle_indep_checker.isChecked() self.reload_textstyle.emit(pcfg.let_textstyle_indep_flag) def on_rst_imgformat_changed(self): pcfg.imgsave_ext = '.' + self.rst_imgformat_combobox.currentText().lower() Loading Loading @@ -615,6 +623,7 @@ class ConfigPanel(Widget): self.let_autolayout_adaptive_fntsize_checker.setChecked(pcfg.let_autolayout_adaptive_fntsz) self.selectext_minimenu_checker.setChecked(pcfg.textselect_mini_menu) self.let_uppercase_checker.setChecked(pcfg.let_uppercase_flag) self.let_textstyle_indep_checker.setChecked(pcfg.let_textstyle_indep_flag) self.saladict_shortcut.setKeySequence(pcfg.saladict_shortcut) self.searchurl_combobox.setCurrentText(pcfg.search_url) self.ocr_config_panel.restoreEmptyOCRChecker.setChecked(pcfg.restore_ocr_empty) Loading ui/mainwindow.py +18 −2 Original line number Diff line number Diff line Loading @@ -128,7 +128,7 @@ class MainWindow(mainwindow_cls): self.leftBar.imgTransChecked.connect(self.setupImgTransUI) self.leftBar.configChecked.connect(self.setupConfigUI) self.leftBar.globalSearchChecker.clicked.connect(self.on_set_gsearch_widget) self.leftBar.open_dir.connect(self.openDir) self.leftBar.open_dir.connect(self.OpenProj) self.leftBar.open_json_proj.connect(self.openJsonProj) self.leftBar.save_proj.connect(self.save_proj) self.leftBar.export_doc.connect(self.on_export_doc) Loading Loading @@ -289,6 +289,7 @@ class MainWindow(mainwindow_cls): self.configPanel.setupConfig() self.configPanel.save_config.connect(self.save_config) self.configPanel.reload_textstyle.connect(self.load_textstyle_from_proj_dir) textblock_mode = pcfg.imgtrans_textblock if pcfg.imgtrans_textedit: Loading Loading @@ -345,6 +346,21 @@ class MainWindow(mainwindow_cls): else: self.openJsonProj(proj_path) if pcfg.let_textstyle_indep_flag and not shared.HEADLESS: self.load_textstyle_from_proj_dir(from_proj=True) def load_textstyle_from_proj_dir(self, from_proj=False): if from_proj: text_style_path = osp.join(self.imgtrans_proj.directory, 'textstyles.json') else: text_style_path = 'config/textstyles/default.json' if osp.exists(text_style_path): load_textstyle_from(text_style_path) self.textPanel.formatpanel.textstyle_panel.style_area.setStyles(text_styles) else: pcfg.text_styles_path = text_style_path save_text_styles() def openDir(self, directory: str): try: self.opening_dir = True Loading @@ -361,7 +377,7 @@ class MainWindow(mainwindow_cls): def dropOpenDir(self, directory: str): if isinstance(directory, str) and osp.exists(directory): self.leftBar.updateRecentProjList(directory) self.openDir(directory) self.OpenProj(directory) def openJsonProj(self, json_path: str): try: Loading utils/config.py +1 −0 Original line number Diff line number Diff line Loading @@ -83,6 +83,7 @@ class ProgramConfig(Config): let_autolayout_flag: bool = True let_autolayout_adaptive_fntsz: bool = True let_uppercase_flag: bool = True let_textstyle_indep_flag: bool = False text_styles_path: str = osp.join(shared.DEFAULT_TEXTSTYLE_DIR, 'default.json') expand_tstyle_panel: bool = True fsearch_case: bool = False Loading Loading
ui/configpanel.py +12 −3 Original line number Diff line number Diff line Loading @@ -350,6 +350,7 @@ class ConfigPanel(Widget): save_config = Signal() unload_models = Signal() reload_textstyle = Signal(bool) def __init__(self, *args, **kwargs) -> None: super().__init__(*args, **kwargs) Loading @@ -365,7 +366,7 @@ class ConfigPanel(Widget): label_inpaint = self.tr('Inpaint') label_translator = self.tr('Translator') label_startup = self.tr('Startup') label_lettering = self.tr('Typesetting') label_typesetting = self.tr('Typesetting') label_save = self.tr('Save') label_saladict = self.tr('SalaDict') Loading @@ -377,7 +378,7 @@ class ConfigPanel(Widget): ]) generalTableItem.appendRows([ TableItem(label_startup, CONFIG_FONTSIZE_TABLE), TableItem(label_lettering, CONFIG_FONTSIZE_TABLE), TableItem(label_typesetting, CONFIG_FONTSIZE_TABLE), TableItem(label_save, CONFIG_FONTSIZE_TABLE), TableItem(label_saladict, CONFIG_FONTSIZE_TABLE), ]) Loading Loading @@ -414,7 +415,7 @@ class ConfigPanel(Widget): self.open_on_startup_checker, _ = generalConfigPanel.addCheckBox(self.tr('Reopen last project on startup')) self.open_on_startup_checker.stateChanged.connect(self.on_open_onstartup_changed) generalConfigPanel.addTextLabel(label_lettering) generalConfigPanel.addTextLabel(label_typesetting) dec_program_str = self.tr('decide by program') use_global_str = self.tr('use global setting') Loading Loading @@ -466,6 +467,9 @@ class ConfigPanel(Widget): self.let_uppercase_checker, _ = generalConfigPanel.addCheckBox(self.tr('To uppercase')) self.let_uppercase_checker.stateChanged.connect(self.on_uppercase_changed) self.let_textstyle_indep_checker, _ = generalConfigPanel.addCheckBox(self.tr('Independent text styles for each projects')) self.let_textstyle_indep_checker.stateChanged.connect(self.on_textstyle_indep_changed) generalConfigPanel.addTextLabel(label_save) self.rst_imgformat_combobox, imsave_sublock = generalConfigPanel.addCombobox(['PNG', 'JPG', 'WEBP'], self.tr('Result image format')) self.rst_imgformat_combobox.currentIndexChanged.connect(self.on_rst_imgformat_changed) Loading Loading @@ -549,6 +553,10 @@ class ConfigPanel(Widget): def on_uppercase_changed(self): pcfg.let_uppercase_flag = self.let_uppercase_checker.isChecked() def on_textstyle_indep_changed(self): pcfg.let_textstyle_indep_flag = self.let_textstyle_indep_checker.isChecked() self.reload_textstyle.emit(pcfg.let_textstyle_indep_flag) def on_rst_imgformat_changed(self): pcfg.imgsave_ext = '.' + self.rst_imgformat_combobox.currentText().lower() Loading Loading @@ -615,6 +623,7 @@ class ConfigPanel(Widget): self.let_autolayout_adaptive_fntsize_checker.setChecked(pcfg.let_autolayout_adaptive_fntsz) self.selectext_minimenu_checker.setChecked(pcfg.textselect_mini_menu) self.let_uppercase_checker.setChecked(pcfg.let_uppercase_flag) self.let_textstyle_indep_checker.setChecked(pcfg.let_textstyle_indep_flag) self.saladict_shortcut.setKeySequence(pcfg.saladict_shortcut) self.searchurl_combobox.setCurrentText(pcfg.search_url) self.ocr_config_panel.restoreEmptyOCRChecker.setChecked(pcfg.restore_ocr_empty) Loading
ui/mainwindow.py +18 −2 Original line number Diff line number Diff line Loading @@ -128,7 +128,7 @@ class MainWindow(mainwindow_cls): self.leftBar.imgTransChecked.connect(self.setupImgTransUI) self.leftBar.configChecked.connect(self.setupConfigUI) self.leftBar.globalSearchChecker.clicked.connect(self.on_set_gsearch_widget) self.leftBar.open_dir.connect(self.openDir) self.leftBar.open_dir.connect(self.OpenProj) self.leftBar.open_json_proj.connect(self.openJsonProj) self.leftBar.save_proj.connect(self.save_proj) self.leftBar.export_doc.connect(self.on_export_doc) Loading Loading @@ -289,6 +289,7 @@ class MainWindow(mainwindow_cls): self.configPanel.setupConfig() self.configPanel.save_config.connect(self.save_config) self.configPanel.reload_textstyle.connect(self.load_textstyle_from_proj_dir) textblock_mode = pcfg.imgtrans_textblock if pcfg.imgtrans_textedit: Loading Loading @@ -345,6 +346,21 @@ class MainWindow(mainwindow_cls): else: self.openJsonProj(proj_path) if pcfg.let_textstyle_indep_flag and not shared.HEADLESS: self.load_textstyle_from_proj_dir(from_proj=True) def load_textstyle_from_proj_dir(self, from_proj=False): if from_proj: text_style_path = osp.join(self.imgtrans_proj.directory, 'textstyles.json') else: text_style_path = 'config/textstyles/default.json' if osp.exists(text_style_path): load_textstyle_from(text_style_path) self.textPanel.formatpanel.textstyle_panel.style_area.setStyles(text_styles) else: pcfg.text_styles_path = text_style_path save_text_styles() def openDir(self, directory: str): try: self.opening_dir = True Loading @@ -361,7 +377,7 @@ class MainWindow(mainwindow_cls): def dropOpenDir(self, directory: str): if isinstance(directory, str) and osp.exists(directory): self.leftBar.updateRecentProjList(directory) self.openDir(directory) self.OpenProj(directory) def openJsonProj(self, json_path: str): try: Loading
utils/config.py +1 −0 Original line number Diff line number Diff line Loading @@ -83,6 +83,7 @@ class ProgramConfig(Config): let_autolayout_flag: bool = True let_autolayout_adaptive_fntsz: bool = True let_uppercase_flag: bool = True let_textstyle_indep_flag: bool = False text_styles_path: str = osp.join(shared.DEFAULT_TEXTSTYLE_DIR, 'default.json') expand_tstyle_panel: bool = True fsearch_case: bool = False Loading