From ca7ace68ba0a1a1a9f80f23f399d12f751867a64 Mon Sep 17 00:00:00 2001 From: Sebastian Lohff Date: Thu, 19 Dec 2013 18:07:29 +0100 Subject: [PATCH] Unknown player handling with extra event --- Readme.md | 5 +++-- windows.py | 14 ++++++++++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/Readme.md b/Readme.md index ac7c911..f22c543 100644 --- a/Readme.md +++ b/Readme.md @@ -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 diff --git a/windows.py b/windows.py index c9a6283..e4e747e 100644 --- a/windows.py +++ b/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: