Commit 44189207 authored by dmMaze's avatar dmMaze
Browse files

support override writing mode

parent 739ec095
Loading
Loading
Loading
Loading
+142 B (14.2 KiB)

File changed.

No diff preview for this file type.

+54 −39
Original line number Diff line number Diff line
@@ -135,67 +135,67 @@
<context>
    <name>ConfigPanel</name>
    <message>
        <location filename="../ui/configpanel.py" line="356"/>
        <location filename="../ui/configpanel.py" line="359"/>
        <source>Text Detection</source>
        <translation>文本检测</translation>
    </message>
    <message>
        <location filename="../ui/configpanel.py" line="383"/>
        <location filename="../ui/configpanel.py" line="386"/>
        <source>OCR</source>
        <translation>OCR</translation>
    </message>
    <message>
        <location filename="../ui/configpanel.py" line="358"/>
        <location filename="../ui/configpanel.py" line="361"/>
        <source>Inpaint</source>
        <translation>图像修复</translation>
    </message>
    <message>
        <location filename="../ui/configpanel.py" line="359"/>
        <location filename="../ui/configpanel.py" line="362"/>
        <source>Translator</source>
        <translation>翻译器</translation>
    </message>
    <message>
        <location filename="../ui/configpanel.py" line="379"/>
        <location filename="../ui/configpanel.py" line="382"/>
        <source>Detector</source>
        <translation>检测器</translation>
    </message>
    <message>
        <location filename="../ui/configpanel.py" line="387"/>
        <location filename="../ui/configpanel.py" line="390"/>
        <source>Inpainter</source>
        <translation>修复工具</translation>
    </message>
    <message>
        <location filename="../ui/configpanel.py" line="353"/>
        <location filename="../ui/configpanel.py" line="356"/>
        <source>DL Module</source>
        <translation>自动化模组</translation>
    </message>
    <message>
        <location filename="../ui/configpanel.py" line="354"/>
        <location filename="../ui/configpanel.py" line="357"/>
        <source>General</source>
        <translation>常规</translation>
    </message>
    <message>
        <location filename="../ui/configpanel.py" line="360"/>
        <location filename="../ui/configpanel.py" line="363"/>
        <source>Startup</source>
        <translation>启动</translation>
    </message>
    <message>
        <location filename="../ui/configpanel.py" line="395"/>
        <location filename="../ui/configpanel.py" line="398"/>
        <source>Reopen last project on startup</source>
        <translation>启动时打开上次项目</translation>
    </message>
    <message>
        <location filename="../ui/configpanel.py" line="361"/>
        <location filename="../ui/configpanel.py" line="364"/>
        <source>Lettering</source>
        <translation>嵌字</translation>
    </message>
    <message>
        <location filename="../ui/configpanel.py" line="399"/>
        <location filename="../ui/configpanel.py" line="402"/>
        <source>decide by program</source>
        <translation>由程序决定</translation>
    </message>
    <message>
        <location filename="../ui/configpanel.py" line="400"/>
        <location filename="../ui/configpanel.py" line="403"/>
        <source>use global setting</source>
        <translation>使用全局设置</translation>
    </message>
@@ -220,17 +220,17 @@
        <translation type="obsolete">对齐方式</translation>
    </message>
    <message>
        <location filename="../ui/configpanel.py" line="433"/>
        <location filename="../ui/configpanel.py" line="440"/>
        <source>Auto layout</source>
        <translation>自动排版</translation>
        <translation>横排自动排版</translation>
    </message>
    <message>
        <location filename="../ui/configpanel.py" line="433"/>
        <source>Split translation into multi-lines according to the extracted balloon region. The font size will be adaptively resized if it is set to &quot;decide by program.&quot;</source>
        <translation>自动断句并分行.</translation>
        <translation type="obsolete">自动断句并分行.</translation>
    </message>
    <message>
        <location filename="../ui/configpanel.py" line="436"/>
        <location filename="../ui/configpanel.py" line="446"/>
        <source>To uppercase</source>
        <translation>小写转大写</translation>
    </message>
@@ -240,17 +240,17 @@
        <translation type="obsolete">特效</translation>
    </message>
    <message>
        <location filename="../ui/configpanel.py" line="363"/>
        <location filename="../ui/configpanel.py" line="366"/>
        <source>SalaDict</source>
        <translation>沙拉查词</translation>
    </message>
    <message>
        <location filename="../ui/configpanel.py" line="452"/>
        <location filename="../ui/configpanel.py" line="462"/>
        <source>&lt;a href=&quot;https://github.com/dmMaze/BallonsTranslator/tree/master/doc/saladict.md&quot;&gt;Installation guide&lt;/a&gt;</source>
        <translation>&lt;a href=&quot;https://github.com/dmMaze/BallonsTranslator/tree/master/doc/saladict_chs.md&quot;&gt;安装说明&lt;/a&gt;</translation>
    </message>
    <message>
        <location filename="../ui/configpanel.py" line="456"/>
        <location filename="../ui/configpanel.py" line="466"/>
        <source>Show mini menu when selecting text.</source>
        <translation>选择文本时显示迷你菜单</translation>
    </message>
@@ -260,7 +260,7 @@
        <translation type="obsolete">快捷键</translation>
    </message>
    <message>
        <location filename="../ui/configpanel.py" line="465"/>
        <location filename="../ui/configpanel.py" line="475"/>
        <source>Search Engines</source>
        <translation>搜索引擎</translation>
    </message>
@@ -280,55 +280,70 @@
        <translation type="obsolete">轮廓颜色</translation>
    </message>
    <message>
        <location filename="../ui/configpanel.py" line="362"/>
        <location filename="../ui/configpanel.py" line="365"/>
        <source>Save</source>
        <translation>保存</translation>
    </message>
    <message>
        <location filename="../ui/configpanel.py" line="410"/>
        <location filename="../ui/configpanel.py" line="413"/>
        <source>Font Size</source>
        <translation>大小</translation>
    </message>
    <message>
        <location filename="../ui/configpanel.py" line="414"/>
        <location filename="../ui/configpanel.py" line="417"/>
        <source>Stroke Size</source>
        <translation></translation>
        <translation>轮廓大小</translation>
    </message>
    <message>
        <location filename="../ui/configpanel.py" line="418"/>
        <location filename="../ui/configpanel.py" line="421"/>
        <source>Font Color</source>
        <translation></translation>
        <translation>字体颜色</translation>
    </message>
    <message>
        <location filename="../ui/configpanel.py" line="421"/>
        <location filename="../ui/configpanel.py" line="424"/>
        <source>Stroke Color</source>
        <translation></translation>
        <translation>轮廓颜色</translation>
    </message>
    <message>
        <location filename="../ui/configpanel.py" line="425"/>
        <location filename="../ui/configpanel.py" line="428"/>
        <source>Effect</source>
        <translation>特效</translation>
    </message>
    <message>
        <location filename="../ui/configpanel.py" line="428"/>
        <location filename="../ui/configpanel.py" line="431"/>
        <source>Alignment</source>
        <translation></translation>
        <translation>对齐方式</translation>
    </message>
    <message>
        <location filename="../ui/configpanel.py" line="440"/>
        <location filename="../ui/configpanel.py" line="450"/>
        <source>Result image format</source>
        <translation>结果图格式</translation>
    </message>
    <message>
        <location filename="../ui/configpanel.py" line="445"/>
        <location filename="../ui/configpanel.py" line="455"/>
        <source>Quality</source>
        <translation>质量</translation>
    </message>
    <message>
        <location filename="../ui/configpanel.py" line="462"/>
        <location filename="../ui/configpanel.py" line="472"/>
        <source>Shortcut</source>
        <translation>快捷键</translation>
    </message>
    <message>
        <location filename="../ui/configpanel.py" line="440"/>
        <source>Split translation into multi-lines according to the extracted balloon region.</source>
        <translation>自动断句并分行</translation>
    </message>
    <message>
        <location filename="../ui/configpanel.py" line="442"/>
        <source>Adjust font size adaptively if it is set to &quot;decide by program.&quot;</source>
        <translation>自动排版时调整字体大小</translation>
    </message>
    <message>
        <location filename="../ui/configpanel.py" line="435"/>
        <source>Writing-mode</source>
        <translation>书写方向</translation>
    </message>
</context>
<context>
    <name>DrawingPanel</name>
@@ -725,22 +740,22 @@
        <translation>项目加载失败 </translation>
    </message>
    <message>
        <location filename="../ui/mainwindow.py" line="937"/>
        <location filename="../ui/mainwindow.py" line="940"/>
        <source>unsaved</source>
        <translation>未保存</translation>
    </message>
    <message>
        <location filename="../ui/mainwindow.py" line="937"/>
        <location filename="../ui/mainwindow.py" line="940"/>
        <source>saved</source>
        <translation>已保存</translation>
    </message>
    <message>
        <location filename="../ui/mainwindow.py" line="974"/>
        <location filename="../ui/mainwindow.py" line="977"/>
        <source>Saving image...</source>
        <translation>保存中...</translation>
    </message>
    <message>
        <location filename="../ui/mainwindow.py" line="1054"/>
        <location filename="../ui/mainwindow.py" line="1057"/>
        <source>Export to </source>
        <translation>导出至 </translation>
    </message>
+7 −0
Original line number Diff line number Diff line
@@ -431,6 +431,10 @@ class ConfigPanel(Widget):
        self.let_alignment_combox, sublock = combobox_with_label([dec_program_str, use_global_str], self.tr('Alignment'), parent=self, insert_stretch=True)
        self.let_alignment_combox.currentIndexChanged.connect(self.on_alignment_flag_changed)
        global_fntfmt_layout.addWidget(sublock, 2, 1)

        self.let_writing_mode_combox, sublock = combobox_with_label([dec_program_str, use_global_str], self.tr('Writing-mode'), parent=self, insert_stretch=True)
        self.let_writing_mode_combox.currentIndexChanged.connect(self.on_writing_mode_flag_changed)
        global_fntfmt_layout.addWidget(sublock, 3, 0)
        global_fntfmt_layout.addItem(QSpacerItem(0, 0, QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding), 0, 2)

        self.let_autolayout_checker, sublock = generalConfigPanel.addCheckBox(self.tr('Auto layout'), 
@@ -546,6 +550,9 @@ class ConfigPanel(Widget):
    def on_alignment_flag_changed(self):
        pcfg.let_alignment_flag = self.let_alignment_combox.currentIndex()

    def on_writing_mode_flag_changed(self):
        pcfg.let_writing_mode_flag = self.let_writing_mode_combox.currentIndex()

    def on_effect_flag_changed(self):
        pcfg.let_fnteffect_flag = self.let_effect_combox.currentIndex()

+3 −0
Original line number Diff line number Diff line
@@ -886,6 +886,7 @@ class MainWindow(FramelessWindow):
        override_fnt_scolor = pcfg.let_fnt_scolor_flag == 1
        override_alignment = pcfg.let_alignment_flag == 1
        override_effect = pcfg.let_fnteffect_flag == 1
        override_writing_mode = pcfg.let_writing_mode_flag == 1
        gf = self.textPanel.formatpanel.global_format
        
        for blk in blk_list:
@@ -906,6 +907,8 @@ class MainWindow(FramelessWindow):
                blk.shadow_radius = gf.shadow_radius
                blk.shadow_strength = gf.shadow_strength
                blk.shadow_offset = gf.shadow_offset
            if override_writing_mode:
                blk.vertical = gf.vertical
            
            blk.line_spacing = gf.line_spacing
            blk.letter_spacing = gf.letter_spacing
+13 −3
Original line number Diff line number Diff line
@@ -640,19 +640,29 @@ class SceneTextManager(QObject):
            self.textEditList.set_selected_list([t.idx for t in textitems])

    def layout_textblk(self, blkitem: TextBlkItem, text: str = None, mask: np.ndarray = None, bounding_rect: List = None, region_rect: List = None):
        
        '''
        auto text layout, vertical writing is not supported yet.
        '''
        
        old_br = blkitem.absBoundingRect()
        img = self.imgtrans_proj.img_array
        if img is None:
            return

        src_is_cjk = is_cjk(pcfg.module.translate_source)
        tgt_is_cjk = is_cjk(pcfg.module.translate_target)

        # disable for vertical writing
        if (src_is_cjk and tgt_is_cjk and blkitem.blk.src_is_vertical) or \
            (pcfg.let_writing_mode_flag == 1 and self.formatpanel.global_format.vertical):
            return

        blk_font = blkitem.font()
        fmt = blkitem.get_fontformat()
        blk_font.setLetterSpacing(QFont.SpacingType.PercentageSpacing, fmt.letter_spacing * 100)
        text_size_func = lambda text: get_text_size(QFontMetrics(blk_font), text)

        src_is_cjk = is_cjk(pcfg.module.translate_source)
        tgt_is_cjk = is_cjk(pcfg.module.translate_target)

        restore_charfmts = False
        if text is None:
            text = blkitem.toPlainText()
Loading