From e96cb8ad150be6481eea8688e32bf177c5db37bc Mon Sep 17 00:00:00 2001 From: Timmy Welch Date: Sat, 27 Jul 2024 16:39:34 -0700 Subject: [PATCH] Add button to autodetect double pages A page is marked as a double page if it's as least as wide as tall. Closes: #578 Co-authored-by: Sven Hesse --- comictaggerlib/pagelisteditor.py | 13 ++++++++++++- comictaggerlib/ui/pagelisteditor.ui | 17 ++++++++++++----- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/comictaggerlib/pagelisteditor.py b/comictaggerlib/pagelisteditor.py index 07064c6..b95294d 100644 --- a/comictaggerlib/pagelisteditor.py +++ b/comictaggerlib/pagelisteditor.py @@ -21,7 +21,7 @@ import logging from PyQt5 import QtCore, QtWidgets, uic from comicapi.comicarchive import ComicArchive, tags -from comicapi.genericmetadata import ImageMetadata, PageType +from comicapi.genericmetadata import GenericMetadata, ImageMetadata, PageType from comictaggerlib.coverimagewidget import CoverImageWidget from comictaggerlib.ui import ui_path from comictaggerlib.ui.qtutils import enable_widget @@ -113,6 +113,7 @@ class PageListEditor(QtWidgets.QWidget): self.btnUp.clicked.connect(self.move_current_up) self.btnDown.clicked.connect(self.move_current_down) self.btnIdentifyScannerPage.clicked.connect(self.identify_scanner_page) + self.btnIdentifyDoublePage.clicked.connect(self.identify_double_page) self.pre_move_row = -1 self.first_front_page: int | None = None @@ -164,6 +165,16 @@ class PageListEditor(QtWidgets.QWidget): item.setText(self.list_entry_text(page_dict)) self.change_page() + def identify_double_page(self) -> None: + if self.comic_archive is None: + return + md = GenericMetadata(pages=self.get_page_list()) + double_pages = [x.get("double_page", False) for x in md.pages] + self.comic_archive.apply_archive_info_to_metadata(md, True, True) + self.set_data(self.comic_archive, pages_list=md.pages) + if double_pages != [x.get("double_page", False) for x in md.pages]: + self.modified.emit() + def select_page_type_item(self, idx: int) -> None: if self.cbPageType.isEnabled() and self.listWidget.count() > 0: self.cbPageType.setCurrentIndex(idx) diff --git a/comictaggerlib/ui/pagelisteditor.ui b/comictaggerlib/ui/pagelisteditor.ui index 1038225..65040c9 100644 --- a/comictaggerlib/ui/pagelisteditor.ui +++ b/comictaggerlib/ui/pagelisteditor.ui @@ -6,7 +6,7 @@ 0 0 - 527 + 600 323 @@ -114,17 +114,24 @@ - + + + + Blur image (no spoilers) + + + + Identify Scanner page - - + + - Blur image (no spoilers) + Identify Double Page