|
@@ -1,8 +1,12 @@
|
|
1
|
+// RAN 2015-06-26 - Added Zulu Zone label
|
|
2
|
+// - Removed the onclick functions for the buttons that are no longer used
|
|
3
|
+
|
1
|
4
|
#include "mainwindow.h"
|
2
|
5
|
#include "ui_mainwindow.h"
|
3
|
6
|
#include "secondwindow.cpp"
|
4
|
7
|
|
5
|
8
|
#include <QDebug>
|
|
9
|
+#include <QTimer>
|
6
|
10
|
#include <QtCore/qmath.h>
|
7
|
11
|
#include <QMessageBox>
|
8
|
12
|
#include "functions.h"
|
|
@@ -38,7 +42,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
38
|
42
|
|
39
|
43
|
// We need to know whenever the second window is closed to show the
|
40
|
44
|
// main window, or to hide when the second one is showed
|
41
|
|
- connect(window, SIGNAL(cerrado(bool)), this, SLOT(mostrar(bool)));
|
|
45
|
+ connect(window, SIGNAL(closeIt(bool)), this, SLOT(showMW(bool)));
|
42
|
46
|
|
43
|
47
|
if(!dice1.load(":/images/resources/d1.png") || !dice2.load(":/images/resources/d1.png")){
|
44
|
48
|
qDebug() << "Error1 Loading image";
|
|
@@ -52,9 +56,8 @@ MainWindow::~MainWindow()
|
52
|
56
|
delete ui;
|
53
|
57
|
}
|
54
|
58
|
|
55
|
|
-//This function show the main window and delete all the items created on the closed one or hide the mainwindow
|
56
|
|
-void MainWindow::mostrar(bool si){
|
57
|
|
- if (si==true){
|
|
59
|
+void MainWindow::showMW(bool doShow){
|
|
60
|
+ if (doShow){
|
58
|
61
|
show();
|
59
|
62
|
|
60
|
63
|
// Deleting pointers and point them to NULL
|
|
@@ -76,14 +79,13 @@ void MainWindow::mostrar(bool si){
|
76
|
79
|
|
77
|
80
|
// Create the new window and connecting it again with the signal
|
78
|
81
|
window = new secondwindow;
|
79
|
|
- connect(window, SIGNAL(cerrado(bool)), this, SLOT(mostrar(bool)));
|
|
82
|
+ connect(window, SIGNAL(closeIt(bool)), this, SLOT(showMW(bool)));
|
80
|
83
|
}
|
81
|
84
|
else hide();
|
82
|
85
|
}
|
83
|
86
|
|
84
|
|
-//It is a slot that reads what item of the combo box was selected and save it
|
85
|
|
-//into a member
|
86
|
|
-void MainWindow::whatOption(QString str){
|
|
87
|
+
|
|
88
|
+void MainWindow::setOption(QString str){
|
87
|
89
|
option = str;
|
88
|
90
|
}
|
89
|
91
|
|
|
@@ -97,212 +99,8 @@ void MainWindow::clearLines(){
|
97
|
99
|
score1 = score2 = 0;
|
98
|
100
|
}
|
99
|
101
|
|
100
|
|
-//It forces the input 1 to be valid
|
101
|
|
-void MainWindow::RPSnormalizer1(QString str){
|
102
|
|
- //For every character in the string only allow
|
103
|
|
- //the character 'R' for rock, 'P' for paper and
|
104
|
|
- //'S' for scissors. Delete all the other characters
|
105
|
|
- //different from this three, and if is 'r', 'p' or 's'
|
106
|
|
- //make it uppercase.
|
107
|
|
- for (int i = 0; i< str.size(); i++){
|
108
|
|
- if (str[i] == 'r'){
|
109
|
|
- str[i] = 'R';
|
110
|
|
- }
|
111
|
|
- else if (str[i] == 'p'){
|
112
|
|
- str[i] = 'P';
|
113
|
|
- }
|
114
|
|
- else if (str[i] == 's'){
|
115
|
|
- str[i] = 'S';
|
116
|
|
- }
|
117
|
|
-
|
118
|
|
- else if (str[i] == 'R' || str[i] == 'P' ||
|
119
|
|
- str[i] == 'S');//then its ok, do nothing
|
120
|
|
- else{
|
121
|
|
- str = str.mid(0,i).append(str.mid(i+1));
|
122
|
|
- }
|
123
|
|
- }
|
124
|
|
-
|
125
|
|
- line[0]->setText(str);
|
126
|
|
-}
|
127
|
|
-
|
128
|
|
-//It forces the input 2 to be valid
|
129
|
|
-void MainWindow::RPSnormalizer2(QString str){
|
130
|
|
- for (int i = 0; i< str.size(); i++){
|
131
|
|
- if (str[i] == 'r'){
|
132
|
|
- str[i] = 'R';
|
133
|
|
- }
|
134
|
|
- else if (str[i] == 'p'){
|
135
|
|
- str[i] = 'P';
|
136
|
|
- }
|
137
|
|
- else if (str[i] == 's'){
|
138
|
|
- str[i] = 'S';
|
139
|
|
- }
|
140
|
|
- else if (str[i] == 'R' || str[i] == 'P' ||
|
141
|
|
- str[i] == 'S');//then its ok, do nothing
|
142
|
|
- else{
|
143
|
|
- str = str.mid(0,i).append(str.mid(i+1));
|
144
|
|
- }
|
145
|
|
- }
|
146
|
|
-
|
147
|
|
- line[1]->setText(str);
|
148
|
|
-}
|
149
|
|
-
|
150
|
|
-//It forces the input 3 to be valid
|
151
|
|
-void MainWindow::RPSnormalizer3(QString str){
|
152
|
|
- //Verify that the string do not contains other thing than
|
153
|
|
- //numbers
|
154
|
|
- for (int i = 0; i< str.size(); i++){
|
155
|
|
- if (!str[i].isDigit()){
|
156
|
|
- str = str.mid(0,i).append(str.mid(i+1));
|
157
|
|
- }
|
158
|
|
- }
|
159
|
|
-
|
160
|
|
- //Left zeros do not count, delete them
|
161
|
|
- while (str[0] == '0'){
|
162
|
|
- str = str.mid(1);
|
163
|
|
- }
|
164
|
|
-
|
165
|
|
- //If the player exagerates the number of games to win
|
166
|
|
- //change the string to the maximum number allowed
|
167
|
|
- if (str.toInt() > 150){
|
168
|
|
- str = "150";
|
169
|
|
- }
|
170
|
|
-
|
171
|
|
- line[2]->setText(str);
|
172
|
|
-}
|
173
|
|
-
|
174
|
|
-//It forces the input to be valid
|
175
|
|
-void MainWindow::CheckWnormalizer(QString str){
|
176
|
|
- //Just allow numbers
|
177
|
|
- for (int i = 0; i< str.size(); i++){
|
178
|
|
- if (!str[i].isDigit()){
|
179
|
|
- str = str.mid(0,i).append(str.mid(i+1));
|
180
|
|
- }
|
181
|
|
- }
|
182
|
|
-
|
183
|
|
- //Zeros on the left side do not count (delete them)
|
184
|
|
- while (str[0] == '0'){
|
185
|
|
- str = str.mid(1);
|
186
|
|
- }
|
187
|
|
-
|
188
|
|
- //The maximum is 999,999,999
|
189
|
|
- if (str.toDouble() > 999999999){
|
190
|
|
- str = "999999999";
|
191
|
|
- }
|
192
|
|
-
|
193
|
|
- line[0]->setText(str);
|
194
|
|
-}
|
195
|
|
-
|
196
|
|
-
|
197
|
|
-
|
198
|
|
-//It forces the first input of Zulu to be valid
|
199
|
|
-void MainWindow::Zulunormalizer1(QString str){
|
200
|
|
- //Just allow numbers to be written
|
201
|
|
- for (int i = 0; i< str.size(); i++){
|
202
|
|
- if (!str[i].isDigit()){
|
203
|
|
- str = str.mid(0,i).append(str.mid(i+1));
|
204
|
|
- }
|
205
|
|
- }
|
206
|
|
-
|
207
|
|
- //The maximum here is 2359, so force it to be the
|
208
|
|
- //maximum when the user write a larger number
|
209
|
|
- if (str.toInt() > 2359){
|
210
|
|
- str = "2359";
|
211
|
|
- }
|
212
|
|
-
|
213
|
|
- line[0]->setText(str);
|
214
|
|
-}
|
215
|
|
-
|
216
|
|
-//It forces the second input of Zulu to be valid
|
217
|
|
-void MainWindow::Zulunormalizer2(QString str){
|
218
|
|
- //Just allow one character to be written
|
219
|
|
- if (str.size() > 1){
|
220
|
|
- str = str[1];
|
221
|
|
- }
|
222
|
|
-
|
223
|
|
- //If that only character is 'e', 'c', 'm' or 'p'
|
224
|
|
- //the uppercase it
|
225
|
|
- if (str[0] == 'e' || str[0] == 'c' ||
|
226
|
|
- str[0] == 'm' || str[0] == 'p'){
|
227
|
|
- str = str[0].toUpper();
|
228
|
|
- }
|
229
|
|
- //If we get here is because the character is not
|
230
|
|
- //the lowercase letters allowed... so if they are
|
231
|
|
- //not the uppercase letters that we admit we have
|
232
|
|
- //to delete it.
|
233
|
|
- else if (str[0] != 'E' || str[0] != 'C' ||
|
234
|
|
- str[0] != 'M' || str[0] != 'P'){
|
235
|
|
- str = "";
|
236
|
|
- }
|
237
|
|
-
|
238
|
|
- line[1]->setText(str);
|
239
|
|
-}
|
240
|
102
|
|
241
|
|
-//It forces the first input of APFT to be valid
|
242
|
|
-void MainWindow::APFTnormalizer1(QString str){
|
243
|
|
- //Just admit numbers, delete the other type of
|
244
|
|
- //characters
|
245
|
|
- for (int i = 0; i< str.size(); i++){
|
246
|
|
- if (!str[i].isDigit()){
|
247
|
|
- str = str.mid(0,i).append(str.mid(i+1));
|
248
|
|
- }
|
249
|
|
- }
|
250
|
|
-
|
251
|
|
- //Left zeros are not valid
|
252
|
|
- while (str[0] == '0'){
|
253
|
|
- str = str.mid(1);
|
254
|
|
- }
|
255
|
|
-
|
256
|
|
- line[0]->setText(str);
|
257
|
|
-}
|
258
|
|
-
|
259
|
|
-//It forces the second input of APFT to be valid
|
260
|
|
-void MainWindow::APFTnormalizer2(QString str){
|
261
|
|
- //Just allow the numbers to be written
|
262
|
|
- for (int i = 0; i< str.size(); i++){
|
263
|
|
- if (!str[i].isDigit()){
|
264
|
|
- str = str.mid(0,i).append(str.mid(i+1));
|
265
|
|
- }
|
266
|
|
- }
|
267
|
|
-
|
268
|
|
- //Left-hand zeros? Delete them
|
269
|
|
- while (str[0] == '0'){
|
270
|
|
- str = str.mid(1);
|
271
|
|
- }
|
272
|
|
-
|
273
|
|
- line[1]->setText(str);
|
274
|
|
-}
|
275
|
|
-
|
276
|
|
-//It forces the third input of APFT to be valid
|
277
|
|
-void MainWindow::APFTnormalizer3(QString str){
|
278
|
|
- //Allow just numbers on the string only if the
|
279
|
|
- //character is not in the position 2
|
280
|
|
- for (int i = 0; i< str.size(); i++){
|
281
|
|
- if (!str[i].isDigit() && i != 2){
|
282
|
|
- str = str.mid(0,i).append(str.mid(i+1));
|
283
|
|
- }
|
284
|
|
- }
|
285
|
|
-
|
286
|
|
- //Then if there is a character in the position 2
|
287
|
|
- //and it is not ':', then add it between the
|
288
|
|
- //position 1 and 3
|
289
|
|
- if (str.size() > 2 && str[2] != ':'){
|
290
|
|
- while (str.size()>2 && !str[2].isDigit()){
|
291
|
|
- str = str.mid(0,2).append(str.mid(3));
|
292
|
|
- }
|
293
|
|
- str = str.mid(0, 2).append(':').append(str.mid(2));
|
294
|
|
- }
|
295
|
|
- //If the size exceeds 5, then take the first five
|
296
|
|
- //so then we will have the format mm:ss
|
297
|
|
- if (str.size() > 5){
|
298
|
|
- str = str.mid(0, 5);
|
299
|
|
- }
|
300
|
|
-
|
301
|
|
- line[2]->setText(str);
|
302
|
|
-}
|
303
|
|
-
|
304
|
|
-//Checks which version of sort is selected and call it
|
305
|
|
-void MainWindow::sorts(){
|
|
103
|
+void MainWindow::callOneOfTheSorts(){
|
306
|
104
|
QString a = line[0]->text();
|
307
|
105
|
QString b = line[1]->text();
|
308
|
106
|
QString c = line[2]->text();
|
|
@@ -331,16 +129,12 @@ void MainWindow::sorts(){
|
331
|
129
|
}
|
332
|
130
|
|
333
|
131
|
|
|
132
|
+void MainWindow::callOneOfTheRPS(){
|
334
|
133
|
|
|
134
|
+ QString p1 = this->cmbPlayer01->currentText();
|
|
135
|
+ QString p2 = this->cmbPlayer02->currentText();
|
335
|
136
|
|
336
|
|
-//Checks which version of RPS is selected and call it
|
337
|
|
-void MainWindow::RPSs(){
|
338
|
|
-
|
339
|
|
- QString p1 = line[0]->text();
|
340
|
|
- QString p2 = line[1]->text();
|
341
|
|
- QString gamesToWin = line[2]->text();
|
342
|
|
-
|
343
|
|
- if (p1.length() * p2.length() * gamesToWin.length() == 0) {
|
|
137
|
+ if (p1.length() * p2.length() == 0) {
|
344
|
138
|
QMessageBox::warning(this, "Alert",
|
345
|
139
|
"Please provide a play for both players and the number of games to win");
|
346
|
140
|
return;
|
|
@@ -348,50 +142,100 @@ void MainWindow::RPSs(){
|
348
|
142
|
|
349
|
143
|
int winnerNum;
|
350
|
144
|
if (option == "Version Alpha")
|
351
|
|
- winnerNum = RPSAlpha(p1.toStdString()[0], p2.toStdString()[0], score1, score2);
|
|
145
|
+ winnerNum = RPSDelta(p1.toStdString()[0], p2.toStdString()[0]);
|
352
|
146
|
else if (option == "Version Beta")
|
353
|
|
- winnerNum = RPSBeta(p1.toStdString()[0], p2.toStdString()[0], score1, score2);
|
|
147
|
+ winnerNum = RPSBeta(p1.toStdString()[0], p2.toStdString()[0]);
|
354
|
148
|
else if (option == "Version Gamma")
|
355
|
|
- winnerNum = RPSGamma(p1.toStdString()[0], p2.toStdString()[0], score1, score2);
|
|
149
|
+ winnerNum = RPSGamma(p1.toStdString()[0], p2.toStdString()[0]);
|
356
|
150
|
else
|
357
|
|
- winnerNum = RPSDelta(p1.toStdString()[0], p2.toStdString()[0], score1, score2);
|
|
151
|
+ winnerNum = RPSDelta(p1.toStdString()[0], p2.toStdString()[0]);
|
358
|
152
|
|
359
|
153
|
QString st;
|
360
|
154
|
|
|
155
|
+
|
361
|
156
|
switch(winnerNum) {
|
362
|
|
- case 1: st = "Player 1"; break;
|
363
|
|
- case 2: st = "Player 2"; break;
|
364
|
|
- case 0: st = "Tie"; break;
|
365
|
|
- default: st = "Error";
|
|
157
|
+ case 1: st = "Player 1"; break;
|
|
158
|
+ case 2: st = "Player 2"; break;
|
|
159
|
+ case 0: st = "Tie"; break;
|
|
160
|
+ default: st = "Error";
|
366
|
161
|
}
|
367
|
162
|
|
368
|
|
- line[3]->setText(st);
|
|
163
|
+ line[0]->setText(st);
|
369
|
164
|
|
370
|
|
- line[4]->setText(QString::number(score1) + " to " + QString::number(score2));
|
|
165
|
+}
|
371
|
166
|
|
372
|
|
- if (score1 == gamesToWin.toInt() || score2 == gamesToWin.toInt() ) {
|
373
|
|
- QMessageBox::warning(this, "Alert",
|
374
|
|
- "Game won by " + st + "!!!");
|
375
|
|
- score1 = score2 = 0;
|
|
167
|
+
|
|
168
|
+void MainWindow::paintDice() {
|
|
169
|
+ this->timerCounter++;
|
|
170
|
+ int a, b;
|
|
171
|
+ a = rand()%6;
|
|
172
|
+ b = rand()%6;
|
|
173
|
+ label[3]->setPixmap(QPixmap::fromImage(diceImages[a]));
|
|
174
|
+ label[4]->setPixmap(QPixmap::fromImage(diceImages[b]));
|
|
175
|
+ if (this->timerCounter == 10) {
|
|
176
|
+ aTimer->stop();
|
|
177
|
+ diceFinal01 = a;
|
|
178
|
+ diceFinal02 = b;
|
|
179
|
+ if (option == "Version Alpha")
|
|
180
|
+ diceBeta();
|
|
181
|
+ else if (option == "Version Beta")
|
|
182
|
+ diceGamma();
|
|
183
|
+ else if (option == "Version Gamma")
|
|
184
|
+ diceAlpha();
|
|
185
|
+ else
|
|
186
|
+ diceAlpha();
|
376
|
187
|
}
|
|
188
|
+}
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+void MainWindow::callOneOfTheDices(){
|
|
192
|
+
|
|
193
|
+ for (int i = 1; i <= 6; i++)
|
|
194
|
+ this->diceImages.push_back(QImage(":/images/resources/d" + QString::number(i) + ".png"));
|
|
195
|
+
|
|
196
|
+ aTimer = new QTimer;
|
|
197
|
+ aTimer->setInterval(100);
|
|
198
|
+ aTimer->setSingleShot(false);
|
|
199
|
+ aTimer->start();
|
|
200
|
+ timerCounter = 0;
|
|
201
|
+ QObject::connect(aTimer,&QTimer::timeout, this, &MainWindow::paintDice); //[&](){ birth(w, juana, avelardo, piolin);});
|
|
202
|
+
|
377
|
203
|
|
378
|
204
|
}
|
379
|
205
|
|
380
|
|
-//Checks which version of dice is selected and call it
|
381
|
|
-void MainWindow::dices(){
|
382
|
|
- if (option == "Version Alpha")
|
383
|
|
- diceAlpha();
|
384
|
|
- else if (option == "Version Beta")
|
385
|
|
- diceBeta();
|
386
|
|
- else if (option == "Version Gamma")
|
387
|
|
- diceGamma();
|
388
|
|
- else
|
389
|
|
- diceDelta();
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+//========================================================
|
|
210
|
+// Functions for the dice roller
|
|
211
|
+//========================================================
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+void MainWindow::diceAlpha(){
|
|
215
|
+ int total = diceFinal01 + diceFinal02 + 2;
|
|
216
|
+ line[0]->setText(QString::number(total));
|
|
217
|
+}
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+void MainWindow::diceBeta(){
|
|
221
|
+ int total = diceFinal01 + diceFinal01 + 2;
|
|
222
|
+ line[0]->setText(QString::number(total));
|
|
223
|
+}
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+void MainWindow::diceGamma(){
|
|
227
|
+ int total = diceFinal01 - diceFinal02;
|
|
228
|
+ line[0]->setText(QString::number(total));
|
|
229
|
+}
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+void MainWindow::diceDelta(){
|
|
233
|
+ int total = diceFinal01 + diceFinal02;
|
|
234
|
+ line[0]->setText(QString::number(total));
|
390
|
235
|
}
|
391
|
236
|
|
392
|
237
|
|
393
|
|
-//Checks which version of check-writer is selected and call it
|
394
|
|
-void MainWindow::checkWs(){
|
|
238
|
+void MainWindow::callOneOfTheChecks(){
|
395
|
239
|
unsigned int qty;
|
396
|
240
|
if (!validateCheckQty(line[0]->text(),qty)) {
|
397
|
241
|
QMessageBox::warning(this, "Alert",
|
|
@@ -408,8 +252,7 @@ void MainWindow::checkWs(){
|
408
|
252
|
line[1]->setText( checkWDelta(qty) );
|
409
|
253
|
}
|
410
|
254
|
|
411
|
|
-//Checks which version of zulu is selected and call it
|
412
|
|
-void MainWindow::zulus(){
|
|
255
|
+void MainWindow::callOneOfTheZulus(){
|
413
|
256
|
QString zuluTime = line[0]->text();
|
414
|
257
|
QString zuluZone = line[1]->text();
|
415
|
258
|
int hours, minutes;
|
|
@@ -417,7 +260,7 @@ void MainWindow::zulus(){
|
417
|
260
|
if (!validZuluTime(zuluTime, zuluZone, hours, minutes) ) {
|
418
|
261
|
|
419
|
262
|
QMessageBox::warning(this, "Alert",
|
420
|
|
- "Either Zulu Time or Zone is not valid");
|
|
263
|
+ "Either Zulu Time or Zone is not valid.");
|
421
|
264
|
line[2]->setText("Error");
|
422
|
265
|
return;
|
423
|
266
|
}
|
|
@@ -432,23 +275,7 @@ void MainWindow::zulus(){
|
432
|
275
|
|
433
|
276
|
}
|
434
|
277
|
|
435
|
|
-//Checks which version of APFT is selected and call it
|
436
|
|
-void MainWindow::APFTs(){
|
437
|
|
- if (option == "Version Alpha"){
|
438
|
|
- APFTAlpha();
|
439
|
|
- }
|
440
|
|
- else if (option == "Version Beta"){
|
441
|
|
- APFTBeta();
|
442
|
|
- }
|
443
|
|
- else if (option == "Version Gamma"){
|
444
|
|
- APFTGamma();
|
445
|
|
- }
|
446
|
|
- else{
|
447
|
|
- APFTDelta();
|
448
|
|
- }
|
449
|
|
-}
|
450
|
278
|
|
451
|
|
-//Here is what happend when Sort-button is clicked
|
452
|
279
|
void MainWindow::on_SortsButton_clicked()
|
453
|
280
|
{
|
454
|
281
|
//Create a new QComboBox and add the items in it
|
|
@@ -495,19 +322,18 @@ void MainWindow::on_SortsButton_clicked()
|
495
|
322
|
|
496
|
323
|
//Here we connect the signals of the widgets generated
|
497
|
324
|
//by code to their respective functions
|
498
|
|
- connect(method, SIGNAL(currentIndexChanged(QString)), this, SLOT(whatOption(QString)));
|
499
|
|
- connect(button[0], SIGNAL(clicked()), this, SLOT(sorts()));
|
|
325
|
+ connect(method, SIGNAL(currentIndexChanged(QString)), this, SLOT(setOption(QString)));
|
|
326
|
+ connect(button[0], SIGNAL(clicked()), this, SLOT(callOneOfTheSorts()));
|
500
|
327
|
connect(button[1], SIGNAL(clicked()), this, SLOT(clearLines()));
|
501
|
328
|
|
502
|
329
|
//Now that we have set our new window, we hide the main-window
|
503
|
330
|
//and show the new one. The new-window has a signal that
|
504
|
331
|
//notify when it was closed so we can shor the main-window
|
505
|
332
|
window->setLayout(layout);
|
506
|
|
- mostrar(false);
|
|
333
|
+ showMW(false);
|
507
|
334
|
window->show();
|
508
|
335
|
}
|
509
|
336
|
|
510
|
|
-//Here is what happend when Dice-button is clicked
|
511
|
337
|
void MainWindow::on_DiceButton_clicked()
|
512
|
338
|
{
|
513
|
339
|
//Create a new QComboBox and add the items in it
|
|
@@ -551,18 +377,17 @@ void MainWindow::on_DiceButton_clicked()
|
551
|
377
|
|
552
|
378
|
//Here we connect the signals of the widgets generated
|
553
|
379
|
//by code to their respective functions
|
554
|
|
- connect(method, SIGNAL(currentIndexChanged(QString)), this, SLOT(whatOption(QString)));
|
555
|
|
- connect(button[0], SIGNAL(clicked()), this, SLOT(dices()));
|
|
380
|
+ connect(method, SIGNAL(currentIndexChanged(QString)), this, SLOT(setOption(QString)));
|
|
381
|
+ connect(button[0], SIGNAL(clicked()), this, SLOT(callOneOfTheDices()));
|
556
|
382
|
|
557
|
383
|
//Now that we have set our new window, we hide the main-window
|
558
|
384
|
//and show the new one. The new-window has a signal that
|
559
|
385
|
//notify when it was closed so we can shor the main-window
|
560
|
386
|
window->setLayout(layout);
|
561
|
|
- mostrar(false);
|
|
387
|
+ showMW(false);
|
562
|
388
|
window->show();
|
563
|
389
|
}
|
564
|
390
|
|
565
|
|
-//Here is what happend when RPS-button is clicked
|
566
|
391
|
void MainWindow::on_RPSButton_clicked()
|
567
|
392
|
{
|
568
|
393
|
//Create a new QComboBox and add the items in it
|
|
@@ -573,117 +398,52 @@ void MainWindow::on_RPSButton_clicked()
|
573
|
398
|
method->addItem("Version Delta");
|
574
|
399
|
option = "Version Alpha"; //Default option is alpha
|
575
|
400
|
|
576
|
|
- //We create a new layout and insert the comboBox to it
|
577
|
|
- layout = new QGridLayout;
|
578
|
|
- layout->addWidget(method, 0, 0, 1, -1);
|
|
401
|
+ cmbPlayer01 = new QComboBox;
|
|
402
|
+ cmbPlayer02 = new QComboBox;
|
|
403
|
+ cmbPlayer01->addItem("rock"); cmbPlayer02->addItem("rock");
|
|
404
|
+ cmbPlayer01->addItem("paper"); cmbPlayer02->addItem("paper");
|
|
405
|
+ cmbPlayer01->addItem("scisors"); cmbPlayer02->addItem("scisors");
|
|
406
|
+
|
579
|
407
|
|
580
|
408
|
//The buttons needed here are the 'play' and 'clear' buttons
|
581
|
409
|
button[0] = new QPushButton("Play");
|
582
|
|
- button[1] = new QPushButton("Clear");
|
583
|
|
-
|
584
|
|
- //3 inputs and 1 output
|
585
|
|
- for (int i = 0; i<4; i++){
|
586
|
|
- line[i] = new QLineEdit;
|
587
|
|
- }
|
588
|
410
|
|
|
411
|
+ line[0] = new QLineEdit;
|
589
|
412
|
//The user is not able to write on the output line
|
590
|
|
- line[3]->setEnabled(false);
|
|
413
|
+ line[0]->setEnabled(false);
|
591
|
414
|
|
592
|
415
|
//Labels to let the user understand the app
|
593
|
416
|
label[0] = new QLabel("Player 1's moves");
|
594
|
417
|
label[1] = new QLabel("Player 2's moves");
|
595
|
|
- label[2] = new QLabel("How many games to win:");
|
596
|
|
- label[3] = new QLabel("Winner:");
|
597
|
|
- label[4] = new QLabel("Tournament:");
|
598
|
|
- //lines for score
|
599
|
|
- line[4] = new QLineEdit;
|
600
|
|
- line[4]->setEnabled(false);
|
601
|
|
-
|
602
|
|
- //Here we insert the widgets on the layout
|
603
|
|
- layout->addWidget(label[0], 1, 0);
|
604
|
|
- layout->addWidget(line[0], 2, 0);
|
605
|
|
- layout->addWidget(label[1], 3, 0);
|
606
|
|
- layout->addWidget(line[1], 4, 0);
|
607
|
|
- layout->addWidget(label[2], 5, 0);
|
608
|
|
- layout->addWidget(line[2], 5, 1);
|
609
|
|
- layout->addWidget(label[3], 6, 0);
|
610
|
|
- layout->addWidget(line[3], 6, 1);
|
611
|
|
- layout->addWidget(button[0], 2, 1);
|
612
|
|
- layout->addWidget(button[1], 3, 1);
|
613
|
|
- layout->addWidget(line[4],7 ,1 );
|
614
|
|
- layout->addWidget(label[4],7 ,0 );
|
615
|
|
-
|
616
|
|
- //Here we connect the signals of the widgets generated
|
617
|
|
- //by code to their respective functions
|
618
|
|
- connect(method, SIGNAL(currentIndexChanged(QString)), this, SLOT(whatOption(QString)));
|
619
|
|
- connect(button[0], SIGNAL(clicked()), this, SLOT(RPSs()));
|
620
|
|
- connect(button[1], SIGNAL(clicked()), this, SLOT(clearLines()));
|
621
|
|
- connect(line[0], SIGNAL(textEdited(QString)), this, SLOT(RPSnormalizer1(QString)));
|
622
|
|
- connect(line[1], SIGNAL(textEdited(QString)), this, SLOT(RPSnormalizer2(QString)));
|
623
|
|
- connect(line[2], SIGNAL(textEdited(QString)), this, SLOT(RPSnormalizer3(QString)));
|
624
|
|
-
|
625
|
|
- //Now that we have set our new window, we hide the main-window
|
626
|
|
- //and show the new one. The new-window has a signal that
|
627
|
|
- //notify when it was closed so we can shor the main-window
|
628
|
|
- window->setLayout(layout);
|
629
|
|
- mostrar(false);
|
630
|
|
- window->show();
|
631
|
|
- score1 = score2 = 0;
|
632
|
|
-}
|
633
|
|
-
|
634
|
|
-//Here is what happend when CheckWritter-button is clicked
|
635
|
|
-void MainWindow::on_CheckWriterButton_clicked()
|
636
|
|
-{
|
637
|
|
- //Create a new QComboBox and add the items in it
|
638
|
|
- method = new QComboBox;
|
639
|
|
- method->addItem("Version Alpha");
|
640
|
|
- method->addItem("Version Beta");
|
641
|
|
- method->addItem("Version Gamma");
|
642
|
|
- method->addItem("Version Delta");
|
643
|
|
- option = "Version Alpha"; //Default option is alpha
|
|
418
|
+ label[2] = new QLabel("Winner:");
|
644
|
419
|
|
645
|
420
|
//We create a new layout and insert the comboBox to it
|
|
421
|
+ int row = 0;
|
646
|
422
|
layout = new QGridLayout;
|
647
|
|
- layout->addWidget(method, 0, 0, 1, -1);
|
648
|
|
-
|
649
|
|
- //Label to let the user understand the app
|
650
|
|
- label[0] = new QLabel("Number to convert");
|
|
423
|
+ layout->addWidget(method, row++, 0);
|
|
424
|
+ layout->addWidget(label[0], row, 0);
|
|
425
|
+ layout->addWidget(cmbPlayer01, row++, 1);
|
|
426
|
+ layout->addWidget(label[1], row, 0);
|
|
427
|
+ layout->addWidget(cmbPlayer02, row++, 1);
|
|
428
|
+ layout->addWidget(button[0], row++, 1);
|
|
429
|
+ layout->addWidget(line[0], row, 1);
|
|
430
|
+ layout->addWidget(label[2], row++, 0);
|
651
|
431
|
|
652
|
|
- //We just need two buttons to clear or convert
|
653
|
|
- button[0] = new QPushButton("Convert");
|
654
|
|
- button[1] = new QPushButton("Clear");
|
655
|
|
-
|
656
|
|
- //1 output and 1 input
|
657
|
|
- for (int i = 0; i<2; i++){
|
658
|
|
- line[i] = new QLineEdit;
|
659
|
|
- }
|
660
|
|
-
|
661
|
|
- //The user is not able to write on the output line
|
662
|
|
- line[1]->setEnabled(false);
|
663
|
|
-
|
664
|
|
- //Here we insert the widgets on the layout
|
665
|
|
- layout->addWidget(label[0], 1, 0, 1, 2);
|
666
|
|
- layout->addWidget(line[0], 2, 0, 1, 2);
|
667
|
|
- layout->addWidget(button[0], 3, 0);
|
668
|
|
- layout->addWidget(button[1], 3, 1);
|
669
|
|
- layout->addWidget(line[1], 4, 0, 1, 2);
|
670
|
432
|
|
671
|
433
|
//Here we connect the signals of the widgets generated
|
672
|
434
|
//by code to their respective functions
|
673
|
|
- connect(method, SIGNAL(currentIndexChanged(QString)), this, SLOT(whatOption(QString)));
|
674
|
|
- connect(button[0], SIGNAL(clicked()), this, SLOT(checkWs()));
|
675
|
|
- connect(button[1], SIGNAL(clicked()), this, SLOT(clearLines()));
|
676
|
|
- //connect(line[0], SIGNAL(textEdited(QString)), this, SLOT(CheckWnormalizer(QString)));
|
|
435
|
+ connect(method, SIGNAL(currentIndexChanged(QString)), this, SLOT(setOption(QString)));
|
|
436
|
+ connect(button[0], SIGNAL(clicked()), this, SLOT(callOneOfTheRPS()));
|
677
|
437
|
|
678
|
438
|
//Now that we have set our new window, we hide the main-window
|
679
|
439
|
//and show the new one. The new-window has a signal that
|
680
|
440
|
//notify when it was closed so we can shor the main-window
|
681
|
441
|
window->setLayout(layout);
|
682
|
|
- mostrar(false);
|
|
442
|
+ showMW(false);
|
683
|
443
|
window->show();
|
684
|
444
|
}
|
685
|
445
|
|
686
|
|
-//Here is what happend when Zulu-button is clicked
|
|
446
|
+
|
687
|
447
|
void MainWindow::on_ZuluButton_clicked()
|
688
|
448
|
{
|
689
|
449
|
//Create a new QComboBox and add the items in it
|
|
@@ -701,6 +461,7 @@ void MainWindow::on_ZuluButton_clicked()
|
701
|
461
|
//Labels to let the user understand the app
|
702
|
462
|
label[0] = new QLabel("Zulu time:");
|
703
|
463
|
label[1] = new QLabel("Standard time");
|
|
464
|
+ label[2] = new QLabel("Zulu zone:");
|
704
|
465
|
|
705
|
466
|
//Just the buttons to clear and convert the time
|
706
|
467
|
button[0] = new QPushButton("Clear");
|
|
@@ -716,6 +477,7 @@ void MainWindow::on_ZuluButton_clicked()
|
716
|
477
|
|
717
|
478
|
//Here we insert the widgets on the layout
|
718
|
479
|
layout->addWidget(label[0], 1, 0);
|
|
480
|
+ layout->addWidget(label[2], 1, 1);
|
719
|
481
|
layout->addWidget(line[0], 2, 0);
|
720
|
482
|
layout->addWidget(line[1], 2, 1);
|
721
|
483
|
layout->addWidget(button[0], 3, 0);
|
|
@@ -725,9 +487,9 @@ void MainWindow::on_ZuluButton_clicked()
|
725
|
487
|
|
726
|
488
|
//Here we connect the signals of the widgets generated
|
727
|
489
|
//by code to their respective functions
|
728
|
|
- connect(method, SIGNAL(currentIndexChanged(QString)), this, SLOT(whatOption(QString)));
|
|
490
|
+ connect(method, SIGNAL(currentIndexChanged(QString)), this, SLOT(setOption(QString)));
|
729
|
491
|
connect(button[0], SIGNAL(clicked()), this, SLOT(clearLines()));
|
730
|
|
- connect(button[1], SIGNAL(clicked()), this, SLOT(zulus()));
|
|
492
|
+ connect(button[1], SIGNAL(clicked()), this, SLOT(callOneOfTheZulus()));
|
731
|
493
|
|
732
|
494
|
// Rafa 2014-09-16 - Validation will be done when button is clicked
|
733
|
495
|
// connect(line[0], SIGNAL(textEdited(QString)), this, SLOT(Zulunormalizer1(QString)));
|
|
@@ -737,82 +499,7 @@ void MainWindow::on_ZuluButton_clicked()
|
737
|
499
|
//and show the new one. The new-window has a signal that
|
738
|
500
|
//notify when it was closed so we can shor the main-window
|
739
|
501
|
window->setLayout(layout);
|
740
|
|
- mostrar(false);
|
|
502
|
+ showMW(false);
|
741
|
503
|
window->show();
|
742
|
504
|
}
|
743
|
505
|
|
744
|
|
-//Here is what happend when APFT-button is clicked
|
745
|
|
-void MainWindow::on_APFTButton_clicked()
|
746
|
|
-{
|
747
|
|
- //Create a new QComboBox and add the items in it
|
748
|
|
- method = new QComboBox;
|
749
|
|
- method->addItem("Version Alpha");
|
750
|
|
- method->addItem("Version Beta");
|
751
|
|
- method->addItem("Version Gamma");
|
752
|
|
- method->addItem("Version Delta");
|
753
|
|
- option = "Version Alpha"; //Default option is alpha
|
754
|
|
-
|
755
|
|
- //We create a new layout and insert the comboBox to it
|
756
|
|
- layout = new QGridLayout;
|
757
|
|
- layout->addWidget(method, 0, 0, 1, -1);
|
758
|
|
-
|
759
|
|
- //3 inputs and 4 outputs
|
760
|
|
- for (int i = 0; i<7; i++){
|
761
|
|
- line[i] = new QLineEdit;
|
762
|
|
- }
|
763
|
|
-
|
764
|
|
- //The user is not able to write on the output lines
|
765
|
|
- line[3]->setEnabled(false);
|
766
|
|
- line[4]->setEnabled(false);
|
767
|
|
- line[5]->setEnabled(false);
|
768
|
|
- line[6]->setEnabled(false);
|
769
|
|
-
|
770
|
|
- //Labels to let the user understand the app
|
771
|
|
- label[0] = new QLabel("Sit-Ups");
|
772
|
|
- label[1] = new QLabel("Push-Ups");
|
773
|
|
- label[2] = new QLabel("2 Mile Run");
|
774
|
|
- label[3] = new QLabel("Sit-Ups Score");
|
775
|
|
- label[4] = new QLabel("Push-Ups Score");
|
776
|
|
- label[5] = new QLabel("2 Mile Run Score");
|
777
|
|
- label[6] = new QLabel("Total Score");
|
778
|
|
- label[7] = new QLabel("----");
|
779
|
|
-
|
780
|
|
- //Just the buttons to calculate it and clear the lines
|
781
|
|
- button[0] = new QPushButton("Calculate");
|
782
|
|
- button[1] = new QPushButton("Clear");
|
783
|
|
-
|
784
|
|
- //Here we insert the widgets on the layout
|
785
|
|
- layout->addWidget(label[0], 1, 0);
|
786
|
|
- layout->addWidget(label[1], 2, 0);
|
787
|
|
- layout->addWidget(label[2], 3, 0);
|
788
|
|
- layout->addWidget(button[0], 4, 0);
|
789
|
|
- layout->addWidget(line[0], 1, 1);
|
790
|
|
- layout->addWidget(line[1], 2, 1);
|
791
|
|
- layout->addWidget(line[2], 3, 1);
|
792
|
|
- layout->addWidget(button[1], 4, 1);
|
793
|
|
- layout->addWidget(label[3], 1, 2);
|
794
|
|
- layout->addWidget(label[4], 2, 2);
|
795
|
|
- layout->addWidget(label[5], 3, 2);
|
796
|
|
- layout->addWidget(label[6], 4, 2);
|
797
|
|
- layout->addWidget(line[3], 1, 3);
|
798
|
|
- layout->addWidget(line[4], 2, 3);
|
799
|
|
- layout->addWidget(line[5], 3, 3);
|
800
|
|
- layout->addWidget(line[6], 4, 3);
|
801
|
|
- layout->addWidget(label[7], 4, 4);
|
802
|
|
-
|
803
|
|
- //Here we connect the signals of the widgets generated
|
804
|
|
- //by code to their respective functions
|
805
|
|
- connect(method, SIGNAL(currentIndexChanged(QString)), this, SLOT(whatOption(QString)));
|
806
|
|
- connect(button[0], SIGNAL(clicked()), this, SLOT(APFTs()));
|
807
|
|
- connect(button[1], SIGNAL(clicked()), this, SLOT(clearLines()));
|
808
|
|
- connect(line[0], SIGNAL(textEdited(QString)), this, SLOT(APFTnormalizer1(QString)));
|
809
|
|
- connect(line[1], SIGNAL(textEdited(QString)), this, SLOT(APFTnormalizer2(QString)));
|
810
|
|
- connect(line[2], SIGNAL(textEdited(QString)), this, SLOT(APFTnormalizer3(QString)));
|
811
|
|
-
|
812
|
|
- //Now that we have set our new window, we hide the main-window
|
813
|
|
- //and show the new one. The new-window has a signal that
|
814
|
|
- //notify when it was closed so we can shor the main-window
|
815
|
|
- window->setLayout(layout);
|
816
|
|
- mostrar(false);
|
817
|
|
- window->show();
|
818
|
|
-}
|