From 8fd919227745f7d12c37403605b024339b794e4a Mon Sep 17 00:00:00 2001 From: Tolkachev Aleksei Date: Wed, 7 Aug 2024 14:13:30 +0500 Subject: [PATCH] menu highlight in manual mode --- app/ui/dayu_widgets/push_button.py | 5 +++++ comic.py | 15 +++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/app/ui/dayu_widgets/push_button.py b/app/ui/dayu_widgets/push_button.py index 7cb6549..659d42a 100644 --- a/app/ui/dayu_widgets/push_button.py +++ b/app/ui/dayu_widgets/push_button.py @@ -137,3 +137,8 @@ def tiny(self): """Set MPushButton to tiny size""" self.set_dayu_size(dayu_theme.tiny) return self + + def default(self): + """Set MPushButton to DefaultType""" + self.set_dayu_type(MPushButton.DefaultType) + return self diff --git a/comic.py b/comic.py index 6a96ade..9bf3d1c 100644 --- a/comic.py +++ b/comic.py @@ -345,7 +345,8 @@ def block_detect(self, load_rects: bool = True): self.disable_hbutton_group() self.run_threaded(self.pipeline.detect_blocks, self.pipeline.on_blk_detect_complete, self.default_error_handler, self.on_manual_finished, load_rects) - + self.menu_highlight(0) + def clear_text_edits(self): self.current_text_block = None self.current_text_block_item = None @@ -366,6 +367,7 @@ def ocr(self): self.loading.setVisible(True) self.disable_hbutton_group() self.run_threaded(self.pipeline.OCR_image, None, self.default_error_handler, self.finish_ocr_translate) + self.menu_highlight(1) def translate_image(self): source_lang = self.s_combo.currentText() @@ -375,6 +377,7 @@ def translate_image(self): self.loading.setVisible(True) self.disable_hbutton_group() self.run_threaded(self.pipeline.translate_image, None, self.default_error_handler, self.finish_ocr_translate) + self.menu_highlight(2) def inpaint_and_set(self): if self.image_viewer.hasPhoto() and self.image_viewer.has_drawn_elements(): @@ -383,6 +386,7 @@ def inpaint_and_set(self): self.disable_hbutton_group() self.run_threaded(self.pipeline.inpaint, self.pipeline.inpaint_complete, self.default_error_handler, self.on_manual_finished) + self.menu_highlight(4) def load_images_threaded(self, file_paths: List[str]): self.file_handler.file_paths = file_paths @@ -438,6 +442,12 @@ def on_images_loaded(self, loaded_images: List[Tuple[str, np.ndarray]]): self.image_viewer.resetTransform() self.image_viewer.fitInView() + for button in self.hbutton_group.get_button_group().buttons(): + button.default() + + def menu_highlight(self, button_index: int): + self.hbutton_group.get_button_group().buttons()[button_index].success() + def update_image_cards(self): # Clear existing cards for i in reversed(range(self.image_card_layout.count())): @@ -549,7 +559,7 @@ def load_segmentation_points(self): self.image_viewer.draw_segmentation_lines(bboxes) self.enable_hbutton_group() - + self.menu_highlight(3) else: self.loading.setVisible(True) self.disable_hbutton_group() @@ -732,6 +742,7 @@ def render_text(self): self.run_threaded(manual_wrap, self.on_render_complete, self.default_error_handler, None, self, new_blocks, font_family, line_spacing, outline_width, bold, italic, underline, max_font_size, min_font_size) + self.menu_highlight(5) def handle_rectangle_change(self, new_rect: QtCore.QRectF): # Find the corresponding TextBlock in blk_list