WaitMessage moved to Frames module
This commit is contained in:
@@ -129,7 +129,8 @@ class PyQt5Gui(Gui):
|
|||||||
self._p.setCentralWidget(PyQt5PoseMessage())
|
self._p.setCentralWidget(PyQt5PoseMessage())
|
||||||
|
|
||||||
elif isinstance(state, AssembleState):
|
elif isinstance(state, AssembleState):
|
||||||
self._p.setCentralWidget(PyQt5WaitMessage('Processing picture...'))
|
self._p.setCentralWidget(Frames.WaitMessage('Processing picture...'))
|
||||||
|
# self._p.setCentralWidget(PyQt5WaitMessage('Processing picture...'))
|
||||||
|
|
||||||
elif isinstance(state, PictureState):
|
elif isinstance(state, PictureState):
|
||||||
img = ImageQt.ImageQt(state.picture)
|
img = ImageQt.ImageQt(state.picture)
|
||||||
@@ -198,7 +199,8 @@ class PyQt5Gui(Gui):
|
|||||||
|
|
||||||
self._lastState = self.showStartPhotobooth
|
self._lastState = self.showStartPhotobooth
|
||||||
self._conn.send('start')
|
self._conn.send('start')
|
||||||
self._p.setCentralWidget(PyQt5WaitMessage('Starting the photobooth...'))
|
# self._p.setCentralWidget(PyQt5WaitMessage('Starting the photobooth...'))
|
||||||
|
self._p.setCentralWidget(Frames.WaitMessage('Starting the photobooth...'))
|
||||||
if cfg.getBool('Gui', 'hide_cursor'):
|
if cfg.getBool('Gui', 'hide_cursor'):
|
||||||
QtWidgets.QApplication.setOverrideCursor(QtCore.Qt.BlankCursor)
|
QtWidgets.QApplication.setOverrideCursor(QtCore.Qt.BlankCursor)
|
||||||
|
|
||||||
@@ -311,70 +313,6 @@ class PyQt5MainWindow(QtWidgets.QMainWindow):
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
class PyQt5WaitMessage(QtWidgets.QFrame):
|
|
||||||
# With spinning wait clock, inspired by
|
|
||||||
# https://wiki.python.org/moin/PyQt/A%20full%20widget%20waiting%20indicator
|
|
||||||
|
|
||||||
def __init__(self, message):
|
|
||||||
|
|
||||||
super().__init__()
|
|
||||||
|
|
||||||
self._message = message
|
|
||||||
|
|
||||||
self.initFrame()
|
|
||||||
|
|
||||||
|
|
||||||
def initFrame(self):
|
|
||||||
|
|
||||||
self.setStyleSheet('background-color: black; color: white;')
|
|
||||||
|
|
||||||
|
|
||||||
def paintEvent(self, event):
|
|
||||||
|
|
||||||
painter = QtGui.QPainter(self)
|
|
||||||
|
|
||||||
f = self.font()
|
|
||||||
f.setPixelSize(self.height() / 8)
|
|
||||||
painter.setFont(f)
|
|
||||||
|
|
||||||
rect = QtCore.QRect(0, self.height() * 3 / 5, self.width(), self.height() * 3 / 10)
|
|
||||||
painter.drawText(rect, QtCore.Qt.AlignCenter, self._message)
|
|
||||||
|
|
||||||
painter.setRenderHint(QtGui.QPainter.Antialiasing)
|
|
||||||
painter.setPen(QtGui.QPen(QtCore.Qt.NoPen))
|
|
||||||
|
|
||||||
center = (self.width() / 2, self.height() / 2)
|
|
||||||
|
|
||||||
dots = 8
|
|
||||||
pos = self._counter % dots
|
|
||||||
|
|
||||||
for i in range(dots):
|
|
||||||
|
|
||||||
distance = (pos - i) % dots
|
|
||||||
color = (distance + 1) / (dots + 1) * 255
|
|
||||||
painter.setBrush(QtGui.QBrush(QtGui.QColor(color, color, color)))
|
|
||||||
|
|
||||||
painter.drawEllipse(
|
|
||||||
center[0] + 180 / dots * math.cos(2 * math.pi * i / dots) - 20,
|
|
||||||
center[1] + 180 / dots * math.sin(2 * math.pi * i / dots) - 20,
|
|
||||||
15, 15)
|
|
||||||
|
|
||||||
painter.end()
|
|
||||||
|
|
||||||
|
|
||||||
def showEvent(self, event):
|
|
||||||
|
|
||||||
self._counter = 0
|
|
||||||
self.startTimer(100)
|
|
||||||
|
|
||||||
|
|
||||||
def timerEvent(self, event):
|
|
||||||
|
|
||||||
self._counter += 1
|
|
||||||
self.update()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class PyQt5IdleMessage(QtWidgets.QFrame):
|
class PyQt5IdleMessage(QtWidgets.QFrame):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|||||||
@@ -3,6 +3,10 @@
|
|||||||
|
|
||||||
from os.path import expanduser
|
from os.path import expanduser
|
||||||
|
|
||||||
|
import math
|
||||||
|
|
||||||
|
from PyQt5 import QtCore
|
||||||
|
from PyQt5 import QtGui
|
||||||
from PyQt5 import QtWidgets
|
from PyQt5 import QtWidgets
|
||||||
|
|
||||||
from .. import modules
|
from .. import modules
|
||||||
@@ -36,6 +40,65 @@ class Start(QtWidgets.QFrame):
|
|||||||
self.setLayout(lay)
|
self.setLayout(lay)
|
||||||
|
|
||||||
|
|
||||||
|
class WaitMessage(QtWidgets.QFrame):
|
||||||
|
# With spinning wait clock, inspired by
|
||||||
|
# https://wiki.python.org/moin/PyQt/A%20full%20widget%20waiting%20indicator
|
||||||
|
|
||||||
|
def __init__(self, message):
|
||||||
|
|
||||||
|
super().__init__()
|
||||||
|
|
||||||
|
self._message = message
|
||||||
|
|
||||||
|
def showEvent(self, event):
|
||||||
|
|
||||||
|
self._counter = 0
|
||||||
|
self.startTimer(100)
|
||||||
|
|
||||||
|
def timerEvent(self, event):
|
||||||
|
|
||||||
|
self._counter += 1
|
||||||
|
self.update()
|
||||||
|
|
||||||
|
def _paintMessage(self, painter):
|
||||||
|
|
||||||
|
f = self.font()
|
||||||
|
f.setPixelSize(self.height() / 8)
|
||||||
|
painter.setFont(f)
|
||||||
|
|
||||||
|
rect = QtCore.QRect(0, self.height() * 3 / 5,
|
||||||
|
self.width(), self.height() * 3 / 10)
|
||||||
|
painter.drawText(rect, QtCore.Qt.AlignCenter, self._message)
|
||||||
|
|
||||||
|
def _paintClock(self, painter):
|
||||||
|
|
||||||
|
painter.setRenderHint(QtGui.QPainter.Antialiasing)
|
||||||
|
painter.setPen(QtGui.QPen(QtCore.Qt.NoPen))
|
||||||
|
|
||||||
|
center = (self.width() / 2, self.height() / 2)
|
||||||
|
|
||||||
|
dots = 8
|
||||||
|
pos = self._counter % dots
|
||||||
|
|
||||||
|
for i in range(dots):
|
||||||
|
|
||||||
|
distance = (pos - i) % dots
|
||||||
|
color = (distance + 1) / (dots + 1) * 255
|
||||||
|
painter.setBrush(QtGui.QBrush(QtGui.QColor(color, color, color)))
|
||||||
|
|
||||||
|
painter.drawEllipse(
|
||||||
|
center[0] + 180 / dots * math.cos(2 * math.pi * i / dots) - 20,
|
||||||
|
center[1] + 180 / dots * math.sin(2 * math.pi * i / dots) - 20,
|
||||||
|
15, 15)
|
||||||
|
|
||||||
|
def paintEvent(self, event):
|
||||||
|
|
||||||
|
painter = QtGui.QPainter(self)
|
||||||
|
self._paintMessage(painter)
|
||||||
|
self._paintClock(painter)
|
||||||
|
painter.end()
|
||||||
|
|
||||||
|
|
||||||
class Settings(QtWidgets.QFrame):
|
class Settings(QtWidgets.QFrame):
|
||||||
|
|
||||||
def __init__(self, config, reload_action, cancel_action, restart_action):
|
def __init__(self, config, reload_action, cancel_action, restart_action):
|
||||||
@@ -235,9 +298,9 @@ class Settings(QtWidgets.QFrame):
|
|||||||
lay_dist.addWidget(min_dist_y)
|
lay_dist.addWidget(min_dist_y)
|
||||||
|
|
||||||
def file_dialog():
|
def file_dialog():
|
||||||
basedir.setText(QtWidgets.QFileDialog.getExistingDirectory(self,
|
dialog = QtWidgets.QFileDialog.getExistingDirectory
|
||||||
'Select directory', expanduser('~'),
|
basedir.setText(dialog(self, 'Select directory', expanduser('~'),
|
||||||
QtWidgets.QFileDialog.ShowDirsOnly))
|
QtWidgets.QFileDialog.ShowDirsOnly))
|
||||||
|
|
||||||
file_button = QtWidgets.QPushButton('Select directory')
|
file_button = QtWidgets.QPushButton('Select directory')
|
||||||
file_button.clicked.connect(file_dialog)
|
file_button.clicked.connect(file_dialog)
|
||||||
|
|||||||
Reference in New Issue
Block a user