|
@@ -0,0 +1,818 @@
|
|
1
|
+#include "mainwindow.h"
|
|
2
|
+#include "ui_mainwindow.h"
|
|
3
|
+#include "secondwindow.cpp"
|
|
4
|
+
|
|
5
|
+#include <QDebug>
|
|
6
|
+#include <QtCore/qmath.h>
|
|
7
|
+#include <QMessageBox>
|
|
8
|
+#include "functions.h"
|
|
9
|
+
|
|
10
|
+MainWindow::MainWindow(QWidget *parent) :
|
|
11
|
+ QMainWindow(parent),
|
|
12
|
+ ui(new Ui::MainWindow)
|
|
13
|
+{
|
|
14
|
+ ui->setupUi(this);
|
|
15
|
+
|
|
16
|
+ //These are the size of the arrays of widgets 'line-edit',
|
|
17
|
+ //'label' and 'button'
|
|
18
|
+ buttonSize = 2;
|
|
19
|
+ lineSize = 7;
|
|
20
|
+ labelSize = 8;
|
|
21
|
+
|
|
22
|
+ // We set every pointer member to point NULL because we
|
|
23
|
+ // when we delete every pointer we dont want to delete a
|
|
24
|
+ // pointer that was already deleted in other moment or
|
|
25
|
+ // was never used
|
|
26
|
+ layout = NULL;
|
|
27
|
+ for (int i = 0; i<buttonSize ; i++){
|
|
28
|
+ button[i] = 0;
|
|
29
|
+ }
|
|
30
|
+ for (int i = 0; i < lineSize ; i++){
|
|
31
|
+ line[i] = 0;
|
|
32
|
+ }
|
|
33
|
+ for (int i = 0; i<labelSize ; i++){
|
|
34
|
+ label[i] = 0;
|
|
35
|
+ }
|
|
36
|
+
|
|
37
|
+ window = new secondwindow;
|
|
38
|
+
|
|
39
|
+ // We need to know whenever the second window is closed to show the
|
|
40
|
+ // main window, or to hide when the second one is showed
|
|
41
|
+ connect(window, SIGNAL(cerrado(bool)), this, SLOT(mostrar(bool)));
|
|
42
|
+
|
|
43
|
+ if(!dice1.load(":/images/resources/d1.png") || !dice2.load(":/images/resources/d1.png")){
|
|
44
|
+ qDebug() << "Error1 Loading image";
|
|
45
|
+ }
|
|
46
|
+
|
|
47
|
+ initCheckWMaps();
|
|
48
|
+}
|
|
49
|
+
|
|
50
|
+MainWindow::~MainWindow()
|
|
51
|
+{
|
|
52
|
+ delete ui;
|
|
53
|
+}
|
|
54
|
+
|
|
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){
|
|
58
|
+ show();
|
|
59
|
+
|
|
60
|
+ // Deleting pointers and point them to NULL
|
|
61
|
+ for (int i = 0; i<buttonSize ; i++){
|
|
62
|
+ delete button[i];
|
|
63
|
+ button[i] = NULL;
|
|
64
|
+ }
|
|
65
|
+ for (int i = 0; i<lineSize ; i++){
|
|
66
|
+ delete line[i];
|
|
67
|
+ line[i] = NULL;
|
|
68
|
+ }
|
|
69
|
+ for (int i = 0; i<labelSize ; i++){
|
|
70
|
+ delete label[i];
|
|
71
|
+ label[i] = NULL;
|
|
72
|
+ }
|
|
73
|
+ delete layout;
|
|
74
|
+ layout = NULL;
|
|
75
|
+ delete window;
|
|
76
|
+
|
|
77
|
+ // Create the new window and connecting it again with the signal
|
|
78
|
+ window = new secondwindow;
|
|
79
|
+ connect(window, SIGNAL(cerrado(bool)), this, SLOT(mostrar(bool)));
|
|
80
|
+ }
|
|
81
|
+ else hide();
|
|
82
|
+}
|
|
83
|
+
|
|
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
|
+ option = str;
|
|
88
|
+}
|
|
89
|
+
|
|
90
|
+//Clear all the lines that are used
|
|
91
|
+void MainWindow::clearLines(){
|
|
92
|
+ for (int i = 0; i < lineSize; i++){
|
|
93
|
+ if (line[i] != NULL){
|
|
94
|
+ line[i]->clear();
|
|
95
|
+ }
|
|
96
|
+ }
|
|
97
|
+ score1 = score2 = 0;
|
|
98
|
+}
|
|
99
|
+
|
|
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
|
+
|
|
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(){
|
|
306
|
+ QString a = line[0]->text();
|
|
307
|
+ QString b = line[1]->text();
|
|
308
|
+ QString c = line[2]->text();
|
|
309
|
+
|
|
310
|
+ if (!validateSorts(a,b,c)) {
|
|
311
|
+ QMessageBox::warning(this, "Alert",
|
|
312
|
+ "Please provide the three non-empty strings");
|
|
313
|
+ return;
|
|
314
|
+ }
|
|
315
|
+
|
|
316
|
+ if (option == "Version Alpha"){
|
|
317
|
+ mySortAlpha(a,b,c);
|
|
318
|
+ }
|
|
319
|
+ else if (option == "Version Beta"){
|
|
320
|
+ mySortBeta(a,b,c);
|
|
321
|
+ }
|
|
322
|
+ else if (option == "Version Gamma"){
|
|
323
|
+ mySortGamma(a,b,c);
|
|
324
|
+ }
|
|
325
|
+ else{
|
|
326
|
+ mySortDelta(a,b,c);
|
|
327
|
+ }
|
|
328
|
+ line[3]->setText(a);
|
|
329
|
+ line[4]->setText(b);
|
|
330
|
+ line[5]->setText(c);
|
|
331
|
+}
|
|
332
|
+
|
|
333
|
+
|
|
334
|
+
|
|
335
|
+
|
|
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) {
|
|
344
|
+ QMessageBox::warning(this, "Alert",
|
|
345
|
+ "Please provide a play for both players and the number of games to win");
|
|
346
|
+ return;
|
|
347
|
+ }
|
|
348
|
+
|
|
349
|
+ int winnerNum;
|
|
350
|
+ if (option == "Version Alpha")
|
|
351
|
+ winnerNum = RPSAlpha(p1.toStdString()[0], p2.toStdString()[0], score1, score2);
|
|
352
|
+ else if (option == "Version Beta")
|
|
353
|
+ winnerNum = RPSBeta(p1.toStdString()[0], p2.toStdString()[0], score1, score2);
|
|
354
|
+ else if (option == "Version Gamma")
|
|
355
|
+ winnerNum = RPSGamma(p1.toStdString()[0], p2.toStdString()[0], score1, score2);
|
|
356
|
+ else
|
|
357
|
+ winnerNum = RPSDelta(p1.toStdString()[0], p2.toStdString()[0], score1, score2);
|
|
358
|
+
|
|
359
|
+ QString st;
|
|
360
|
+
|
|
361
|
+ 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";
|
|
366
|
+ }
|
|
367
|
+
|
|
368
|
+ line[3]->setText(st);
|
|
369
|
+
|
|
370
|
+ line[4]->setText(QString::number(score1) + " to " + QString::number(score2));
|
|
371
|
+
|
|
372
|
+ if (score1 == gamesToWin.toInt() || score2 == gamesToWin.toInt() ) {
|
|
373
|
+ QMessageBox::warning(this, "Alert",
|
|
374
|
+ "Game won by " + st + "!!!");
|
|
375
|
+ score1 = score2 = 0;
|
|
376
|
+ }
|
|
377
|
+
|
|
378
|
+}
|
|
379
|
+
|
|
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();
|
|
390
|
+}
|
|
391
|
+
|
|
392
|
+
|
|
393
|
+//Checks which version of check-writer is selected and call it
|
|
394
|
+void MainWindow::checkWs(){
|
|
395
|
+ unsigned int qty;
|
|
396
|
+ if (!validateCheckQty(line[0]->text(),qty)) {
|
|
397
|
+ QMessageBox::warning(this, "Alert",
|
|
398
|
+ "Enter a valid amount!");
|
|
399
|
+ }
|
|
400
|
+
|
|
401
|
+ if (option == "Version Alpha")
|
|
402
|
+ line[1]->setText( checkWAlpha(qty) );
|
|
403
|
+ else if (option == "Version Beta")
|
|
404
|
+ line[1]->setText( checkWBeta(qty) );
|
|
405
|
+ else if (option == "Version Gamma")
|
|
406
|
+ line[1]->setText( checkWGamma(qty) );
|
|
407
|
+ else
|
|
408
|
+ line[1]->setText( checkWDelta(qty) );
|
|
409
|
+}
|
|
410
|
+
|
|
411
|
+//Checks which version of zulu is selected and call it
|
|
412
|
+void MainWindow::zulus(){
|
|
413
|
+ QString zuluTime = line[0]->text();
|
|
414
|
+ QString zuluZone = line[1]->text();
|
|
415
|
+ int hours, minutes;
|
|
416
|
+
|
|
417
|
+ if (!validZuluTime(zuluTime, zuluZone, hours, minutes) ) {
|
|
418
|
+
|
|
419
|
+ QMessageBox::warning(this, "Alert",
|
|
420
|
+ "Either Zulu Time or Zone is not valid");
|
|
421
|
+ line[2]->setText("Error");
|
|
422
|
+ return;
|
|
423
|
+ }
|
|
424
|
+ if (option == "Version Alpha")
|
|
425
|
+ line[2]->setText( zuluAlpha(hours, minutes, zuluZone.toStdString()[0]) );
|
|
426
|
+ else if (option == "Version Beta")
|
|
427
|
+ line[2]->setText( zuluBeta(hours, minutes, zuluZone.toStdString()[0]) );
|
|
428
|
+ else if (option == "Version Gamma")
|
|
429
|
+ line[2]->setText( zuluGamma(hours, minutes, zuluZone.toStdString()[0]) );
|
|
430
|
+ else
|
|
431
|
+ line[2]->setText( zuluDelta(hours, minutes, zuluZone.toStdString()[0]) );
|
|
432
|
+
|
|
433
|
+}
|
|
434
|
+
|
|
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
|
+
|
|
451
|
+//Here is what happend when Sort-button is clicked
|
|
452
|
+void MainWindow::on_SortsButton_clicked()
|
|
453
|
+{
|
|
454
|
+ //Create a new QComboBox and add the items in it
|
|
455
|
+ method = new QComboBox;
|
|
456
|
+ method->addItem("Version Alpha");
|
|
457
|
+ method->addItem("Version Beta");
|
|
458
|
+ method->addItem("Version Gamma");
|
|
459
|
+ method->addItem("Version Delta");
|
|
460
|
+ option = "Version Alpha"; //Default option is alpha
|
|
461
|
+
|
|
462
|
+ //We create a new layout and insert the comboBox to it
|
|
463
|
+ layout = new QGridLayout;
|
|
464
|
+ layout->addWidget(method, 0, 0, 1, -1);
|
|
465
|
+
|
|
466
|
+ //The buttons needed are sort and clear so we create them
|
|
467
|
+ button[0] = new QPushButton("Sort");
|
|
468
|
+ button[1] = new QPushButton("Clear");
|
|
469
|
+
|
|
470
|
+ //3 lines for input and 3 for output
|
|
471
|
+ for (int i = 0; i<6 ; i++){
|
|
472
|
+ line[i] = new QLineEdit;
|
|
473
|
+ }
|
|
474
|
+
|
|
475
|
+ //The user is not able to write on the output lines
|
|
476
|
+ line[3]->setEnabled(false);
|
|
477
|
+ line[4]->setEnabled(false);
|
|
478
|
+ line[5]->setEnabled(false);
|
|
479
|
+
|
|
480
|
+ //Labels to let the user understand the app
|
|
481
|
+ label[0] = new QLabel("Input");
|
|
482
|
+ label[1] = new QLabel("Output");
|
|
483
|
+
|
|
484
|
+ //Here we insert the widgets on the layout
|
|
485
|
+ layout->addWidget(label[0], 1, 0);
|
|
486
|
+ layout->addWidget(label[1], 1, 2);
|
|
487
|
+ layout->addWidget(line[0], 2, 0);
|
|
488
|
+ layout->addWidget(line[1], 3, 0);
|
|
489
|
+ layout->addWidget(line[2], 4, 0);
|
|
490
|
+ layout->addWidget(button[0], 1, 1, 2, 1);
|
|
491
|
+ layout->addWidget(button[1], 3, 1, 2, 1);
|
|
492
|
+ layout->addWidget(line[3], 2, 2);
|
|
493
|
+ layout->addWidget(line[4], 3, 2);
|
|
494
|
+ layout->addWidget(line[5], 4, 2);
|
|
495
|
+
|
|
496
|
+ //Here we connect the signals of the widgets generated
|
|
497
|
+ //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()));
|
|
500
|
+ connect(button[1], SIGNAL(clicked()), this, SLOT(clearLines()));
|
|
501
|
+
|
|
502
|
+ //Now that we have set our new window, we hide the main-window
|
|
503
|
+ //and show the new one. The new-window has a signal that
|
|
504
|
+ //notify when it was closed so we can shor the main-window
|
|
505
|
+ window->setLayout(layout);
|
|
506
|
+ mostrar(false);
|
|
507
|
+ window->show();
|
|
508
|
+}
|
|
509
|
+
|
|
510
|
+//Here is what happend when Dice-button is clicked
|
|
511
|
+void MainWindow::on_DiceButton_clicked()
|
|
512
|
+{
|
|
513
|
+ //Create a new QComboBox and add the items in it
|
|
514
|
+ method = new QComboBox;
|
|
515
|
+ method->addItem("Version Alpha");
|
|
516
|
+ method->addItem("Version Beta");
|
|
517
|
+ method->addItem("Version Gamma");
|
|
518
|
+ method->addItem("Version Delta");
|
|
519
|
+ option = "Version Alpha"; //Default option is alpha
|
|
520
|
+
|
|
521
|
+ //We create a new layout and insert the comboBox to it
|
|
522
|
+ layout = new QGridLayout;
|
|
523
|
+ layout->addWidget(method, 0, 0, 1, -1);
|
|
524
|
+
|
|
525
|
+ //Labels to let the user understand the app
|
|
526
|
+ label[0] = new QLabel("Dice 1");
|
|
527
|
+ label[1] = new QLabel("Dice 2");
|
|
528
|
+ label[2] = new QLabel("Total");
|
|
529
|
+
|
|
530
|
+ //The user is not able to write on the output line
|
|
531
|
+ line[0] = new QLineEdit;
|
|
532
|
+ line[0]->setEnabled(false);
|
|
533
|
+
|
|
534
|
+ //Here we just need one button to roll the dices
|
|
535
|
+ button[0] = new QPushButton("Roll them!");
|
|
536
|
+
|
|
537
|
+ //Labels to put the dices' images on them
|
|
538
|
+ label[3] = new QLabel;
|
|
539
|
+ label[4] = new QLabel;
|
|
540
|
+ label[3]->setPixmap(QPixmap::fromImage(dice1));
|
|
541
|
+ label[4]->setPixmap(QPixmap::fromImage(dice2));
|
|
542
|
+
|
|
543
|
+ //Here we insert the widgets on the layout
|
|
544
|
+ layout->addWidget(label[0], 1, 0);
|
|
545
|
+ layout->addWidget(label[3], 1, 1);
|
|
546
|
+ layout->addWidget(label[1], 2, 0);
|
|
547
|
+ layout->addWidget(label[4], 2, 1);
|
|
548
|
+ layout->addWidget(label[2], 3, 0);
|
|
549
|
+ layout->addWidget(line[0], 3, 1);
|
|
550
|
+ layout->addWidget(button[0], 1, 2, 2, 1);
|
|
551
|
+
|
|
552
|
+ //Here we connect the signals of the widgets generated
|
|
553
|
+ //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()));
|
|
556
|
+
|
|
557
|
+ //Now that we have set our new window, we hide the main-window
|
|
558
|
+ //and show the new one. The new-window has a signal that
|
|
559
|
+ //notify when it was closed so we can shor the main-window
|
|
560
|
+ window->setLayout(layout);
|
|
561
|
+ mostrar(false);
|
|
562
|
+ window->show();
|
|
563
|
+}
|
|
564
|
+
|
|
565
|
+//Here is what happend when RPS-button is clicked
|
|
566
|
+void MainWindow::on_RPSButton_clicked()
|
|
567
|
+{
|
|
568
|
+ //Create a new QComboBox and add the items in it
|
|
569
|
+ method = new QComboBox;
|
|
570
|
+ method->addItem("Version Alpha");
|
|
571
|
+ method->addItem("Version Beta");
|
|
572
|
+ method->addItem("Version Gamma");
|
|
573
|
+ method->addItem("Version Delta");
|
|
574
|
+ option = "Version Alpha"; //Default option is alpha
|
|
575
|
+
|
|
576
|
+ //We create a new layout and insert the comboBox to it
|
|
577
|
+ layout = new QGridLayout;
|
|
578
|
+ layout->addWidget(method, 0, 0, 1, -1);
|
|
579
|
+
|
|
580
|
+ //The buttons needed here are the 'play' and 'clear' buttons
|
|
581
|
+ 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
|
+
|
|
589
|
+ //The user is not able to write on the output line
|
|
590
|
+ line[3]->setEnabled(false);
|
|
591
|
+
|
|
592
|
+ //Labels to let the user understand the app
|
|
593
|
+ label[0] = new QLabel("Player 1's moves");
|
|
594
|
+ 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
|
|
644
|
+
|
|
645
|
+ //We create a new layout and insert the comboBox to it
|
|
646
|
+ 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");
|
|
651
|
+
|
|
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
|
+
|
|
671
|
+ //Here we connect the signals of the widgets generated
|
|
672
|
+ //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)));
|
|
677
|
+
|
|
678
|
+ //Now that we have set our new window, we hide the main-window
|
|
679
|
+ //and show the new one. The new-window has a signal that
|
|
680
|
+ //notify when it was closed so we can shor the main-window
|
|
681
|
+ window->setLayout(layout);
|
|
682
|
+ mostrar(false);
|
|
683
|
+ window->show();
|
|
684
|
+}
|
|
685
|
+
|
|
686
|
+//Here is what happend when Zulu-button is clicked
|
|
687
|
+void MainWindow::on_ZuluButton_clicked()
|
|
688
|
+{
|
|
689
|
+ //Create a new QComboBox and add the items in it
|
|
690
|
+ method = new QComboBox;
|
|
691
|
+ method->addItem("Version Alpha");
|
|
692
|
+ method->addItem("Version Beta");
|
|
693
|
+ method->addItem("Version Gamma");
|
|
694
|
+ method->addItem("Version Delta");
|
|
695
|
+ option = "Version Alpha"; //Default option is alpha
|
|
696
|
+
|
|
697
|
+ //We create a new layout and insert the comboBox to it
|
|
698
|
+ layout = new QGridLayout;
|
|
699
|
+ layout->addWidget(method, 0, 0, 1, -1);
|
|
700
|
+
|
|
701
|
+ //Labels to let the user understand the app
|
|
702
|
+ label[0] = new QLabel("Zulu time:");
|
|
703
|
+ label[1] = new QLabel("Standard time");
|
|
704
|
+
|
|
705
|
+ //Just the buttons to clear and convert the time
|
|
706
|
+ button[0] = new QPushButton("Clear");
|
|
707
|
+ button[1] = new QPushButton("Convert");
|
|
708
|
+
|
|
709
|
+ //2 inputs and 1 output
|
|
710
|
+ for (int i = 0; i<3; i++){
|
|
711
|
+ line[i] = new QLineEdit;
|
|
712
|
+ }
|
|
713
|
+
|
|
714
|
+ //The user is not able to write on the output line
|
|
715
|
+ line[2]->setEnabled(false);
|
|
716
|
+
|
|
717
|
+ //Here we insert the widgets on the layout
|
|
718
|
+ layout->addWidget(label[0], 1, 0);
|
|
719
|
+ layout->addWidget(line[0], 2, 0);
|
|
720
|
+ layout->addWidget(line[1], 2, 1);
|
|
721
|
+ layout->addWidget(button[0], 3, 0);
|
|
722
|
+ layout->addWidget(button[1], 3, 1);
|
|
723
|
+ layout->addWidget(label[1], 4, 0);
|
|
724
|
+ layout->addWidget(line[2], 4, 1);
|
|
725
|
+
|
|
726
|
+ //Here we connect the signals of the widgets generated
|
|
727
|
+ //by code to their respective functions
|
|
728
|
+ connect(method, SIGNAL(currentIndexChanged(QString)), this, SLOT(whatOption(QString)));
|
|
729
|
+ connect(button[0], SIGNAL(clicked()), this, SLOT(clearLines()));
|
|
730
|
+ connect(button[1], SIGNAL(clicked()), this, SLOT(zulus()));
|
|
731
|
+
|
|
732
|
+ // Rafa 2014-09-16 - Validation will be done when button is clicked
|
|
733
|
+ // connect(line[0], SIGNAL(textEdited(QString)), this, SLOT(Zulunormalizer1(QString)));
|
|
734
|
+ // connect(line[1], SIGNAL(textEdited(QString)), this, SLOT(Zulunormalizer2(QString)));
|
|
735
|
+
|
|
736
|
+ //Now that we have set our new window, we hide the main-window
|
|
737
|
+ //and show the new one. The new-window has a signal that
|
|
738
|
+ //notify when it was closed so we can shor the main-window
|
|
739
|
+ window->setLayout(layout);
|
|
740
|
+ mostrar(false);
|
|
741
|
+ window->show();
|
|
742
|
+}
|
|
743
|
+
|
|
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
|
+}
|