Loading .gitignore +3 −0 Original line number Diff line number Diff line Loading @@ -5,6 +5,9 @@ result ballontranslator/data/models ballontranslator/data/testpacks/eng_dontupload ballontranslator/data/testpacks/testpacks ballontranslator/data/*.png ballontranslator/ui/pagesources/gallery-dl ballontranslator/gallery-dl release libs Loading ballontranslator/ui/configpanel.py +17 −8 Original line number Diff line number Diff line Loading @@ -97,7 +97,7 @@ class ConfigBlock(Widget): sublock.layout().addItem(QSpacerItem(0, 0, QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding)) self.addSublock(sublock) sublock.layout().setSpacing(20) return le return le, sublock def addTextLabel(self, text: str = None): label = ConfigTextLabel(text, CONFIG_FONTSIZE_HEADER) Loading Loading @@ -272,6 +272,7 @@ class ConfigTable(QTreeView): class ConfigPanel(Widget): save_config = Signal() update_source_download_status = Signal(str) def __init__(self, *args, **kwargs) -> None: super().__init__(*args, **kwargs) Loading @@ -296,6 +297,7 @@ class ConfigPanel(Widget): label_inpaint = self.tr('Inpaint') label_translator = self.tr('Translator') label_startup = self.tr('Startup') label_sources = self.tr('Sources') label_lettering = self.tr('Lettering') label_saladict = self.tr("SalaDict") Loading @@ -307,6 +309,7 @@ class ConfigPanel(Widget): ]) generalTableItem.appendRows([ TableItem(label_startup, CONFIG_FONTSIZE_TABLE), TableItem(label_sources, CONFIG_FONTSIZE_TABLE), TableItem(label_lettering, CONFIG_FONTSIZE_TABLE), TableItem(label_saladict, CONFIG_FONTSIZE_TABLE) ]) Loading @@ -331,6 +334,10 @@ 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_sources) self.src_link_textbox, self.src_link_sub_block = generalConfigPanel.addLineEdit('Source url') self.src_link_textbox.textChanged.connect(self.on_source_link_changed) generalConfigPanel.addTextLabel(label_lettering) dec_program_str = self.tr('decide by program') use_global_str = self.tr('use global setting') Loading Loading @@ -438,14 +445,10 @@ class ConfigPanel(Widget): def on_effect_flag_changed(self): self.config.let_fnteffect_flag = self.let_effect_combox.currentIndex() # def on_source_flag_changed(self): # self.config.src_choice_flag = self.src_choice_combox.currentIndex() # def on_source_link_changed(self): # self.config.src_link_flag = self.src_link_textbox.text() # def on_source_force_download_changed(self): # self.config.src_force_download_flag = self.src_force_download_checker.isChecked() def on_source_link_changed(self): self.config.src_link_flag = self.src_link_textbox.text() self.update_source_download_status.emit(self.config.src_link_flag) def focusOnTranslator(self): idx0, idx1 = self.trans_sub_block.idx0, self.trans_sub_block.idx1 Loading @@ -457,6 +460,11 @@ class ConfigPanel(Widget): self.configTable.setCurrentItem(idx0, idx1) self.configTable.tableitem_pressed.emit(idx0, idx1) def focusOnSourceDownload(self): idx0, idx1 = self.src_link_sub_block.idx0, self.src_link_sub_block.idx1 self.configTable.setCurrentItem(idx0, idx1) self.configTable.tableitem_pressed.emit(idx0, idx1) def showEvent(self, e) -> None: self.inpaint_sub_block.layout().addWidget(self.inpaint_config_panel) return super().showEvent(e) Loading @@ -483,5 +491,6 @@ class ConfigPanel(Widget): self.let_uppercase_checker.setChecked(config.let_uppercase_flag) self.saladict_shortcut.setKeySequence(config.saladict_shortcut) self.searchurl_combobox.setCurrentText(config.search_url) self.src_link_textbox.setText(config.src_link_flag) self.blockSignals(False) No newline at end of file ballontranslator/ui/constants.py +2 −0 Original line number Diff line number Diff line Loading @@ -12,6 +12,8 @@ STYLESHEET_PATH = osp.join(PROGRAM_PATH, 'data/config/stylesheet.css') THEME_PATH = osp.join(PROGRAM_PATH, 'data/config/themes.json') CONFIG_PATH = osp.join(PROGRAM_PATH, 'data/config/config.json') DOWNLOAD_PATH = osp.join(PROGRAM_PATH, 'gallery-dl') CONFIG_FONTSIZE_HEADER = 18 CONFIG_FONTSIZE_TABLE = 14 CONFIG_FONTSIZE_CONTENT = 14 Loading ballontranslator/ui/dl_manager.py +9 −0 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ import time from typing import Union, List, Dict, Callable import numpy as np import traceback import os.path as osp from qtpy.QtCore import QThread, Signal, QObject, QLocale from qtpy.QtWidgets import QMessageBox Loading @@ -20,6 +21,7 @@ from .stylewidgets import ImgtransProgressMessageBox from .configpanel import ConfigPanel from .misc import DLModuleConfig, ProgramConfig from .imgtrans_proj import ProjImgTrans from dl.textdetector import TextBlock Loading Loading @@ -449,6 +451,7 @@ class DLManager(QObject): imgtrans_proj: ProjImgTrans = None update_translator_status = Signal(str, str, str) update_source_download_status = Signal(str) update_inpainter_status = Signal(str) finish_translate_page = Signal(str) canvas_inpaint_finished = Signal(dict) Loading Loading @@ -528,6 +531,8 @@ class DLManager(QObject): ocr_panel.ocr_changed.connect(self.setOCR) self.ocr_postprocess = ocr_postprocess self.on_finish_setsourcedownload() self.setTextDetector() self.setOCR() if self.dl_config.enable_translate: Loading Loading @@ -739,6 +744,10 @@ class DLManager(QObject): LOGGER.error('invalid translator') self.update_translator_status.emit(self.tr('Invalid'), '', '') def on_finish_setsourcedownload(self): if self.config.src_link_flag: self.update_source_download_status.emit(self.config.src_link_flag) def on_finish_translate_page(self, page_key: str): self.finish_translate_page.emit(page_key) Loading ballontranslator/ui/imgtrans_proj.py +10 −1 Original line number Diff line number Diff line Loading @@ -36,6 +36,9 @@ class ProjImgTrans: self.not_found_pages: Dict[List[TextBlock]] = {} self.new_pages: List[str] = [] self.proj_path: str = None self.src_download_link: str = '' self.current_img: str = None self.img_array: np.ndarray = None self.mask_array: np.ndarray = None Loading Loading @@ -86,6 +89,9 @@ class ProjImgTrans: def result_dir(self): return osp.join(self.directory, 'result') def init_properties(self, src_download_link: str = '', **kwargs): self.src_download_link = src_download_link def load_from_dict(self, proj_dict: dict): self.set_current_img(None) try: Loading @@ -107,6 +113,7 @@ class ProjImgTrans: self._idx2pagename[ii] = imname for imname in not_found_pages: self.not_found_pages[imname] = [TextBlock(**blk_dict) for blk_dict in page_dict[imname]] self.init_properties(**proj_dict) except Exception as e: raise ProjectNotSupportedException(e) set_img_failed = False Loading Loading @@ -185,6 +192,7 @@ class ProjImgTrans: self.pages[imgname] = [] self._pagename2idx[imgname] = ii self._idx2pagename[ii] = imgname self.init_properties() self.set_current_img_byidx(0) self.save() Loading @@ -200,7 +208,8 @@ class ProjImgTrans: return { 'directory': self.directory, 'pages': pages, 'current_img': self.current_img 'current_img': self.current_img, 'src_download_link': self.src_download_link } def read_img(self, imgname: str) -> np.ndarray: Loading Loading
.gitignore +3 −0 Original line number Diff line number Diff line Loading @@ -5,6 +5,9 @@ result ballontranslator/data/models ballontranslator/data/testpacks/eng_dontupload ballontranslator/data/testpacks/testpacks ballontranslator/data/*.png ballontranslator/ui/pagesources/gallery-dl ballontranslator/gallery-dl release libs Loading
ballontranslator/ui/configpanel.py +17 −8 Original line number Diff line number Diff line Loading @@ -97,7 +97,7 @@ class ConfigBlock(Widget): sublock.layout().addItem(QSpacerItem(0, 0, QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding)) self.addSublock(sublock) sublock.layout().setSpacing(20) return le return le, sublock def addTextLabel(self, text: str = None): label = ConfigTextLabel(text, CONFIG_FONTSIZE_HEADER) Loading Loading @@ -272,6 +272,7 @@ class ConfigTable(QTreeView): class ConfigPanel(Widget): save_config = Signal() update_source_download_status = Signal(str) def __init__(self, *args, **kwargs) -> None: super().__init__(*args, **kwargs) Loading @@ -296,6 +297,7 @@ class ConfigPanel(Widget): label_inpaint = self.tr('Inpaint') label_translator = self.tr('Translator') label_startup = self.tr('Startup') label_sources = self.tr('Sources') label_lettering = self.tr('Lettering') label_saladict = self.tr("SalaDict") Loading @@ -307,6 +309,7 @@ class ConfigPanel(Widget): ]) generalTableItem.appendRows([ TableItem(label_startup, CONFIG_FONTSIZE_TABLE), TableItem(label_sources, CONFIG_FONTSIZE_TABLE), TableItem(label_lettering, CONFIG_FONTSIZE_TABLE), TableItem(label_saladict, CONFIG_FONTSIZE_TABLE) ]) Loading @@ -331,6 +334,10 @@ 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_sources) self.src_link_textbox, self.src_link_sub_block = generalConfigPanel.addLineEdit('Source url') self.src_link_textbox.textChanged.connect(self.on_source_link_changed) generalConfigPanel.addTextLabel(label_lettering) dec_program_str = self.tr('decide by program') use_global_str = self.tr('use global setting') Loading Loading @@ -438,14 +445,10 @@ class ConfigPanel(Widget): def on_effect_flag_changed(self): self.config.let_fnteffect_flag = self.let_effect_combox.currentIndex() # def on_source_flag_changed(self): # self.config.src_choice_flag = self.src_choice_combox.currentIndex() # def on_source_link_changed(self): # self.config.src_link_flag = self.src_link_textbox.text() # def on_source_force_download_changed(self): # self.config.src_force_download_flag = self.src_force_download_checker.isChecked() def on_source_link_changed(self): self.config.src_link_flag = self.src_link_textbox.text() self.update_source_download_status.emit(self.config.src_link_flag) def focusOnTranslator(self): idx0, idx1 = self.trans_sub_block.idx0, self.trans_sub_block.idx1 Loading @@ -457,6 +460,11 @@ class ConfigPanel(Widget): self.configTable.setCurrentItem(idx0, idx1) self.configTable.tableitem_pressed.emit(idx0, idx1) def focusOnSourceDownload(self): idx0, idx1 = self.src_link_sub_block.idx0, self.src_link_sub_block.idx1 self.configTable.setCurrentItem(idx0, idx1) self.configTable.tableitem_pressed.emit(idx0, idx1) def showEvent(self, e) -> None: self.inpaint_sub_block.layout().addWidget(self.inpaint_config_panel) return super().showEvent(e) Loading @@ -483,5 +491,6 @@ class ConfigPanel(Widget): self.let_uppercase_checker.setChecked(config.let_uppercase_flag) self.saladict_shortcut.setKeySequence(config.saladict_shortcut) self.searchurl_combobox.setCurrentText(config.search_url) self.src_link_textbox.setText(config.src_link_flag) self.blockSignals(False) No newline at end of file
ballontranslator/ui/constants.py +2 −0 Original line number Diff line number Diff line Loading @@ -12,6 +12,8 @@ STYLESHEET_PATH = osp.join(PROGRAM_PATH, 'data/config/stylesheet.css') THEME_PATH = osp.join(PROGRAM_PATH, 'data/config/themes.json') CONFIG_PATH = osp.join(PROGRAM_PATH, 'data/config/config.json') DOWNLOAD_PATH = osp.join(PROGRAM_PATH, 'gallery-dl') CONFIG_FONTSIZE_HEADER = 18 CONFIG_FONTSIZE_TABLE = 14 CONFIG_FONTSIZE_CONTENT = 14 Loading
ballontranslator/ui/dl_manager.py +9 −0 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ import time from typing import Union, List, Dict, Callable import numpy as np import traceback import os.path as osp from qtpy.QtCore import QThread, Signal, QObject, QLocale from qtpy.QtWidgets import QMessageBox Loading @@ -20,6 +21,7 @@ from .stylewidgets import ImgtransProgressMessageBox from .configpanel import ConfigPanel from .misc import DLModuleConfig, ProgramConfig from .imgtrans_proj import ProjImgTrans from dl.textdetector import TextBlock Loading Loading @@ -449,6 +451,7 @@ class DLManager(QObject): imgtrans_proj: ProjImgTrans = None update_translator_status = Signal(str, str, str) update_source_download_status = Signal(str) update_inpainter_status = Signal(str) finish_translate_page = Signal(str) canvas_inpaint_finished = Signal(dict) Loading Loading @@ -528,6 +531,8 @@ class DLManager(QObject): ocr_panel.ocr_changed.connect(self.setOCR) self.ocr_postprocess = ocr_postprocess self.on_finish_setsourcedownload() self.setTextDetector() self.setOCR() if self.dl_config.enable_translate: Loading Loading @@ -739,6 +744,10 @@ class DLManager(QObject): LOGGER.error('invalid translator') self.update_translator_status.emit(self.tr('Invalid'), '', '') def on_finish_setsourcedownload(self): if self.config.src_link_flag: self.update_source_download_status.emit(self.config.src_link_flag) def on_finish_translate_page(self, page_key: str): self.finish_translate_page.emit(page_key) Loading
ballontranslator/ui/imgtrans_proj.py +10 −1 Original line number Diff line number Diff line Loading @@ -36,6 +36,9 @@ class ProjImgTrans: self.not_found_pages: Dict[List[TextBlock]] = {} self.new_pages: List[str] = [] self.proj_path: str = None self.src_download_link: str = '' self.current_img: str = None self.img_array: np.ndarray = None self.mask_array: np.ndarray = None Loading Loading @@ -86,6 +89,9 @@ class ProjImgTrans: def result_dir(self): return osp.join(self.directory, 'result') def init_properties(self, src_download_link: str = '', **kwargs): self.src_download_link = src_download_link def load_from_dict(self, proj_dict: dict): self.set_current_img(None) try: Loading @@ -107,6 +113,7 @@ class ProjImgTrans: self._idx2pagename[ii] = imname for imname in not_found_pages: self.not_found_pages[imname] = [TextBlock(**blk_dict) for blk_dict in page_dict[imname]] self.init_properties(**proj_dict) except Exception as e: raise ProjectNotSupportedException(e) set_img_failed = False Loading Loading @@ -185,6 +192,7 @@ class ProjImgTrans: self.pages[imgname] = [] self._pagename2idx[imgname] = ii self._idx2pagename[ii] = imgname self.init_properties() self.set_current_img_byidx(0) self.save() Loading @@ -200,7 +208,8 @@ class ProjImgTrans: return { 'directory': self.directory, 'pages': pages, 'current_img': self.current_img 'current_img': self.current_img, 'src_download_link': self.src_download_link } def read_img(self, imgname: str) -> np.ndarray: Loading