diff --git a/photobooth/gui/PyQt5Gui.py b/photobooth/gui/PyQt5Gui.py index 8015887..750789c 100644 --- a/photobooth/gui/PyQt5Gui.py +++ b/photobooth/gui/PyQt5Gui.py @@ -137,7 +137,8 @@ class PyQt5Gui(Gui): elif isinstance(state, PictureState): 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, lambda : self.postprocessPicture(state.picture)) @@ -411,36 +412,3 @@ class PyQt5CountdownMessage(QtWidgets.QFrame): self.updateProgressBar() 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() - diff --git a/photobooth/gui/Qt5Gui/Frames.py b/photobooth/gui/Qt5Gui/Frames.py index cefcd7f..1451932 100644 --- a/photobooth/gui/Qt5Gui/Frames.py +++ b/photobooth/gui/Qt5Gui/Frames.py @@ -135,6 +135,34 @@ class PoseMessage(QtWidgets.QFrame): 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): # With spinning wait clock, inspired by # https://wiki.python.org/moin/PyQt/A%20full%20widget%20waiting%20indicator