Commit c560268d authored by dmMaze's avatar dmMaze
Browse files

support show only custom fonts

parent 2226a349
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -340,6 +340,7 @@ class ConfigPanel(Widget):
    save_config = Signal()
    unload_models = Signal()
    reload_textstyle = Signal(bool)
    show_only_custom_font = Signal(bool)

    def __init__(self, *args, **kwargs) -> None:
        super().__init__(*args, **kwargs)
@@ -447,6 +448,10 @@ class ConfigPanel(Widget):

        global_fntfmt_layout.addItem(QSpacerItem(0, 0, QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding), 0, 2)
        
        self.let_show_only_custom_fonts, sublock = checkbox_with_label(self.tr("Font selection"), discription=self.tr("Show only custom fonts"))
        global_fntfmt_layout.addWidget(sublock, 4, 0)
        self.let_show_only_custom_fonts.stateChanged.connect(self.on_show_only_custom_fonts)

        self.let_autolayout_checker, sublock = generalConfigPanel.addCheckBox(self.tr('Auto layout'), 
                discription=self.tr('Split translation into multi-lines according to the extracted balloon region.'))

@@ -577,6 +582,10 @@ class ConfigPanel(Widget):
    def on_effect_flag_changed(self):
        pcfg.let_fnteffect_flag = self.let_effect_combox.currentIndex()

    def on_show_only_custom_fonts(self):
        pcfg.let_show_only_custom_fonts_flag = self.let_show_only_custom_fonts.isChecked()
        self.show_only_custom_font.emit(pcfg.let_show_only_custom_fonts_flag)

    def focusOnTranslator(self):
        idx0, idx1 = self.trans_sub_block.idx0, self.trans_sub_block.idx1
        self.configTable.setCurrentItem(idx0, idx1)
@@ -616,5 +625,6 @@ class ConfigPanel(Widget):
        self.rst_imgquality_edit.setText(str(pcfg.imgsave_quality))
        self.load_model_checker.setChecked(pcfg.module.load_model_on_demand)
        self.empty_runcache_checker.setChecked(pcfg.module.empty_runcache)
        self.let_show_only_custom_fonts.setChecked(pcfg.let_show_only_custom_fonts_flag)

        self.blockSignals(False)
 No newline at end of file
+10 −0
Original line number Diff line number Diff line
@@ -297,6 +297,9 @@ 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)
        self.configPanel.show_only_custom_font.connect(self.on_show_only_custom_font)
        if pcfg.let_show_only_custom_fonts_flag:
            self.on_show_only_custom_font(True)

        textblock_mode = pcfg.imgtrans_textblock
        if pcfg.imgtrans_textedit:
@@ -368,6 +371,13 @@ class MainWindow(mainwindow_cls):
            pcfg.text_styles_path = text_style_path
            save_text_styles()

    def on_show_only_custom_font(self, only_custom: bool):
        if only_custom:
            font_list = shared.CUSTOM_FONTS
        else:
            font_list = shared.FONT_FAMILIES
        self.textPanel.formatpanel.familybox.update_font_list(font_list)

    def openDir(self, directory: str):
        try:
            self.opening_dir = True
+10 −0
Original line number Diff line number Diff line
@@ -255,6 +255,16 @@ class FontFamilyComboBox(QFontComboBox):
            self.param_changed.emit('font_family', ffamily)
            self._current_font = ffamily


    def update_font_list(self, font_list):
        self.currentFontChanged.disconnect(self.on_fontfamily_changed)
        current_font = self.currentFont().family()
        self.clear()
        self.addItems(font_list)
        self.addItems([current_font])
        self.setCurrentText(current_font)
        self.currentFontChanged.connect(self.on_fontfamily_changed)

    def on_return_pressed(self):
        self.return_pressed = True
        self.apply_fontfamily()