Unknown player handling with extra event

This commit is contained in:
Sebastian Lohff 2013-12-19 18:07:29 +01:00
parent ccd22fc3c3
commit ca7ace68ba
2 changed files with 15 additions and 4 deletions

View File

@ -80,8 +80,9 @@ An input class has two functions which are called while a question is on
display: display:
- `buzzersOpen(isOpen)` is called, when the question is first displayed, - `buzzersOpen(isOpen)` is called, when the question is first displayed,
when the question is reopened after a false answer and when the question is when the question is reopened after a false answer, when the question is
closed after either a correct answer or no answer at all. 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 - `playerGotQuestion(playerNo)` is called, whenever a player pressed
their button *and* got the turn to answer. Note that no extra their button *and* got the turn to answer. Note that no extra

View File

@ -127,14 +127,24 @@ class QuestionWindow(QtGui.QDialog):
# restart music if question was not answered # restart music if question was not answered
MusicBox.play_music("%s-%s" % (self.section, self.qnumber)) 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 return True
else: 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(): if not self.answers.is_answered():
self.buzzersOpen.emit(True) self.buzzersOpen.emit(True)
self._windowSetup = True self._windowSetup = True
return super(QuestionWindow, self).event(e) return ret
def keyPressEvent(self, e): def keyPressEvent(self, e):
if e.key() == QtCore.Qt.Key_Escape: if e.key() == QtCore.Qt.Key_Escape: