No Description

mainwindow.cpp 21KB

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