aboutsummaryrefslogtreecommitdiff
path: root/src/gui/preview_win.py
diff options
context:
space:
mode:
authortassaron2026-01-11 14:29:58 -0500
committertassaron2026-01-11 14:29:58 -0500
commit669756b391d26661cf2e2a97a304e73343ef6655 (patch)
tree9cf2d4858c209bdab9f44d5c7f95c2a30b37f7a6 /src/gui/preview_win.py
parent9d45f7f1a986aaa5d3c084c7ae747442b94a61b1 (diff)
update to Qt 6 and Pillow 12
and yeah, I accidentally ran black on the codebase. I don't want to spend more free time fixing that. All of these changes are simple renames or removals, nothing too major.
Diffstat (limited to 'src/gui/preview_win.py')
-rw-r--r--src/gui/preview_win.py45
1 files changed, 21 insertions, 24 deletions
diff --git a/src/gui/preview_win.py b/src/gui/preview_win.py
index d910456..f52f8a3 100644
--- a/src/gui/preview_win.py
+++ b/src/gui/preview_win.py
@@ -1,18 +1,20 @@
-from PyQt5 import QtCore, QtGui, QtWidgets
+from PyQt6 import QtCore, QtGui, QtWidgets
import logging
-log = logging.getLogger('AVP.Gui.PreviewWindow')
+log = logging.getLogger("AVP.Gui.PreviewWindow")
class PreviewWindow(QtWidgets.QLabel):
- '''
- Paints the preview QLabel in MainWindow and maintains the aspect ratio
- when the window is resized.
- '''
+ """
+ Paints the preview QLabel in MainWindow and maintains the aspect ratio
+ when the window is resized.
+ """
+
def __init__(self, parent, img):
super().__init__()
self.parent = parent
- self.setFrameStyle(QtWidgets.QFrame.StyledPanel)
+ # FIXME
+ # self.setFrameStyle(QtWidgets.QFrame.StyledPanel)
self.pixmap = QtGui.QPixmap(img)
def paintEvent(self, event):
@@ -21,12 +23,13 @@ class PreviewWindow(QtWidgets.QLabel):
point = QtCore.QPoint(0, 0)
scaledPix = self.pixmap.scaled(
size,
- QtCore.Qt.KeepAspectRatio,
- transformMode=QtCore.Qt.SmoothTransformation)
+ QtCore.Qt.AspectRatioMode.KeepAspectRatio,
+ transformMode=QtCore.Qt.TransformationMode.SmoothTransformation,
+ )
# start painting the label from left upper corner
- point.setX(int((size.width() - scaledPix.width())/2))
- point.setY(int((size.height() - scaledPix.height())/2))
+ point.setX(int((size.width() - scaledPix.width()) / 2))
+ point.setY(int((size.height() - scaledPix.height()) / 2))
painter.drawPixmap(point, scaledPix)
def changePixmap(self, img):
@@ -40,22 +43,16 @@ class PreviewWindow(QtWidgets.QLabel):
i = self.parent.listWidget_componentList.currentRow()
if i >= 0:
component = self.parent.core.selectedComponents[i]
- if not hasattr(component, 'previewClickEvent'):
+ if not hasattr(component, "previewClickEvent"):
return
- pos = (event.x(), event.y())
+ qpoint = event.position().toPoint()
+ pos = (qpoint.x(), qpoint.y())
size = (self.width(), self.height())
butt = event.button()
- log.info('Click event for #%s: %s button %s' % (
- i, pos, butt))
- component.previewClickEvent(
- pos, size, butt
- )
+ log.info("Click event for #%s: %s button %s" % (i, pos, butt))
+ component.previewClickEvent(pos, size, butt)
@QtCore.pyqtSlot(str)
def threadError(self, msg):
- self.parent.showMessage(
- msg=msg,
- icon='Critical',
- parent=self
- )
- log.info('%', repr(self.parent))
+ self.parent.showMessage(msg=msg, icon="Critical", parent=self)
+ log.info("%", repr(self.parent))