diff --git a/comictaggerlib/coverimagewidget.py b/comictaggerlib/coverimagewidget.py index 5746b82..5d5d117 100644 --- a/comictaggerlib/coverimagewidget.py +++ b/comictaggerlib/coverimagewidget.py @@ -69,6 +69,7 @@ class CoverImageWidget(QtWidgets.QWidget): mode: int, cache_folder: pathlib.Path | None, talker: ComicTalker | None, + blur: bool = False, expand_on_click: bool = True, ) -> None: super().__init__(parent) @@ -86,6 +87,8 @@ class CoverImageWidget(QtWidgets.QWidget): self.mode: int = mode self.page_loader: PageLoader | None = None self.showControls = True + self.blur = blur + self.scene = QtWidgets.QGraphicsScene(parent=self) self.current_pixmap = QtGui.QPixmap() @@ -107,9 +110,10 @@ class CoverImageWidget(QtWidgets.QWidget): self.btnRight.clicked.connect(self.increment_image) self.image_fetch_complete.connect(self.cover_remote_fetch_complete) if expand_on_click: - clickable(self.lblImage).connect(self.show_popup) + clickable(self.graphicsView).connect(self.show_popup) else: - self.lblImage.setToolTip("") + self.graphicsView.setToolTip("") + self.graphicsView.setScene(self.scene) self.update_content() @@ -271,28 +275,36 @@ class CoverImageWidget(QtWidgets.QWidget): def set_display_pixmap(self) -> None: """The deltas let us know what the new width and height of the label will be""" - new_h = self.frame.height() new_w = self.frame.width() + new_h = self.frame.height() frame_w = self.frame.width() frame_h = self.frame.height() - new_h -= 4 - new_w -= 4 + new_h -= 8 + new_w -= 8 new_h = max(new_h, 0) new_w = max(new_w, 0) # scale the pixmap to fit in the frame scaled_pixmap = self.current_pixmap.scaled( - new_w, new_h, QtCore.Qt.AspectRatioMode.KeepAspectRatio, QtCore.Qt.SmoothTransformation + new_w, new_h, QtCore.Qt.AspectRatioMode.KeepAspectRatio, QtCore.Qt.TransformationMode.SmoothTransformation ) - self.lblImage.setPixmap(scaled_pixmap) + self.scene.clear() + qpix = self.scene.addPixmap(scaled_pixmap) + assert qpix + if self.blur: + blur = QtWidgets.QGraphicsBlurEffect(parent=self) + blur.setBlurHints(QtWidgets.QGraphicsBlurEffect.BlurHint.PerformanceHint) + blur.setBlurRadius(30) + qpix.setGraphicsEffect(blur) # move and resize the label to be centered in the fame img_w = scaled_pixmap.width() img_h = scaled_pixmap.height() - self.lblImage.resize(img_w, img_h) - self.lblImage.move(int((frame_w - img_w) / 2), int((frame_h - img_h) / 2)) + self.scene.setSceneRect(0, 0, img_w, img_h) + self.graphicsView.resize(img_w + 2, img_h + 2) + self.graphicsView.move(int((frame_w - img_w) / 2), int((frame_h - img_h) / 2)) def show_popup(self) -> None: ImagePopup(self, self.current_pixmap) diff --git a/comictaggerlib/ctsettings/file.py b/comictaggerlib/ctsettings/file.py index 7999bdb..48ab38d 100644 --- a/comictaggerlib/ctsettings/file.py +++ b/comictaggerlib/ctsettings/file.py @@ -13,6 +13,7 @@ from comictaggerlib.defaults import DEFAULT_REPLACEMENTS, Replacement, Replaceme def general(parser: settngs.Manager) -> None: # General Settings parser.add_setting("check_for_new_version", default=False, cmdline=False) + parser.add_setting("blur", default=False, cmdline=False) parser.add_setting( "--prompt-on-save", default=True, diff --git a/comictaggerlib/pagelisteditor.py b/comictaggerlib/pagelisteditor.py index 7ea50f9..6aad51e 100644 --- a/comictaggerlib/pagelisteditor.py +++ b/comictaggerlib/pagelisteditor.py @@ -87,6 +87,7 @@ class PageListEditor(QtWidgets.QWidget): gridlayout.setContentsMargins(0, 0, 0, 0) self.pageWidget.showControls = False + self.blur = False self.reset_page() # Add the entries to the page type combobox @@ -107,6 +108,7 @@ class PageListEditor(QtWidgets.QWidget): item_move_events(self.listWidget).connect(self.item_move_event) self.cbPageType.activated.connect(self.change_page_type) self.chkDoublePage.clicked.connect(self.toggle_double_page) + self.cbxBlur.clicked.connect(self._toggle_blur) self.leBookmark.editingFinished.connect(self.save_bookmark) self.btnUp.clicked.connect(self.move_current_up) self.btnDown.clicked.connect(self.move_current_down) @@ -118,6 +120,16 @@ class PageListEditor(QtWidgets.QWidget): self.pages_list: list[ImageMetadata] = [] self.data_styles: list[str] = [] + def set_blur(self, blur: bool) -> None: + self.pageWidget.blur = self.blur = blur + self.cbxBlur.setChecked(blur) + self.pageWidget.update_content() + + def _toggle_blur(self) -> None: + self.pageWidget.blur = self.blur = not self.blur + self.cbxBlur.setChecked(self.blur) + self.pageWidget.update_content() + def reset_page(self) -> None: self.pageWidget.clear() self.cbPageType.setEnabled(False) @@ -126,6 +138,7 @@ class PageListEditor(QtWidgets.QWidget): self.listWidget.clear() self.comic_archive = None self.pages_list = [] + self.cbxBlur.setChecked(self.blur) def add_page_type_item(self, text: str, user_data: str, shortcut: str, show_shortcut: bool = True) -> None: if show_shortcut: @@ -340,6 +353,7 @@ class PageListEditor(QtWidgets.QWidget): self.listWidget.setFocus() def set_data(self, comic_archive: ComicArchive, pages_list: list[ImageMetadata]) -> None: + self.cbxBlur.setChecked(self.blur) self.comic_archive = comic_archive self.pages_list = pages_list if pages_list: diff --git a/comictaggerlib/taggerwindow.py b/comictaggerlib/taggerwindow.py index 1d39f3a..b4d45a8 100644 --- a/comictaggerlib/taggerwindow.py +++ b/comictaggerlib/taggerwindow.py @@ -288,6 +288,13 @@ class TaggerWindow(QtWidgets.QMainWindow): self.page_list_editor.listOrderChanged.connect(self.page_list_order_changed) self.tabWidget.currentChanged.connect(self.tab_changed) + self.page_list_editor.set_blur(self.config[0].General__blur) + + def _sync_blur(*args: Any) -> None: + self.config[0].General__blur = self.page_list_editor.blur + + self.page_list_editor.cbxBlur.clicked.connect(_sync_blur) + self.update_metadata_style_tweaks() self.show() diff --git a/comictaggerlib/ui/coverimagewidget.ui b/comictaggerlib/ui/coverimagewidget.ui index c896b7e..4f02957 100644 --- a/comictaggerlib/ui/coverimagewidget.ui +++ b/comictaggerlib/ui/coverimagewidget.ui @@ -107,20 +107,22 @@ QFrame::Raised - + - 60 - 50 - 91 - 61 Double-click to expand - - TextLabel + + Qt::ScrollBarAlwaysOff + + + Qt::ScrollBarAlwaysOff + + + QAbstractScrollArea::AdjustToContents diff --git a/comictaggerlib/ui/pagelisteditor.ui b/comictaggerlib/ui/pagelisteditor.ui index e4b4da5..ba4a318 100644 --- a/comictaggerlib/ui/pagelisteditor.ui +++ b/comictaggerlib/ui/pagelisteditor.ui @@ -91,9 +91,6 @@ - - - @@ -104,6 +101,9 @@ + + + @@ -118,6 +118,13 @@ + + + + Blur image (no spoilers) + + +