From d98f815ce00ba56fd002dd6688718548242f1455 Mon Sep 17 00:00:00 2001 From: Timmy Welch Date: Sat, 27 Apr 2024 18:10:49 -0700 Subject: [PATCH] Add a button to attempt to identify a scanner page --- comictaggerlib/pagelisteditor.py | 16 ++++++++++++++++ comictaggerlib/taggerwindow.py | 3 +++ comictaggerlib/ui/pagelisteditor.ui | 17 ++++++++++++----- 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/comictaggerlib/pagelisteditor.py b/comictaggerlib/pagelisteditor.py index 890afa2..7ea50f9 100644 --- a/comictaggerlib/pagelisteditor.py +++ b/comictaggerlib/pagelisteditor.py @@ -110,6 +110,7 @@ class PageListEditor(QtWidgets.QWidget): self.leBookmark.editingFinished.connect(self.save_bookmark) 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.pre_move_row = -1 self.first_front_page: int | None = None @@ -135,6 +136,21 @@ class PageListEditor(QtWidgets.QWidget): action_item.setShortcut(shortcut) self.addAction(action_item) + def identify_scanner_page(self) -> None: + if self.comic_archive is None: + return + row = self.comic_archive.get_scanner_page_index() + if row is None: + return + page_dict: ImageMetadata = self.listWidget.item(row).data(QtCore.Qt.ItemDataRole.UserRole) + + page_dict["type"] = PageType.Deleted + + item = self.listWidget.item(row) + item.setData(QtCore.Qt.ItemDataRole.UserRole, page_dict) + item.setText(self.list_entry_text(page_dict)) + self.change_page() + 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/taggerwindow.py b/comictaggerlib/taggerwindow.py index 431f1ba..b9d3faa 100644 --- a/comictaggerlib/taggerwindow.py +++ b/comictaggerlib/taggerwindow.py @@ -835,6 +835,8 @@ class TaggerWindow(QtWidgets.QMainWindow): widget.setChecked(False) if isinstance(widget, QtWidgets.QTableWidget): widget.setRowCount(0) + if isinstance(widget, QtWidgets.QListWidget): + widget.clear() # recursive call on children for child in widget.children(): @@ -2139,6 +2141,7 @@ class TaggerWindow(QtWidgets.QMainWindow): def load_archive(self, comic_archive: ComicArchive) -> None: self.comic_archive = None self.clear_form() + self.metadata = GenericMetadata() if not os.path.exists(comic_archive.path): self.fileSelectionList.dirty_flag = False diff --git a/comictaggerlib/ui/pagelisteditor.ui b/comictaggerlib/ui/pagelisteditor.ui index 3aafa8f..e4b4da5 100644 --- a/comictaggerlib/ui/pagelisteditor.ui +++ b/comictaggerlib/ui/pagelisteditor.ui @@ -91,7 +91,10 @@ - + + + + Page Type: @@ -101,16 +104,20 @@ - - - - + &Double Page? + + + + Identify Scanner page + + +