|
|
|
@ -135,6 +135,8 @@ class EditAnswersWindow(QtGui.QDialog):
|
|
|
|
|
self._players = players
|
|
|
|
|
self._answers = answers
|
|
|
|
|
self._nobody = not answers.got_answered()
|
|
|
|
|
self._dj_points = answers.get_dj_points()
|
|
|
|
|
self._in_window = False
|
|
|
|
|
if self._answers:
|
|
|
|
|
self._tries = copy.copy(self._answers.get_tries())
|
|
|
|
|
else:
|
|
|
|
@ -145,7 +147,8 @@ class EditAnswersWindow(QtGui.QDialog):
|
|
|
|
|
self.installEventFilter(KeyGrabber((QtCore.Qt.Key.Key_Left, QtCore.Qt.Key.Key_Right), self))
|
|
|
|
|
|
|
|
|
|
def get_new_answers(self):
|
|
|
|
|
qa = QuestionAnswers(self._answers.section, self._answers.qnumber)
|
|
|
|
|
qa = QuestionAnswers(self._answers.section, self._answers.qnumber, dj_points=self._dj_points)
|
|
|
|
|
|
|
|
|
|
rightPlayer = None
|
|
|
|
|
for player, correct in self._tries:
|
|
|
|
|
if correct:
|
|
|
|
@ -171,7 +174,7 @@ class EditAnswersWindow(QtGui.QDialog):
|
|
|
|
|
self._resetAllButtons()
|
|
|
|
|
self.layout.addLayout(self.answerlayout)
|
|
|
|
|
|
|
|
|
|
self.xlabel = QtGui.QLabel("+/- right/wrong, d delete, a add, arrows change player")
|
|
|
|
|
self.xlabel = QtGui.QLabel("+/- right/wrong, d delete, a add, arrows change player\ne edit double jeopardy")
|
|
|
|
|
self.xlabel.setStyleSheet("QLabel { font-size: 15px; }")
|
|
|
|
|
self.layout.addWidget(self.xlabel)
|
|
|
|
|
|
|
|
|
@ -180,6 +183,15 @@ class EditAnswersWindow(QtGui.QDialog):
|
|
|
|
|
def keyPressEvent(self, e):
|
|
|
|
|
if e.key() == QtCore.Qt.Key_Escape:
|
|
|
|
|
self.close()
|
|
|
|
|
elif e.key() == QtCore.Qt.Key_E:
|
|
|
|
|
# edit double jeopardy
|
|
|
|
|
if self._dj_points is not None and len(self._tries) > 0 and not self._in_window:
|
|
|
|
|
self._in_window = True
|
|
|
|
|
dwin = DoubleJeopardyWindow(self._players, self._answers.qnumber*100, self._tries[0][0], current_points=self._dj_points, parent=self)
|
|
|
|
|
dwin.exec_()
|
|
|
|
|
self._dj_points = dwin.get_chosen_points()
|
|
|
|
|
self._tries[0] = (dwin.get_player(), self._tries[0][1])
|
|
|
|
|
self._in_window = False
|
|
|
|
|
else:
|
|
|
|
|
currFocus = self._getCurrFocus()
|
|
|
|
|
if currFocus is None and e.key() != QtCore.Qt.Key_A:
|
|
|
|
@ -247,15 +259,18 @@ class EditAnswersWindow(QtGui.QDialog):
|
|
|
|
|
f = self.answerlayout.takeAt(0)
|
|
|
|
|
|
|
|
|
|
# add buttons
|
|
|
|
|
first = True
|
|
|
|
|
for player, correct in self._tries:
|
|
|
|
|
self._addAnswerButton(player, correct)
|
|
|
|
|
self._addAnswerButton(player, correct, first)
|
|
|
|
|
first = False
|
|
|
|
|
|
|
|
|
|
# add the nobody button
|
|
|
|
|
self._addAnswerButton(Player("nobody", nobodyColor), self._nobody)
|
|
|
|
|
|
|
|
|
|
def _addAnswerButton(self, player, correct=False):
|
|
|
|
|
def _addAnswerButton(self, player, correct=False, first=False):
|
|
|
|
|
prefix = "+" if correct else "-"
|
|
|
|
|
btn = QtGui.QPushButton("\n%s%s\n" % (prefix, player.name), self)
|
|
|
|
|
dj = " (D)" if first and self._dj_points is not None else ""
|
|
|
|
|
btn = QtGui.QPushButton("\n%s%s%s\n" % (prefix, player.name, dj), self)
|
|
|
|
|
btn.setStyleSheet("QPushButton { background-color: %s; color: white; font-size: 20px; border: none; }" % (player.color.name(),))
|
|
|
|
|
btn.installEventFilter(KeyGrabber((QtCore.Qt.Key.Key_Left, QtCore.Qt.Key.Key_Right), self))
|
|
|
|
|
self.answerlayout.addWidget(btn)
|
|
|
|
|