Без опису

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749
  1. // RAN 2015-06-26 - Added Zulu Zone label
  2. // - Removed the onclick functions for the buttons that are no longer used
  3. #include "mainwindow.h"
  4. #include "ui_mainwindow.h"
  5. #include "secondwindow.cpp"
  6. #include <QDebug>
  7. #include <QtCore/qmath.h>
  8. #include <QMessageBox>
  9. #include "functions.h"
  10. #include <QDesktopWidget>
  11. MainWindow::MainWindow(QWidget *parent) :
  12. QMainWindow(parent),
  13. ui(new Ui::MainWindow)
  14. {
  15. ui->setupUi(this);
  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. // We set every pointer member to point NULL because we
  22. // when we delete every pointer we dont want to delete a
  23. // pointer that was already deleted in other moment or
  24. // was never used
  25. layout = NULL;
  26. for (int i = 0; i<buttonSize ; i++){
  27. button[i] = 0;
  28. }
  29. for (int i = 0; i < lineSize ; i++){
  30. line[i] = 0;
  31. }
  32. for (int i = 0; i<labelSize ; i++){
  33. label[i] = 0;
  34. }
  35. window = new secondwindow;
  36. QDesktopWidget desktop;
  37. window->move( ( desktop.screenGeometry().width() - window->width() )/2,
  38. ( desktop.screenGeometry().height()- window->height() ) /2);
  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. if(!dice1.load(":/images/resources/d1.png") || !dice2.load(":/images/resources/d1.png")){
  43. qDebug() << "Error1 Loading image";
  44. }
  45. initCheckWMaps();
  46. }
  47. MainWindow::~MainWindow()
  48. {
  49. delete ui;
  50. }
  51. //This function show the main window and delete all the items created on the closed one or hide the mainwindow
  52. void MainWindow::mostrar(bool si){
  53. if (si==true){
  54. show();
  55. // Deleting pointers and point them to NULL
  56. for (int i = 0; i<buttonSize ; i++){
  57. delete button[i];
  58. button[i] = NULL;
  59. }
  60. for (int i = 0; i<lineSize ; i++){
  61. delete line[i];
  62. line[i] = NULL;
  63. }
  64. for (int i = 0; i<labelSize ; i++){
  65. delete label[i];
  66. label[i] = NULL;
  67. }
  68. delete layout;
  69. layout = NULL;
  70. delete window;
  71. // Create the new window and connecting it again with the signal
  72. window = new secondwindow;
  73. QDesktopWidget desktop;
  74. window->move( ( desktop.screenGeometry().width() - window->width() )/2,
  75. ( desktop.screenGeometry().height()- window->height() ) /2);
  76. connect(window, SIGNAL(cerrado(bool)), this, SLOT(mostrar(bool)));
  77. }
  78. else hide();
  79. }
  80. //It is a slot that reads what item of the combo box was selected and save it
  81. //into a member
  82. void MainWindow::whatOption(QString str){
  83. option = str;
  84. }
  85. //Clear all the lines that are used
  86. void MainWindow::clearLines(){
  87. for (int i = 0; i < lineSize; i++){
  88. if (line[i] != NULL){
  89. line[i]->clear();
  90. }
  91. }
  92. score1 = score2 = 0;
  93. }
  94. //It forces the input 1 to be valid
  95. void MainWindow::RPSnormalizer1(QString str){
  96. //For every character in the string only allow
  97. //the character 'R' for rock, 'P' for paper and
  98. //'S' for scissors. Delete all the other characters
  99. //different from this three, and if is 'r', 'p' or 's'
  100. //make it uppercase.
  101. for (int i = 0; i< str.size(); i++){
  102. if (str[i] == 'r'){
  103. str[i] = 'R';
  104. }
  105. else if (str[i] == 'p'){
  106. str[i] = 'P';
  107. }
  108. else if (str[i] == 's'){
  109. str[i] = 'S';
  110. }
  111. else if (str[i] == 'R' || str[i] == 'P' ||
  112. str[i] == 'S');//then its ok, do nothing
  113. else{
  114. str = str.mid(0,i).append(str.mid(i+1));
  115. }
  116. }
  117. line[0]->setText(str);
  118. }
  119. //It forces the input 2 to be valid
  120. void MainWindow::RPSnormalizer2(QString str){
  121. for (int i = 0; i< str.size(); i++){
  122. if (str[i] == 'r'){
  123. str[i] = 'R';
  124. }
  125. else if (str[i] == 'p'){
  126. str[i] = 'P';
  127. }
  128. else if (str[i] == 's'){
  129. str[i] = 'S';
  130. }
  131. else if (str[i] == 'R' || str[i] == 'P' ||
  132. str[i] == 'S');//then its ok, do nothing
  133. else{
  134. str = str.mid(0,i).append(str.mid(i+1));
  135. }
  136. }
  137. line[1]->setText(str);
  138. }
  139. //It forces the input 3 to be valid
  140. void MainWindow::RPSnormalizer3(QString str){
  141. //Verify that the string do not contains other thing than
  142. //numbers
  143. for (int i = 0; i< str.size(); i++){
  144. if (!str[i].isDigit()){
  145. str = str.mid(0,i).append(str.mid(i+1));
  146. }
  147. }
  148. //Left zeros do not count, delete them
  149. while (str[0] == '0'){
  150. str = str.mid(1);
  151. }
  152. //If the player exagerates the number of games to win
  153. //change the string to the maximum number allowed
  154. if (str.toInt() > 150){
  155. str = "150";
  156. }
  157. line[2]->setText(str);
  158. }
  159. //It forces the input to be valid
  160. void MainWindow::CheckWnormalizer(QString str){
  161. //Just allow numbers
  162. for (int i = 0; i< str.size(); i++){
  163. if (!str[i].isDigit()){
  164. str = str.mid(0,i).append(str.mid(i+1));
  165. }
  166. }
  167. //Zeros on the left side do not count (delete them)
  168. while (str[0] == '0'){
  169. str = str.mid(1);
  170. }
  171. //The maximum is 999,999,999
  172. if (str.toDouble() > 999999999){
  173. str = "999999999";
  174. }
  175. line[0]->setText(str);
  176. }
  177. //It forces the first input of Zulu to be valid
  178. void MainWindow::Zulunormalizer1(QString str){
  179. //Just allow numbers to be written
  180. for (int i = 0; i< str.size(); i++){
  181. if (!str[i].isDigit()){
  182. str = str.mid(0,i).append(str.mid(i+1));
  183. }
  184. }
  185. //The maximum here is 2359, so force it to be the
  186. //maximum when the user write a larger number
  187. if (str.toInt() > 2359){
  188. str = "2359";
  189. }
  190. line[0]->setText(str);
  191. }
  192. //It forces the second input of Zulu to be valid
  193. void MainWindow::Zulunormalizer2(QString str){
  194. //Just allow one character to be written
  195. if (str.size() > 1){
  196. str = str[1];
  197. }
  198. //If that only character is 'e', 'c', 'm' or 'p'
  199. //the uppercase it
  200. if (str[0] == 'e' || str[0] == 'c' ||
  201. str[0] == 'm' || str[0] == 'p'){
  202. str = str[0].toUpper();
  203. }
  204. //If we get here is because the character is not
  205. //the lowercase letters allowed... so if they are
  206. //not the uppercase letters that we admit we have
  207. //to delete it.
  208. else if (str[0] != 'E' || str[0] != 'C' ||
  209. str[0] != 'M' || str[0] != 'P'){
  210. str = "";
  211. }
  212. line[1]->setText(str);
  213. }
  214. //It forces the first input of APFT to be valid
  215. void MainWindow::APFTnormalizer1(QString str){
  216. //Just admit numbers, delete the other type of
  217. //characters
  218. for (int i = 0; i< str.size(); i++){
  219. if (!str[i].isDigit()){
  220. str = str.mid(0,i).append(str.mid(i+1));
  221. }
  222. }
  223. //Left zeros are not valid
  224. while (str[0] == '0'){
  225. str = str.mid(1);
  226. }
  227. line[0]->setText(str);
  228. }
  229. //It forces the second input of APFT to be valid
  230. void MainWindow::APFTnormalizer2(QString str){
  231. //Just allow the numbers to be written
  232. for (int i = 0; i< str.size(); i++){
  233. if (!str[i].isDigit()){
  234. str = str.mid(0,i).append(str.mid(i+1));
  235. }
  236. }
  237. //Left-hand zeros? Delete them
  238. while (str[0] == '0'){
  239. str = str.mid(1);
  240. }
  241. line[1]->setText(str);
  242. }
  243. //It forces the third input of APFT to be valid
  244. void MainWindow::APFTnormalizer3(QString str){
  245. //Allow just numbers on the string only if the
  246. //character is not in the position 2
  247. for (int i = 0; i< str.size(); i++){
  248. if (!str[i].isDigit() && i != 2){
  249. str = str.mid(0,i).append(str.mid(i+1));
  250. }
  251. }
  252. //Then if there is a character in the position 2
  253. //and it is not ':', then add it between the
  254. //position 1 and 3
  255. if (str.size() > 2 && str[2] != ':'){
  256. while (str.size()>2 && !str[2].isDigit()){
  257. str = str.mid(0,2).append(str.mid(3));
  258. }
  259. str = str.mid(0, 2).append(':').append(str.mid(2));
  260. }
  261. //If the size exceeds 5, then take the first five
  262. //so then we will have the format mm:ss
  263. if (str.size() > 5){
  264. str = str.mid(0, 5);
  265. }
  266. line[2]->setText(str);
  267. }
  268. //Checks which version of sort is selected and call it
  269. void MainWindow::sorts(){
  270. QString a = line[0]->text();
  271. QString b = line[1]->text();
  272. QString c = line[2]->text();
  273. if (!validateSorts(a,b,c)) {
  274. QMessageBox::warning(this, "Alert",
  275. "Please provide the three non-empty strings");
  276. return;
  277. }
  278. if (option == "Version Alpha"){
  279. mySortAlpha(a,b,c);
  280. }
  281. else if (option == "Version Beta"){
  282. mySortBeta(a,b,c);
  283. }
  284. else if (option == "Version Gamma"){
  285. mySortGamma(a,b,c);
  286. }
  287. else{
  288. mySortDelta(a,b,c);
  289. }
  290. line[3]->setText(a);
  291. line[4]->setText(b);
  292. line[5]->setText(c);
  293. }
  294. //Checks which version of RPS is selected and call it
  295. void MainWindow::RPSs(){
  296. QString p1 = this->cmbPlayer01->currentText();
  297. QString p2 = this->cmbPlayer02->currentText();
  298. if (p1.length() * p2.length() == 0) {
  299. QMessageBox::warning(this, "Alert",
  300. "Please provide a play for both players and the number of games to win");
  301. return;
  302. }
  303. int winnerNum;
  304. if (option == "Version Alpha")
  305. winnerNum = RPSDelta(p1.toStdString()[0], p2.toStdString()[0]);
  306. else if (option == "Version Beta")
  307. winnerNum = RPSBeta(p1.toStdString()[0], p2.toStdString()[0]);
  308. else if (option == "Version Gamma")
  309. winnerNum = RPSGamma(p1.toStdString()[0], p2.toStdString()[0]);
  310. else
  311. winnerNum = RPSDelta(p1.toStdString()[0], p2.toStdString()[0]);
  312. QString st;
  313. qDebug() << winnerNum;
  314. switch(winnerNum) {
  315. case 1: st = "Player 1"; break;
  316. case 2: st = "Player 2"; break;
  317. case 0: st = "Tie"; break;
  318. default: st = "Error";
  319. }
  320. line[0]->setText(st);
  321. }
  322. #include <QTimer>
  323. void MainWindow::paintDice() {
  324. this->timerCounter++;
  325. int a, b;
  326. a = rand()%6;
  327. b = rand()%6;
  328. label[3]->setPixmap(QPixmap::fromImage(diceImages[a]));
  329. label[4]->setPixmap(QPixmap::fromImage(diceImages[b]));
  330. if (this->timerCounter == 10) {
  331. aTimer->stop();
  332. diceFinal01 = a;
  333. diceFinal02 = b;
  334. if (option == "Version Alpha")
  335. diceAlpha();
  336. else if (option == "Version Beta")
  337. diceBeta();
  338. else if (option == "Version Gamma")
  339. diceGamma();
  340. else
  341. diceAlpha();
  342. }
  343. }
  344. //Checks which version of dice is selected and call it
  345. void MainWindow::dices(){
  346. // [rafa] Voy a hacer la animación aqui
  347. for (int i = 1; i <= 6; i++)
  348. this->diceImages.push_back(QImage(":/images/resources/d" + QString::number(i) + ".png"));
  349. aTimer = new QTimer;
  350. aTimer->setInterval(100);
  351. aTimer->setSingleShot(false);
  352. aTimer->start();
  353. timerCounter = 0;
  354. QObject::connect(aTimer,&QTimer::timeout, this, &MainWindow::paintDice); //[&](){ birth(w, juana, avelardo, piolin);});
  355. }
  356. //Checks which version of check-writer is selected and call it
  357. void MainWindow::checkWs(){
  358. unsigned int qty;
  359. if (!validateCheckQty(line[0]->text(),qty)) {
  360. QMessageBox::warning(this, "Alert",
  361. "Enter a valid amount!");
  362. }
  363. if (option == "Version Alpha")
  364. line[1]->setText( checkWAlpha(qty) );
  365. else if (option == "Version Beta")
  366. line[1]->setText( checkWBeta(qty) );
  367. else if (option == "Version Gamma")
  368. line[1]->setText( checkWGamma(qty) );
  369. else
  370. line[1]->setText( checkWDelta(qty) );
  371. }
  372. //Checks which version of zulu is selected and call it
  373. void MainWindow::zulus(){
  374. QString zuluTime = line[0]->text();
  375. QString zuluZone = line[1]->text();
  376. int hours, minutes;
  377. if (!validZuluTime(zuluTime, zuluZone, hours, minutes) ) {
  378. QMessageBox::warning(this, "Alert",
  379. "Either Zulu Time or Zone is not valid");
  380. line[2]->setText("Error");
  381. return;
  382. }
  383. if (option == "Version Alpha")
  384. line[2]->setText( zuluAlpha(hours, minutes, zuluZone.toStdString()[0]) );
  385. else if (option == "Version Beta")
  386. line[2]->setText( zuluBeta(hours, minutes, zuluZone.toStdString()[0]) );
  387. else if (option == "Version Gamma")
  388. line[2]->setText( zuluGamma(hours, minutes, zuluZone.toStdString()[0]) );
  389. else
  390. line[2]->setText( zuluDelta(hours, minutes, zuluZone.toStdString()[0]) );
  391. }
  392. //Checks which version of APFT is selected and call it
  393. void MainWindow::APFTs(){
  394. if (option == "Version Alpha"){
  395. APFTAlpha();
  396. }
  397. else if (option == "Version Beta"){
  398. APFTBeta();
  399. }
  400. else if (option == "Version Gamma"){
  401. APFTGamma();
  402. }
  403. else{
  404. APFTDelta();
  405. }
  406. }
  407. //Here is what happend when Sort-button is clicked
  408. void MainWindow::on_SortsButton_clicked()
  409. {
  410. //Create a new QComboBox and add the items in it
  411. method = new QComboBox;
  412. method->addItem("Version Alpha");
  413. method->addItem("Version Beta");
  414. method->addItem("Version Gamma");
  415. method->addItem("Version Delta");
  416. option = "Version Alpha"; //Default option is alpha
  417. //We create a new layout and insert the comboBox to it
  418. layout = new QGridLayout;
  419. layout->addWidget(method, 0, 0, 1, -1);
  420. //The buttons needed are sort and clear so we create them
  421. button[0] = new QPushButton("Sort");
  422. button[1] = new QPushButton("Clear");
  423. //3 lines for input and 3 for output
  424. for (int i = 0; i<6 ; i++){
  425. line[i] = new QLineEdit;
  426. }
  427. //The user is not able to write on the output lines
  428. line[3]->setEnabled(false);
  429. line[4]->setEnabled(false);
  430. line[5]->setEnabled(false);
  431. //Labels to let the user understand the app
  432. label[0] = new QLabel("Input");
  433. label[1] = new QLabel("Output");
  434. //Here we insert the widgets on the layout
  435. layout->addWidget(label[0], 1, 0);
  436. layout->addWidget(label[1], 1, 2);
  437. layout->addWidget(line[0], 2, 0);
  438. layout->addWidget(line[1], 3, 0);
  439. layout->addWidget(line[2], 4, 0);
  440. layout->addWidget(button[0], 1, 1, 2, 1);
  441. layout->addWidget(button[1], 3, 1, 2, 1);
  442. layout->addWidget(line[3], 2, 2);
  443. layout->addWidget(line[4], 3, 2);
  444. layout->addWidget(line[5], 4, 2);
  445. //Here we connect the signals of the widgets generated
  446. //by code to their respective functions
  447. connect(method, SIGNAL(currentIndexChanged(QString)), this, SLOT(whatOption(QString)));
  448. connect(button[0], SIGNAL(clicked()), this, SLOT(sorts()));
  449. connect(button[1], SIGNAL(clicked()), this, SLOT(clearLines()));
  450. //Now that we have set our new window, we hide the main-window
  451. //and show the new one. The new-window has a signal that
  452. //notify when it was closed so we can shor the main-window
  453. window->setLayout(layout);
  454. mostrar(false);
  455. QDesktopWidget desktop;
  456. window->move( ( desktop.screenGeometry().width() - window->width() )/2,
  457. ( desktop.screenGeometry().height()- window->height() ) /2);
  458. window->show();
  459. }
  460. //Here is what happend when Dice-button is clicked
  461. void MainWindow::on_DiceButton_clicked()
  462. {
  463. //Create a new QComboBox and add the items in it
  464. method = new QComboBox;
  465. method->addItem("Version Alpha");
  466. method->addItem("Version Beta");
  467. method->addItem("Version Gamma");
  468. method->addItem("Version Delta");
  469. option = "Version Alpha"; //Default option is alpha
  470. //We create a new layout and insert the comboBox to it
  471. layout = new QGridLayout;
  472. layout->addWidget(method, 0, 0, 1, -1);
  473. //Labels to let the user understand the app
  474. label[0] = new QLabel("Dice 1");
  475. label[1] = new QLabel("Dice 2");
  476. label[2] = new QLabel("Total");
  477. //The user is not able to write on the output line
  478. line[0] = new QLineEdit;
  479. line[0]->setEnabled(false);
  480. //Here we just need one button to roll the dices
  481. button[0] = new QPushButton("Roll them!");
  482. //Labels to put the dices' images on them
  483. label[3] = new QLabel;
  484. label[4] = new QLabel;
  485. label[3]->setPixmap(QPixmap::fromImage(dice1));
  486. label[4]->setPixmap(QPixmap::fromImage(dice2));
  487. //Here we insert the widgets on the layout
  488. layout->addWidget(label[0], 1, 0);
  489. layout->addWidget(label[3], 1, 1);
  490. layout->addWidget(label[1], 2, 0);
  491. layout->addWidget(label[4], 2, 1);
  492. layout->addWidget(label[2], 3, 0);
  493. layout->addWidget(line[0], 3, 1);
  494. layout->addWidget(button[0], 1, 2, 2, 1);
  495. //Here we connect the signals of the widgets generated
  496. //by code to their respective functions
  497. connect(method, SIGNAL(currentIndexChanged(QString)), this, SLOT(whatOption(QString)));
  498. connect(button[0], SIGNAL(clicked()), this, SLOT(dices()));
  499. //Now that we have set our new window, we hide the main-window
  500. //and show the new one. The new-window has a signal that
  501. //notify when it was closed so we can shor the main-window
  502. window->setLayout(layout);
  503. mostrar(false);
  504. window->show();
  505. }
  506. //Here is what happend when RPS-button is clicked
  507. void MainWindow::on_RPSButton_clicked()
  508. {
  509. //Create a new QComboBox and add the items in it
  510. method = new QComboBox;
  511. method->addItem("Version Alpha");
  512. method->addItem("Version Beta");
  513. method->addItem("Version Gamma");
  514. method->addItem("Version Delta");
  515. option = "Version Alpha"; //Default option is alpha
  516. cmbPlayer01 = new QComboBox;
  517. cmbPlayer02 = new QComboBox;
  518. cmbPlayer01->addItem("rock"); cmbPlayer02->addItem("rock");
  519. cmbPlayer01->addItem("paper"); cmbPlayer02->addItem("paper");
  520. cmbPlayer01->addItem("scisors"); cmbPlayer02->addItem("scisors");
  521. //The buttons needed here are the 'play' and 'clear' buttons
  522. button[0] = new QPushButton("Play");
  523. // button[1] = new QPushButton("Clear");
  524. //3 inputs and 1 output
  525. // for (int i = 0; i<4; i++){
  526. // line[i] = new QLineEdit;
  527. // }
  528. line[0] = new QLineEdit;
  529. //The user is not able to write on the output line
  530. line[0]->setEnabled(false);
  531. //Labels to let the user understand the app
  532. label[0] = new QLabel("Player 1's moves");
  533. label[1] = new QLabel("Player 2's moves");
  534. // label[2] = new QLabel("How many games to win:");
  535. label[2] = new QLabel("Winner:");
  536. // label[4] = new QLabel("Tournament:");
  537. // //lines for score
  538. // line[4] = new QLineEdit;
  539. // line[4]->setEnabled(false);
  540. //We create a new layout and insert the comboBox to it
  541. int row = 0;
  542. layout = new QGridLayout;
  543. layout->addWidget(method, row++, 0);
  544. layout->addWidget(label[0], row, 0);
  545. layout->addWidget(cmbPlayer01, row++, 1);
  546. layout->addWidget(label[1], row, 0);
  547. layout->addWidget(cmbPlayer02, row++, 1);
  548. layout->addWidget(button[0], row++, 1);
  549. layout->addWidget(line[0], row, 1);
  550. layout->addWidget(label[2], row++, 0);
  551. //Here we connect the signals of the widgets generated
  552. //by code to their respective functions
  553. connect(method, SIGNAL(currentIndexChanged(QString)), this, SLOT(whatOption(QString)));
  554. connect(button[0], SIGNAL(clicked()), this, SLOT(RPSs()));
  555. //Now that we have set our new window, we hide the main-window
  556. //and show the new one. The new-window has a signal that
  557. //notify when it was closed so we can shor the main-window
  558. window->setLayout(layout);
  559. mostrar(false);
  560. window->show();
  561. // score1 = score2 = 0;
  562. }
  563. //Here is what happend when Zulu-button is clicked
  564. void MainWindow::on_ZuluButton_clicked()
  565. {
  566. //Create a new QComboBox and add the items in it
  567. method = new QComboBox;
  568. method->addItem("Version Alpha");
  569. method->addItem("Version Beta");
  570. method->addItem("Version Gamma");
  571. method->addItem("Version Delta");
  572. option = "Version Alpha"; //Default option is alpha
  573. //We create a new layout and insert the comboBox to it
  574. layout = new QGridLayout;
  575. layout->addWidget(method, 0, 0, 1, -1);
  576. //Labels to let the user understand the app
  577. label[0] = new QLabel("Zulu time:");
  578. label[1] = new QLabel("Standard time");
  579. label[2] = new QLabel("Zulu zone:");
  580. //Just the buttons to clear and convert the time
  581. button[0] = new QPushButton("Clear");
  582. button[1] = new QPushButton("Convert");
  583. //2 inputs and 1 output
  584. for (int i = 0; i<3; i++){
  585. line[i] = new QLineEdit;
  586. }
  587. //The user is not able to write on the output line
  588. line[2]->setEnabled(false);
  589. //Here we insert the widgets on the layout
  590. layout->addWidget(label[0], 1, 0);
  591. layout->addWidget(label[2], 1, 1);
  592. layout->addWidget(line[0], 2, 0);
  593. layout->addWidget(line[1], 2, 1);
  594. layout->addWidget(button[0], 3, 0);
  595. layout->addWidget(button[1], 3, 1);
  596. layout->addWidget(label[1], 4, 0);
  597. layout->addWidget(line[2], 4, 1);
  598. //Here we connect the signals of the widgets generated
  599. //by code to their respective functions
  600. connect(method, SIGNAL(currentIndexChanged(QString)), this, SLOT(whatOption(QString)));
  601. connect(button[0], SIGNAL(clicked()), this, SLOT(clearLines()));
  602. connect(button[1], SIGNAL(clicked()), this, SLOT(zulus()));
  603. // Rafa 2014-09-16 - Validation will be done when button is clicked
  604. // connect(line[0], SIGNAL(textEdited(QString)), this, SLOT(Zulunormalizer1(QString)));
  605. // connect(line[1], SIGNAL(textEdited(QString)), this, SLOT(Zulunormalizer2(QString)));
  606. //Now that we have set our new window, we hide the main-window
  607. //and show the new one. The new-window has a signal that
  608. //notify when it was closed so we can shor the main-window
  609. window->setLayout(layout);
  610. mostrar(false);
  611. window->show();
  612. }