Allow blurring images fixes #637
for people that don't accidentally read the entire comic when editing the metadata
This commit is contained in:
parent
5e6682566f
commit
888720b544
@ -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)
|
||||
|
@ -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,
|
||||
|
@ -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:
|
||||
|
@ -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()
|
||||
|
@ -107,20 +107,22 @@
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<widget class="QLabel" name="lblImage">
|
||||
<widget class="QGraphicsView" name="graphicsView">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>60</x>
|
||||
<y>50</y>
|
||||
<width>91</width>
|
||||
<height>61</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Double-click to expand</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
<property name="verticalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAlwaysOff</enum>
|
||||
</property>
|
||||
<property name="horizontalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAlwaysOff</enum>
|
||||
</property>
|
||||
<property name="sizeAdjustPolicy">
|
||||
<enum>QAbstractScrollArea::AdjustToContents</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
|
@ -91,9 +91,6 @@
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout_1">
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="cbPageType"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="lblPageType">
|
||||
<property name="text">
|
||||
@ -104,6 +101,9 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="cbPageType"/>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QCheckBox" name="chkDoublePage">
|
||||
<property name="text">
|
||||
@ -118,6 +118,13 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QCheckBox" name="cbxBlur">
|
||||
<property name="text">
|
||||
<string>Blur image (no spoilers)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
|
Loading…
Reference in New Issue
Block a user