Commit 27ffd707 authored by dmMaze's avatar dmMaze
Browse files

remove sync source

parent cef0b079
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -85,7 +85,6 @@ class ProgramConfig(Config):
    gsearch_regex: bool = False
    gsearch_range: int = 0
    darkmode: bool = False
    src_link_flag: str = ''
    textselect_mini_menu: bool = True
    fold_textarea: bool = False
    show_source_text: bool = True
+0 −16
Original line number Diff line number Diff line
@@ -268,7 +268,6 @@ 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)
@@ -321,10 +320,6 @@ 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')
@@ -437,11 +432,6 @@ class ConfigPanel(Widget):
    def on_effect_flag_changed(self):
        pcfg.let_fnteffect_flag = self.let_effect_combox.currentIndex()


    def on_source_link_changed(self):
        pcfg.src_link_flag = self.src_link_textbox.text()
        self.update_source_download_status.emit(pcfg.src_link_flag)

    def focusOnTranslator(self):
        idx0, idx1 = self.trans_sub_block.idx0, self.trans_sub_block.idx1
        self.configTable.setCurrentItem(idx0, idx1)
@@ -452,11 +442,6 @@ 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)
@@ -483,7 +468,6 @@ class ConfigPanel(Widget):
        self.let_uppercase_checker.setChecked(pcfg.let_uppercase_flag)
        self.saladict_shortcut.setKeySequence(pcfg.saladict_shortcut)
        self.searchurl_combobox.setCurrentText(pcfg.search_url)
        self.src_link_textbox.setText(pcfg.src_link_flag)
        self.ocr_config_panel.restoreEmptyOCRChecker.setChecked(pcfg.restore_ocr_empty)

        self.blockSignals(False)
 No newline at end of file
+0 −8
Original line number Diff line number Diff line
@@ -37,8 +37,6 @@ class ProjImgTrans:
        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
@@ -89,9 +87,6 @@ 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:
@@ -113,7 +108,6 @@ 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
@@ -192,7 +186,6 @@ class ProjImgTrans:
            self.pages[imgname] = []
            self._pagename2idx[imgname] = ii
            self._idx2pagename[ii] = imgname
        self.init_properties()
        self.set_current_img_byidx(0)
        self.save()
        
@@ -209,7 +202,6 @@ class ProjImgTrans:
            'directory': self.directory,
            'pages': pages,
            'current_img': self.current_img,
            'src_download_link': self.src_download_link
        }

    def read_img(self, imgname: str) -> np.ndarray:
+1 −47
Original line number Diff line number Diff line
@@ -17,13 +17,12 @@ from .imgtrans_proj import ProjImgTrans
from .canvas import Canvas
from .configpanel import ConfigPanel
from .module_manager import ModuleManager
from .pagesources import SourceDownload
from .textedit_area import SourceTextEdit, SelectTextMiniMenu
from .drawingpanel import DrawingPanel
from .scenetext_manager import SceneTextManager, TextPanel, PasteSrcItemsCommand
from .mainwindowbars import TitleBar, LeftBar, BottomBar
from .io_thread import ImgSaveThread, ImportDocThread, ExportDocThread
from .stylewidgets import FrameLessMessageBox, ImgtransProgressMessageBox, SourceDownloadProgressMessageBox
from .stylewidgets import FrameLessMessageBox, ImgtransProgressMessageBox
from .preset_widget import PresetPanel
from .constants import CONFIG_PATH
from .global_search_widget import GlobalSearchWidget
@@ -78,7 +77,6 @@ class MainWindow(FramelessWindow):

    def setStyleSheet(self, styleSheet: str) -> None:
        self.imgtrans_progress_msgbox.setStyleSheet(styleSheet)
        self.source_download_msgbox.setStyleSheet(styleSheet)
        self.export_doc_thread.progress_bar.setStyleSheet(styleSheet)
        self.import_doc_thread.progress_bar.setStyleSheet(styleSheet)
        # sel_menu_size = self.selectext_minimenu.sizeHint()
@@ -138,8 +136,6 @@ class MainWindow(FramelessWindow):
        self.bottomBar.paintmode_checkchanged.connect(self.setPaintMode)
        self.bottomBar.textblock_checkchanged.connect(self.setTextBlockMode)

        self.configPanel.src_link_textbox.setText(pcfg.src_link_flag)

        mainHLayout = QHBoxLayout()
        mainHLayout.addWidget(self.leftBar)
        mainHLayout.addWidget(self.centralStackWidget)
@@ -227,7 +223,6 @@ class MainWindow(FramelessWindow):
        self.mainvlayout = mainVBoxLayout
        self.comicTransSplitter.setStretchFactor(1, 10)
        self.imgtrans_progress_msgbox = ImgtransProgressMessageBox()
        self.source_download_msgbox = SourceDownloadProgressMessageBox()
        self.resetStyleSheet()

    def setupConfig(self):
@@ -251,8 +246,6 @@ class MainWindow(FramelessWindow):

        self.module_manager = module_manager = ModuleManager(self.imgtrans_proj)
        module_manager.update_translator_status.connect(self.updateTranslatorStatus)
        module_manager.update_source_download_status.connect(self.updateSourceDownloadStatus)
        self.configPanel.update_source_download_status.connect(self.updateSourceDownloadStatus)
        module_manager.update_inpainter_status.connect(self.updateInpainterStatus)
        module_manager.finish_translate_page.connect(self.finishTranslatePage)
        module_manager.imgtrans_pipeline_finished.connect(self.on_imgtrans_pipeline_finished)
@@ -265,9 +258,7 @@ class MainWindow(FramelessWindow):
        module_manager.imgtrans_thread.post_process_mask = self.drawingPanel.rectPanel.post_process_mask

        self.leftBar.run_imgtrans.connect(self.on_run_imgtrans)
        self.leftBar.run_sync_source.connect(self.on_run_sync_source)
        self.bottomBar.inpaint_btn_clicked.connect(self.inpaintBtnClicked)
        self.bottomBar.source_download_btn_clicked.connect(self.SourceDownloadBtnClicked)
        self.bottomBar.translatorStatusbtn.clicked.connect(self.translatorStatusBtnPressed)
        self.bottomBar.transTranspageBtn.run_target.connect(self.on_transpagebtn_pressed)

@@ -283,11 +274,6 @@ class MainWindow(FramelessWindow):
        self.configPanel.setupConfig()
        self.configPanel.save_config.connect(self.save_config)

        self.source_download = SourceDownload(pcfg, self.imgtrans_proj, self.source_download_msgbox)
        self.source_download.open_downloaded_proj.connect(self.openDir)
        self.source_download.update_progress_bar.connect(self.source_download_msgbox.updateDownloadBar)
        self.source_download.finished_downloading.connect(self.on_finished_sync_source)

        textblock_mode = pcfg.imgtrans_textblock
        if pcfg.imgtrans_textedit:
            if textblock_mode:
@@ -799,10 +785,6 @@ class MainWindow(FramelessWindow):
        self.leftBar.configChecker.setChecked(True)
        self.configPanel.focusOnInpaint()

    def SourceDownloadBtnClicked(self):
        self.leftBar.configChecker.setChecked(True)
        self.configPanel.focusOnSourceDownload()

    def updateTranslatorStatus(self, translator: str, source: str, target: str):
        if translator == '':
            self.bottomBar.translatorStatusbtn.hide()
@@ -812,15 +794,6 @@ class MainWindow(FramelessWindow):
            self.bottomBar.translatorStatusbtn.show()
            self.bottomBar.transTranspageBtn.show()

    def updateSourceDownloadStatus(self, url: str):
        if url == '':
            self.bottomBar.sourceStatusBtn.hide()
            self.bottomBar.sourceStatusBtn.hide()
        else:
            self.bottomBar.sourceStatusBtn.updateStatus(url)
            self.bottomBar.sourceStatusBtn.show()
            self.bottomBar.sourceStatusBtn.show()

    def updateInpainterStatus(self, inpainter: str):
        self.bottomBar.inpainterStatBtn.updateStatus(inpainter)

@@ -991,13 +964,6 @@ class MainWindow(FramelessWindow):
                                    size.height() - msg_size.height()))
        self.module_manager.progress_msgbox.move(p)

    def on_source_download_progressbox_showed(self):
        msg_size = self.source_download_msgbox.size()
        size = self.size()
        p = self.mapToGlobal(QPoint(size.width() - msg_size.width(),
                                    size.height() - msg_size.height()))
        self.source_download_msgbox.move(p)

    def on_closebtn_clicked(self):
        if self.imsave_thread.isRunning():
            self.imsave_thread.finished.connect(self.close)
@@ -1039,18 +1005,6 @@ class MainWindow(FramelessWindow):
                    textblk.vertical = textblk.src_is_vertical
        self.module_manager.runImgtransPipeline()

    def on_run_sync_source(self):
        self.source_download_msgbox.show_all_bars()
        self.source_download_msgbox.zero_progress()
        self.source_download_msgbox.show()
        self.on_source_download_progressbox_showed()
        self.source_download.start()

    def on_finished_sync_source(self):
        self.source_download_msgbox.hide_all_bars()
        self.source_download_msgbox.hide()


    def on_transpanel_changed(self):
        self.canvas.editor_index = self.rightComicTransStackPanel.currentIndex()
        if not self.canvas.textEditMode() and self.canvas.search_widget.isVisible():
+1 −21
Original line number Diff line number Diff line
@@ -30,11 +30,6 @@ class RunBtn(QPushButton):
        super().__init__(*args, **kwargs)
        self.setText('Run')

class SyncSourceBtn(QPushButton):
    def __init__(self, *args, **kwargs) -> None:
        super().__init__(*args, **kwargs)
        self.setText('Sync')


class StatusButton(QPushButton):
    pass
@@ -87,10 +82,6 @@ class InpainterStatusButton(StatusButton):
    def updateStatus(self, inpainter: str):
        self.setText(self.tr('Inpainter: ') + inpainter)

class SourceDownloadStatusButton(StatusButton):
    def updateStatus(self, source_url: str):
        self.setText(self.tr('Source url: ') + source_url)


class StateChecker(QCheckBox):
    checked = Signal(str)
@@ -115,7 +106,6 @@ class LeftBar(Widget):
    save_proj = Signal()
    save_config = Signal()
    run_imgtrans = Signal()
    run_sync_source = Signal()
    export_doc = Signal()
    import_doc = Signal()
    def __init__(self, mainwindow, *args, **kwargs) -> None:
@@ -178,9 +168,7 @@ class LeftBar(Widget):
        self.runImgtransBtn.setFixedSize(LEFTBTN_WIDTH, LEFTBTN_WIDTH)
        self.runImgtransBtn.clicked.connect(self.run_imgtrans)

        self.syncSourceBtn = SyncSourceBtn()
        self.runImgtransBtn.setFixedSize(LEFTBTN_WIDTH, LEFTBTN_WIDTH)
        self.syncSourceBtn.clicked.connect(self.run_sync_source)

        vlayout = QVBoxLayout(self)
        vlayout.addWidget(openBtnToolBar)
@@ -190,7 +178,6 @@ class LeftBar(Widget):
        vlayout.addItem(QSpacerItem(0, 0, QSizePolicy.Minimum, QSizePolicy.Expanding))
        vlayout.addWidget(self.configChecker)
        vlayout.addWidget(self.runImgtransBtn)
        vlayout.addWidget(self.syncSourceBtn)
        vlayout.setContentsMargins(padding, 0, padding, int(LEFTBTN_WIDTH / 2))
        vlayout.setAlignment(Qt.AlignmentFlag.AlignCenter)
        vlayout.setSpacing(int(LEFTBTN_WIDTH / 2))
@@ -527,7 +514,6 @@ class BottomBar(Widget):
    paintmode_checkchanged = Signal()
    textblock_checkchanged = Signal()
    inpaint_btn_clicked = Signal()
    source_download_btn_clicked = Signal()

    def __init__(self, mainwindow: QMainWindow, *args, **kwargs) -> None:
        super().__init__(mainwindow, *args, **kwargs)
@@ -543,8 +529,6 @@ class BottomBar(Widget):
                                                self.tr('stop translation'))
        self.inpainterStatBtn = InpainterStatusButton()
        self.inpainterStatBtn.clicked.connect(self.inpaintBtnClicked)
        self.sourceStatusBtn = SourceDownloadStatusButton()
        self.sourceStatusBtn.clicked.connect(self.SourceDownloadBtnClicked)
        self.transTranspageBtn.hide()
        self.hlayout = QHBoxLayout(self)
        self.paintChecker = QCheckBox()
@@ -571,7 +555,6 @@ class BottomBar(Widget):
        self.hlayout.addWidget(self.translatorStatusbtn)
        self.hlayout.addWidget(self.transTranspageBtn)
        self.hlayout.addWidget(self.inpainterStatBtn)
        self.hlayout.addWidget(self.sourceStatusBtn)
        self.hlayout.addSpacerItem(QSpacerItem(0, 0, QSizePolicy.Expanding, QSizePolicy.Minimum))
        self.hlayout.addWidget(self.textlayerSlider)
        self.hlayout.addWidget(self.originalSlider)
@@ -596,6 +579,3 @@ class BottomBar(Widget):

    def inpaintBtnClicked(self):
        self.inpaint_btn_clicked.emit()
 No newline at end of file

    def SourceDownloadBtnClicked(self):
        self.source_download_btn_clicked.emit()
 No newline at end of file
Loading