APVQuiz  1
A multiplayer multithreaded quizzing application
gamewindow.h
Go to the documentation of this file.
1 
9 #ifndef GAMEWINDOW_H
10 #define GAMEWINDOW_H
11 
12 #include <QDialog>
13 #include <QNetworkAccessManager>
14 #include <QtNetwork>
15 #include <QTimer>
16 #include <QTcpSocket>
17 #include <QtWebSockets/QtWebSockets>
18 #include "Player.h"
19 namespace Ui {
20 class GameWindow;
21 }
22 
28 class GameWindow : public QDialog
29 {
30  Q_OBJECT
31 
32 
33 public:
41  explicit GameWindow(Player usr, QString sub, QString ip, QWidget *parent = 0);
42 
48  ~GameWindow();
49 
50 
51  /* Documentation for each of the function can be obtained in the
52  * corresponding mainwindow.cpp. The header contains all declaration.
53  */
54 
55 private slots:
56  void on_windowLoaded();
57 
58  void updateTimer();
59 
60  void on_option1PushButton_clicked();
61 
62  void webSocketConnected();
63 
64  void webSocketDisconnected();
65 
66  void onWebSocketRead(QString message);
67 
68  void on_option2PushButton_clicked();
69 
70  void on_option3PushButton_clicked();
71 
72  void on_option4PushButton_clicked();
73 
74 
75 
76 private :
77  void disableOptionButtons();
78 
79  void enableOptionButtons();
80 
81  void updateOpponentsBoard(QString player1Name,QString player1Score,QString player2Name,QString player2Score);
82 
83  void setupQuestionAnswer(QString question, QString option1, QString option2, QString option3, QString option4, QString ownScore);
84 
85  void sendChoiceToServer(bool isCorrect, QString timeOfAnswer);
86 
87  void checkSelectedChoice(int choice);
88 
89  void handleButtonClicked(int buttonNumber);
90 
91  void reject();
92 protected:
93 
94  void showEvent(QShowEvent *ev);
95 
96 signals:
97  void window_loaded();
98 
99  void changeQuestionTextEdit(const QString &s);
100 
101 private:
102  Ui::GameWindow *ui;
103  Player plr;
104  QString subject;
105  QTimer *timer;
106  QTime *starttime;
107  int currentQuestionNumber;
108  int correctAnswer;
109  QString ipServer;
110  QWebSocket webSocket;
111  bool finalScoreRecieved;
112 };
113 
114 #endif // GAMEWINDOW_H
Definition: contribute.h:16
GameWindow(Player usr, QString sub, QString ip, QWidget *parent=0)
Constructor for gamewindow.
Definition: gamewindow.cpp:27
void showEvent(QShowEvent *ev)
Overridden showEvent function.
Definition: gamewindow.cpp:293
~GameWindow()
Destructor for game window.
Definition: gamewindow.cpp:66
Gamewindow class.
Definition: gamewindow.h:28
Player class.
Definition: Player.h:19