Skip to content

Commit

Permalink
menu highlight in manual mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Tolkachev Aleksei committed Aug 30, 2024
1 parent 084deed commit 8fd9192
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
5 changes: 5 additions & 0 deletions app/ui/dayu_widgets/push_button.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
15 changes: 13 additions & 2 deletions comic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Expand All @@ -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():
Expand All @@ -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
Expand Down Expand Up @@ -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())):
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 8fd9192

Please sign in to comment.