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 @@
<height>900</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Hacker Jeopardy by Hacksaar</string>
</property>
......
......@@ -3,7 +3,7 @@
<class>Question</class>
<widget class="QDialog" name="Question">
<property name="windowModality">
<enum>Qt::NonModal</enum>
<enum>Qt::ApplicationModal</enum>
</property>
<property name="geometry">
<rect>
......
......@@ -31,7 +31,7 @@ TIMEOUT = 30
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class Comunication:
class Communication:
def __init__(self, ip, port):
self.ip = ip
self.port = port
......@@ -61,7 +61,7 @@ class Player:
self.solved = [[0 for i in range(5)] for j in range(5)]
class WaitForButton(QThread):
class WaitForBuzzer(QThread):
def __init__(self, socket):
QThread.__init__(self)
self.socket = socket
......@@ -361,28 +361,33 @@ class QuestionGUI(QDialog):
self.socket = socket
self.UI_Main = UI_Main
self.buttonNumber = 0
self.wait = 5
self.waitforbutton = WaitForButton(self.socket)
self.connect(self.waitforbutton, SIGNAL("finished(int)"), self.done)
self.waitforbutton.start()
self.waitForBuzzer = WaitForBuzzer(self.socket)
self.connect(self.waitForBuzzer, SIGNAL("finished(int)"), self.buzzerTriggered)
self.waitForBuzzer.start()
self.time = TIMEOUT
self.timer = QTimer(self)
self.timer.timeout.connect(self.timeHandler)
self.timer.timeout.connect(self.timerFunction)
self.timer.start(1000)
self.UI_Question.show()
def done(self, buttonNumber):
self.waitforbutton.exit()
self.timer.stop()
def buzzerTriggered(self, buttonNumber):
self.waitForBuzzer.exit()
self.UI_Main.showMsg("Player " + str(buttonNumber) + " pressed the button")
def timeHandler(self):
if self.time > 0:
def timerFunction(self):
if self.time > 0 and self.waitForBuzzer.isRunning():
self.time -= 1
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")
def closeEvent(self, event):
......@@ -393,11 +398,13 @@ class MainGUI(QMainWindow):
def __init__(self):
QMainWindow.__init__(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.questionPaths = []
self.numberOfPlayers = 0
self.UI_Main.showMaximized()
self.categoryNames = [self.UI_Main.Cat_Name_1,
self.UI_Main.Cat_Name_2,
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