Unknown player handling with extra event
This commit is contained in:
parent
ccd22fc3c3
commit
ca7ace68ba
|
@ -80,8 +80,9 @@ An input class has two functions which are called while a question is on
|
|||
display:
|
||||
|
||||
- `buzzersOpen(isOpen)` is called, when the question is first displayed,
|
||||
when the question is reopened after a false answer and when the question is
|
||||
closed after either a correct answer or no answer at all.
|
||||
when the question is reopened after a false answer, when the question is
|
||||
closed after either a correct answer or no answer at all or when a
|
||||
button for an unknown player was submitted.
|
||||
|
||||
- `playerGotQuestion(playerNo)` is called, whenever a player pressed
|
||||
their button *and* got the turn to answer. Note that no extra
|
||||
|
|
14
windows.py
14
windows.py
|
@ -127,14 +127,24 @@ class QuestionWindow(QtGui.QDialog):
|
|||
# restart music if question was not answered
|
||||
MusicBox.play_music("%s-%s" % (self.section, self.qnumber))
|
||||
|
||||
elif e.get_playerno() > len(self.players) and not self._inWindow:
|
||||
# unknown player! to not confuse certain devices we send a buttons open event
|
||||
self.buzzersOpen.emit(True)
|
||||
print("unknown player", e.get_playerno())
|
||||
|
||||
|
||||
return True
|
||||
else:
|
||||
if not self._windowSetup and e.type() == QtCore.QEvent.Show:
|
||||
ret = super(QuestionWindow, self).event(e)
|
||||
|
||||
# we want to do this after the window has focus for the first time
|
||||
if not self._windowSetup and e.type() == QtCore.QEvent.FocusIn:
|
||||
if not self.answers.is_answered():
|
||||
self.buzzersOpen.emit(True)
|
||||
self._windowSetup = True
|
||||
|
||||
return super(QuestionWindow, self).event(e)
|
||||
return ret
|
||||
|
||||
|
||||
def keyPressEvent(self, e):
|
||||
if e.key() == QtCore.Qt.Key_Escape:
|
||||
|
|
Loading…
Reference in New Issue