Unverified Commit 960a0d40 authored by dmMaze's avatar dmMaze Committed by GitHub
Browse files

Merge pull request #638 from mercury233/patch-run-confirm

add confirm for the RUN button
parents ab5e8f16 6b6bd9d7
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -322,10 +322,14 @@ QMenu::item:selected {
}

QDialog {
    font-size: 7px;
    font-size: 14px;
    background-color: @widgetBackgroundColor;
}

QDialog QPushButton {
    padding: 5px 15px;
}

QGroupBox {
    background-color: @emptyContentBackgroundColor;
}
+6 −0
Original line number Diff line number Diff line
@@ -885,6 +885,12 @@
        <source>Failed to load project from</source>
        <translation>无法从所选路径加载项目</translation>
    </message>
    <message>
        <location filename="../ui/mainwindow.py" line="1081"/>
        <source>Are you sure to run image translation again?
All existing translation results will be cleared!</source>
        <translation>确定要重新运行吗现有翻译结果将被清空</translation>
    </message>
</context>
<context>
    <name>ModuleManager</name>
+4 −0
Original line number Diff line number Diff line
@@ -306,6 +306,10 @@ class ProjImgTrans:
    def is_empty(self):
        return len(self.pages) == 0

    @property
    def is_all_pages_no_text(self):
        return all([len(blklist) == 0 for blklist in self.pages.values()])

    @property
    def img_valid(self):
        return self.img_array is not None
+9 −3
Original line number Diff line number Diff line
@@ -278,7 +278,7 @@ class MainWindow(mainwindow_cls):
        module_manager.blktrans_pipeline_finished.connect(self.on_blktrans_finished)
        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_imgtrans_clicked.connect(self.run_imgtrans)
        self.bottomBar.inpaint_btn_clicked.connect(self.inpaintBtnClicked)
        self.bottomBar.translatorStatusbtn.clicked.connect(self.translatorStatusBtnPressed)
        self.bottomBar.transTranspageBtn.run_target.connect(self.on_transpagebtn_pressed)
@@ -1077,11 +1077,17 @@ class MainWindow(mainwindow_cls):
            self.set_display_lang(lang)

    def run_imgtrans(self):
        if not self.imgtrans_proj.is_all_pages_no_text:
            reply = QMessageBox.question(self, self.tr('Confirmation'),
                                         self.tr('Are you sure to run image translation again?\nAll existing translation results will be cleared!'),
                                         QMessageBox.Yes | QMessageBox.No, QMessageBox.No)
            if reply != QMessageBox.Yes:
                return
        self.on_run_imgtrans()

    def run_imgtrans_wo_textstyle_update(self):
        self._run_imgtrans_wo_textstyle_update = True
        self.on_run_imgtrans()
        self.run_imgtrans()

    def on_run_imgtrans(self):
        self.backup_blkstyles.clear()
@@ -1321,7 +1327,7 @@ class MainWindow(mainwindow_cls):
                shared.pbar['translate'] = tqdm(range(npages), desc="Translation")
            if pcfg.module.enable_inpaint:
                shared.pbar['inpaint'] = tqdm(range(npages), desc="Inpaint")
        self.run_imgtrans()
        self.on_run_imgtrans()

    def on_create_errdialog(self, error_msg: str, detail_traceback: str = '', exception_type: str = ''):
        try:
+1 −1
Original line number Diff line number Diff line
@@ -181,7 +181,7 @@ class LeftBar(Widget):
        self.runImgtransBtn = QPushButton()
        self.runImgtransBtn.setText(self.tr('RUN'))
        self.runImgtransBtn.setFixedSize(LEFTBTN_WIDTH, LEFTBTN_WIDTH)
        self.run_imgtrans = self.runImgtransBtn.clicked
        self.run_imgtrans_clicked = self.runImgtransBtn.clicked
        self.runImgtransBtn.setFixedSize(LEFTBTN_WIDTH, LEFTBTN_WIDTH)

        vlayout = QVBoxLayout(self)