Commit db0dd8b1 authored by Agrigor's avatar Agrigor

some minor changes regarding renaming and preperation for further programming of the question GUI

parent 4294f06f
...@@ -10,6 +10,12 @@ ...@@ -10,6 +10,12 @@
<height>900</height> <height>900</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle"> <property name="windowTitle">
<string>Hacker Jeopardy by Hacksaar</string> <string>Hacker Jeopardy by Hacksaar</string>
</property> </property>
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<class>Question</class> <class>Question</class>
<widget class="QDialog" name="Question"> <widget class="QDialog" name="Question">
<property name="windowModality"> <property name="windowModality">
<enum>Qt::NonModal</enum> <enum>Qt::ApplicationModal</enum>
</property> </property>
<property name="geometry"> <property name="geometry">
<rect> <rect>
......
...@@ -31,7 +31,7 @@ TIMEOUT = 30 ...@@ -31,7 +31,7 @@ TIMEOUT = 30
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class Comunication: class Communication:
def __init__(self, ip, port): def __init__(self, ip, port):
self.ip = ip self.ip = ip
self.port = port self.port = port
...@@ -61,7 +61,7 @@ class Player: ...@@ -61,7 +61,7 @@ class Player:
self.solved = [[0 for i in range(5)] for j in range(5)] self.solved = [[0 for i in range(5)] for j in range(5)]
class WaitForButton(QThread): class WaitForBuzzer(QThread):
def __init__(self, socket): def __init__(self, socket):
QThread.__init__(self) QThread.__init__(self)
self.socket = socket self.socket = socket
...@@ -361,28 +361,33 @@ class QuestionGUI(QDialog): ...@@ -361,28 +361,33 @@ class QuestionGUI(QDialog):
self.socket = socket self.socket = socket
self.UI_Main = UI_Main self.UI_Main = UI_Main
self.buttonNumber = 0 self.buttonNumber = 0
self.wait = 5
self.waitforbutton = WaitForButton(self.socket) self.waitForBuzzer = WaitForBuzzer(self.socket)
self.connect(self.waitforbutton, SIGNAL("finished(int)"), self.done) self.connect(self.waitForBuzzer, SIGNAL("finished(int)"), self.buzzerTriggered)
self.waitforbutton.start() self.waitForBuzzer.start()
self.time = TIMEOUT self.time = TIMEOUT
self.timer = QTimer(self) self.timer = QTimer(self)
self.timer.timeout.connect(self.timeHandler) self.timer.timeout.connect(self.timerFunction)
self.timer.start(1000) self.timer.start(1000)
self.UI_Question.show() self.UI_Question.show()
def done(self, buttonNumber): def buzzerTriggered(self, buttonNumber):
self.waitforbutton.exit() self.waitForBuzzer.exit()
self.timer.stop()
self.UI_Main.showMsg("Player " + str(buttonNumber) + " pressed the button") self.UI_Main.showMsg("Player " + str(buttonNumber) + " pressed the button")
def timeHandler(self): def timerFunction(self):
if self.time > 0: if self.time > 0 and self.waitForBuzzer.isRunning():
self.time -= 1 self.time -= 1
self.UI_Question.TimeLCD.display(self.time) self.UI_Question.TimeLCD.display(self.time)
else: elif self.waitForBuzzer.isFinished():
if self.wait > 0:
self.wait -= 1
else:
self.wait = 5
self.waitForBuzzer.start()
elif self.time == 0:
self.UI_Main.showMsg("No one pressed a button") self.UI_Main.showMsg("No one pressed a button")
def closeEvent(self, event): def closeEvent(self, event):
...@@ -393,11 +398,13 @@ class MainGUI(QMainWindow): ...@@ -393,11 +398,13 @@ class MainGUI(QMainWindow):
def __init__(self): def __init__(self):
QMainWindow.__init__(self) QMainWindow.__init__(self)
self.UI_Main = loadUi("GUIs/main.ui", self) self.UI_Main = loadUi("GUIs/main.ui", self)
self.socket = Comunication("", PORT) self.socket = Communication("", PORT)
self.players = [Player() for i in range(PLAYERS_MAX)] self.players = [Player() for i in range(PLAYERS_MAX)]
self.questionPaths = [] self.questionPaths = []
self.numberOfPlayers = 0 self.numberOfPlayers = 0
self.UI_Main.showMaximized()
self.categoryNames = [self.UI_Main.Cat_Name_1, self.categoryNames = [self.UI_Main.Cat_Name_1,
self.UI_Main.Cat_Name_2, self.UI_Main.Cat_Name_2,
self.UI_Main.Cat_Name_3, self.UI_Main.Cat_Name_3,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment