PictureMessage moved to Frames
This commit is contained in:
@@ -137,7 +137,8 @@ class PyQt5Gui(Gui):
|
|||||||
|
|
||||||
elif isinstance(state, PictureState):
|
elif isinstance(state, PictureState):
|
||||||
img = ImageQt.ImageQt(state.picture)
|
img = ImageQt.ImageQt(state.picture)
|
||||||
self._p.setCentralWidget(PyQt5PictureMessage(img))
|
# self._p.setCentralWidget(PyQt5PictureMessage(img))
|
||||||
|
self._p.setCentralWidget(Frames.PictureMessage(img))
|
||||||
QtCore.QTimer.singleShot(cfg.getInt('Photobooth', 'display_time') * 1000,
|
QtCore.QTimer.singleShot(cfg.getInt('Photobooth', 'display_time') * 1000,
|
||||||
lambda : self.postprocessPicture(state.picture))
|
lambda : self.postprocessPicture(state.picture))
|
||||||
|
|
||||||
@@ -411,36 +412,3 @@ class PyQt5CountdownMessage(QtWidgets.QFrame):
|
|||||||
self.updateProgressBar()
|
self.updateProgressBar()
|
||||||
self.update()
|
self.update()
|
||||||
|
|
||||||
|
|
||||||
class PyQt5PictureMessage(QtWidgets.QFrame):
|
|
||||||
|
|
||||||
def __init__(self, picture):
|
|
||||||
|
|
||||||
super().__init__()
|
|
||||||
|
|
||||||
self._picture = picture
|
|
||||||
|
|
||||||
self.initFrame()
|
|
||||||
|
|
||||||
|
|
||||||
def initFrame(self):
|
|
||||||
|
|
||||||
self.setStyleSheet('background-color: black; color: white')
|
|
||||||
|
|
||||||
|
|
||||||
def paintEvent(self, event):
|
|
||||||
|
|
||||||
painter = QtGui.QPainter(self)
|
|
||||||
|
|
||||||
if isinstance(self._picture, QtGui.QImage):
|
|
||||||
pix = QtGui.QPixmap.fromImage(self._picture)
|
|
||||||
else:
|
|
||||||
pix = QtGui.QPixmap(self._picture)
|
|
||||||
pix = pix.scaled(self.rect().size(), QtCore.Qt.KeepAspectRatio, QtCore.Qt.SmoothTransformation)
|
|
||||||
|
|
||||||
origin = ( (self.rect().width() - pix.width()) // 2,
|
|
||||||
(self.rect().height() - pix.height()) // 2 )
|
|
||||||
painter.drawPixmap(QtCore.QPoint(*origin), pix)
|
|
||||||
|
|
||||||
painter.end()
|
|
||||||
|
|
||||||
|
|||||||
@@ -135,6 +135,34 @@ class PoseMessage(QtWidgets.QFrame):
|
|||||||
painter.end()
|
painter.end()
|
||||||
|
|
||||||
|
|
||||||
|
class PictureMessage(QtWidgets.QFrame):
|
||||||
|
|
||||||
|
def __init__(self, picture):
|
||||||
|
|
||||||
|
super().__init__()
|
||||||
|
|
||||||
|
self._picture = picture
|
||||||
|
|
||||||
|
def _paintPicture(self, painter):
|
||||||
|
|
||||||
|
if isinstance(self._picture, QtGui.QImage):
|
||||||
|
pix = QtGui.QPixmap.fromImage(self._picture)
|
||||||
|
else:
|
||||||
|
pix = QtGui.QPixmap(self._picture)
|
||||||
|
pix = pix.scaled(self.rect().size(), QtCore.Qt.KeepAspectRatio,
|
||||||
|
QtCore.Qt.SmoothTransformation)
|
||||||
|
|
||||||
|
origin = ((self.rect().width() - pix.width()) // 2,
|
||||||
|
(self.rect().height() - pix.height()) // 2)
|
||||||
|
painter.drawPixmap(QtCore.QPoint(*origin), pix)
|
||||||
|
|
||||||
|
def paintEvent(self, event):
|
||||||
|
|
||||||
|
painter = QtGui.QPainter(self)
|
||||||
|
self._paintPicture(painter)
|
||||||
|
painter.end()
|
||||||
|
|
||||||
|
|
||||||
class WaitMessage(QtWidgets.QFrame):
|
class WaitMessage(QtWidgets.QFrame):
|
||||||
# With spinning wait clock, inspired by
|
# With spinning wait clock, inspired by
|
||||||
# https://wiki.python.org/moin/PyQt/A%20full%20widget%20waiting%20indicator
|
# https://wiki.python.org/moin/PyQt/A%20full%20widget%20waiting%20indicator
|
||||||
|
|||||||
Reference in New Issue
Block a user