qCNC 0.82-alpha
/home/trilog/Desktop/project/gui/Final/src/TS_Extension_Dialog.cpp
Go to the documentation of this file.
00001 
00041 #include "TS_Extension_Dialog.h"
00042 #include "global_includes.h"
00043 //#include "libtse.h"
00044 
00055 TSabout::TSabout(QWidget *parent) : QDialog(parent)
00056 {
00057 
00058         QWidget *aboutw = new QWidget(this);
00059         QVBoxLayout *main = new QVBoxLayout(aboutw);
00060 
00061         QVBoxLayout *D = new QVBoxLayout;
00062 
00063 
00064         QLabel *LD = new QLabel(tr("Description"));
00065         QTextBrowser *DTb = new QTextBrowser;
00066         D->setAlignment(Qt::AlignLeft);
00067         DTb->setText(DESCRIPTION);
00068         DTb->setReadOnly(true);
00069         D->addWidget(LD);
00070         D->addWidget(DTb);
00071 
00072 
00073         QVBoxLayout *L = new QVBoxLayout;
00074         QLabel *LL = new QLabel(tr("Libraries"));
00075         QTextBrowser *LTb = new QTextBrowser;
00076         LTb->setText(LIBRARIES);
00077         LTb->setReadOnly(true);
00078         L->setAlignment(Qt::AlignLeft);
00079         L->addWidget(LL);
00080         L->addWidget(LTb);
00081 
00082         QHBoxLayout *P = new QHBoxLayout;
00083         QVBoxLayout *A = new QVBoxLayout;
00084         QVBoxLayout *LO = new QVBoxLayout;
00085         QLabel *Aut = new QLabel(tr("Author:\tRon Ablinger"));
00086         QLabel *Comp = new QLabel(tr("Company:\tTrilog Studios"));
00087         QLabel *V = new QLabel(VERSION);
00088         //QLabel *bld = new QLabel(BUILD_V);
00089         QLabel *date = new QLabel(BUILD_D);
00090         QLabel *LLO = new QLabel;
00091         LLO->setBackgroundRole(QPalette::Base);
00092         QImage image("resources/TS_Logo.png");
00093         //LLO->setPicture();
00094         LLO->setPixmap(QPixmap::fromImage(image));
00095         A->setAlignment(Qt::AlignLeft);
00096         A->addWidget(Aut);
00097         A->addWidget(Comp);
00098         A->addWidget(V);
00099         //A->addWidget(bld);
00100         A->addWidget(date);
00101         LO->addWidget(LLO);
00102         P->setAlignment(Qt::AlignRight);
00103         P->addLayout(A);
00104         P->addLayout(LO);
00105 
00106         QHBoxLayout *B = new QHBoxLayout;
00107         QPushButton *ok = new QPushButton(tr("close"));
00108         connect(ok,SIGNAL(clicked()),this,SLOT(close()));
00109         B->setAlignment(Qt::AlignRight);
00110         B->addWidget(ok);
00111 
00112         main->addLayout(D);
00113         main->addLayout(L);
00114         main->addLayout(P);
00115         main->addLayout(B);
00116 
00117 
00118 
00119 
00120 
00121 }
00122 
00133 ProgEditDialog::ProgEditDialog(QWidget *parent) : QDialog(parent)
00134 {
00135 
00136 
00137     QString Title;
00138     QString graphcc;
00139     QString graphca;
00140     QString graphsc;
00141     QString graphsa;
00142     QString Main_width;
00143     QString Main_highth;
00144 
00145 
00146     int leng = 0;
00147 
00148     QFile usb(PROG_SETTINGS_TSS);
00149     usb.open(QIODevice::ReadOnly);
00150 
00151     QTextStream fs(&usb);    // read the data serialized from the file
00152 
00153     str.clear();
00154     while (!fs.atEnd())
00155         {
00156             leng = 0;
00157             str=fs.readLine();
00158 
00159             leng = str.length();
00160             if (str[0] == '#')
00161                 continue;
00162             if ((str[0] =='t') && (str[1] =='i') && (str[3] == 'l')) //title
00163             {
00164                 for (int i = 8;i <=leng;i++)
00165                 {
00166                     if (str[i] == '>')
00167                        Title[i-8]='\0';
00168                     else
00169                         Title[i-8]=str[i];
00170 
00171 
00172                 }
00173 
00174 
00175             }
00176             if ((str[0] =='g') && (str[1] =='r') && (str[4] == 'h') && (str[5] == 'c') && (str[6] == 'c'))//graphcc
00177             {
00178                 for (int i = 10;i <=leng;i++)
00179                 {
00180                     if(str[i] == '>')
00181                         graphcc[i-10]='\0';
00182                     else
00183                         graphcc[i-10]=str[i];
00184 
00185 
00186                 }
00187 
00188             }
00189             if ((str[0] =='g') && (str[1] =='r') && (str[4] == 'h') && (str[5] == 'c') && (str[6] == 'a'))//graphca
00190             {
00191                 for (int i = 10;i <=leng;i++)
00192                 {
00193                     if (str[i] == '>')
00194                         graphca[i-10]='\0';
00195                     else
00196                         graphca[i-10]=str[i];
00197 
00198 
00199                 }
00200 
00201             }
00202             if ((str[0] =='g') && (str[1] =='r') && (str[4] == 'h') && (str[5] == 's') && (str[6] == 'c'))//graphsc
00203             {
00204                 for (int i = 10;i <=leng;i++)
00205                 {
00206                     if (str[i] == '>')
00207                         graphsc[i-10]='\0';
00208                     else
00209                         graphsc[i-10]=str[i];
00210 
00211 
00212                 }
00213 
00214             }
00215             if ((str[0] =='g') && (str[1] =='r') && (str[4] == 'h') && (str[5] == 's') && (str[6] == 'a'))//graphsa
00216             {
00217                 for (int i = 10;i <=leng;i++)
00218                 {
00219                     if (str[i] == '>')
00220                         graphsc[i-10]='\0';
00221                     else
00222                         graphsc[i-10]=str[i];
00223 
00224 
00225                 }
00226 
00227 
00228             }
00229             if ((str[0] =='M') && (str[1] =='a') && (str[4] == '_') && (str[5] == 'w') && (str[7] == 'd'))//Main_W
00230             {
00231                 for (int i = 13;i <=leng;i++)
00232                 {
00233                     if (str[i] == '>')
00234                         Main_width[i-13]='\n';
00235                     else
00236                         Main_width[i-13]=str[i];
00237 
00238 
00239 
00240                 }
00241                 QString test;
00242                 test.append("|");
00243                 test.append(Main_width);
00244                 test.append("|");
00245                 QMessageBox::information(this,"test",test);
00246 
00247             }
00248             if ((str[0] =='M') && (str[1] =='a') && (str[4] == '_') && (str[5] == 'h') && (str[7] == 'g'))//Main_h
00249             {
00250                 for (int i = 16;i <=leng;i++)
00251                 {
00252                     if (str[i] == '>')
00253                         Main_highth[i-16]='\0';
00254                     else
00255                         Main_highth[i-16]=str[i];
00256 
00257 
00258                 }
00259                 QString test;
00260                 test.append("|");
00261                 test.append(Main_highth);
00262                 test.append("|");
00263                 QMessageBox::information(this,"test",test);
00264 
00265             }
00266         }
00267 
00268 
00269 
00270 
00271     Swidget = new QWidget(this);
00272     QVBoxLayout *Main_Layout = new QVBoxLayout(Swidget);
00273 
00274     QHBoxLayout *windows1 = new QHBoxLayout;
00275     QHBoxLayout *windows2 = new QHBoxLayout;
00276     QVBoxLayout *vb = new QVBoxLayout;
00277 
00278     QLabel *LTitle =  new QLabel("Title");
00279     QLineEdit *ETitle = new QLineEdit;
00280     QLabel *LWidth = new QLabel("Window width: ");
00281     QLabel *Lhighth = new QLabel("Window highth: ");
00282     QSpinBox *WWidth = new QSpinBox;
00283     QSpinBox *Whighth = new QSpinBox;
00284     WWidth->setRange(0,1600);
00285     Whighth->setRange(0,1200);
00286     //write_to_file("debug.tsD",Main_highth);
00287     int tempw;
00288     int temph;
00289     bool ok;
00290     QString kk = "1234";
00291     tempw = kk.toInt();
00292     temph = Main_highth.toUInt(&ok,10);
00293 
00294     qDebug() << "Tempw" <<tempw << "and the string" <<Main_width;
00295     qDebug() << "Temph" <<temph << "and the string" <<Main_highth;
00296 
00297     WWidth->setValue(tempw);
00298     Whighth->setValue(temph);
00299     ETitle->setText(Title);
00300     //WWidth->setValue(1000);
00301     //Whighth->setValue(350);
00302     windows1->addWidget(LTitle);
00303     windows1->addWidget(ETitle);
00304     windows2->addWidget(LWidth);
00305     windows2->addWidget(WWidth);
00306     windows2->addWidget(Lhighth);
00307     windows2->addWidget(Whighth);
00308     vb->addLayout(windows1);
00309     vb->addSpacing(5);
00310     vb->addLayout(windows2);
00311 
00312 
00313     QVBoxLayout *gcvb = new QVBoxLayout;
00314     QHBoxLayout *gcwindows1 = new QHBoxLayout;
00315     QHBoxLayout *gcwindows2 = new QHBoxLayout;
00316     QHBoxLayout *gcwindows3 = new QHBoxLayout;
00317 
00318     QLabel *LCGraphBox = new QLabel("Settings for <Current Value> Graph");
00319     QLabel *LCcolour = new QLabel("Colour :");
00320     QLabel *LCStyle = new QLabel("Style: ");
00321     QComboBox *CGcspin = new QComboBox;
00322     QComboBox *CGsspin = new QComboBox;
00323 
00324 
00325     CGcspin->addItem("Red");
00326     CGcspin->addItem("Blue");
00327     CGcspin->addItem("Yellow");
00328     CGcspin->addItem("Green");
00329     CGcspin->addItem("Black");
00330 
00331 
00332 
00333     CGsspin->addItem("Lines");
00334     CGsspin->addItem("Sticks");
00335     CGsspin->addItem("Steps");
00336     CGsspin->addItem("Dots");
00337     CGsspin->addItem("NoCurve");
00338 
00339 
00340     gcwindows1->addWidget(LCcolour);
00341     gcwindows1->addWidget(CGcspin);
00342     gcwindows2->addWidget(LCStyle);
00343     gcwindows2->addWidget(CGsspin);
00344     gcwindows3->addLayout(gcwindows1);
00345     gcwindows3->addLayout(gcwindows2);
00346     gcvb->addWidget(LCGraphBox);
00347     gcvb->addLayout(gcwindows3);
00348 
00349 
00350     QVBoxLayout *gavb = new QVBoxLayout;
00351     QHBoxLayout *gawindows1 = new QHBoxLayout;
00352     QHBoxLayout *gawindows2 = new QHBoxLayout;
00353     QHBoxLayout *gawindows3 = new QHBoxLayout;
00354 
00355     QLabel *LAGraphBox = new QLabel("Settings for <Current Value> Graph");
00356     QLabel *LAcolour = new QLabel("Colour :");
00357     QLabel *LAStyle = new QLabel("Style: ");
00358     QComboBox *AGcspin = new QComboBox;
00359     QComboBox *AGsspin = new QComboBox;
00360 
00361     AGcspin->addItem("Red");
00362     AGcspin->addItem("Blue");
00363     AGcspin->addItem("Yellow");
00364     AGcspin->addItem("Green");
00365     AGcspin->addItem("Black");
00366 
00367     AGsspin->addItem("Lines");
00368     AGsspin->addItem("Sticks");
00369     AGsspin->addItem("Steps");
00370     AGsspin->addItem("Dots");
00371     AGsspin->addItem("NoCurve");
00372 
00373     gawindows1->addWidget(LAcolour);
00374     gawindows1->addWidget(AGcspin);
00375     gawindows2->addWidget(LAStyle);
00376     gawindows2->addWidget(AGsspin);
00377     gawindows3->addLayout(gawindows1);
00378     gawindows3->addLayout(gawindows2);
00379     gavb->addWidget(LAGraphBox);
00380     gavb->addLayout(gawindows3);
00381 
00382 
00383 
00384     QHBoxLayout *bbox = new QHBoxLayout;
00385     QPushButton *bOK = new QPushButton("OK");
00386     QPushButton *bApply = new QPushButton("Apply");
00387     QPushButton *bCancel = new QPushButton("Cancel");
00388     bbox->addWidget(bOK);
00389     bbox->addWidget(bApply);
00390     bbox->addWidget(bCancel);
00391     connect(bCancel,SIGNAL(clicked()),this, SLOT(close()));
00392 
00393     Main_Layout->addLayout(vb);
00394     Main_Layout->addSpacing(5);
00395     Main_Layout->addLayout(gcvb);
00396     Main_Layout->addSpacing(5);
00397     Main_Layout->addLayout(gavb);
00398     Main_Layout->addSpacing(5);
00399     Main_Layout->addLayout(bbox);
00400 
00401 
00402 }
00403 
00415 DeviceEditDialog::DeviceEditDialog(int mode, QWidget *parent) : QDialog (parent)
00416 {
00417     QString dDev;
00418     QString vID;
00419     QString pID;
00420     int leng = 0;
00421 
00422 
00423     if (mode == 1)
00424     {
00425         //USB
00426         QFile usb(USB_SETTINGS_TSS);
00427         usb.open(QIODevice::ReadOnly);
00428 
00429         QTextStream fs(&usb);    // read the data serialized from the file
00430 
00431         str.clear();
00432         while (!fs.atEnd())
00433         {
00434             leng = 0;
00435             str=fs.readLine();
00436             leng = str.length();
00437             if (str[0] == '#')
00438                 continue;
00439 
00440             if ((str[0] =='c') && (str[6] == 'v'))
00441             {
00442                 for (int i = 12;i <=leng;i++)
00443                 {
00444                     if(str[i] == '>')
00445                         vID[i-12]='\0';
00446                     else
00447                         vID[i-12]=str[i];
00448 
00449 
00450                 }
00451 
00452             }
00453             if ((str[0] =='c') && (str[6] == 'p'))
00454             {
00455                 for (int i = 12;i <=leng;i++)
00456                 {
00457                     if (str[i] == '>')
00458                         pID[i-12]='\0';
00459                     else
00460                         pID[i-12]=str[i];
00461 
00462 
00463                 }
00464 
00465             }
00466         }
00467 
00468 
00469     }
00470     else if (mode == 0)
00471     {
00472 
00473     }
00474     else
00475     {
00476         QMessageBox::about(this,tr("Error!"), tr("Error connecting to correct Settings! Please try again"));
00477         return;
00478     }
00479 
00480     QWidget *MainW = new QWidget(this);
00481 
00482     QVBoxLayout *Main_layout= new QVBoxLayout(MainW);
00483 
00484   //  QVBoxLayout *Devb = new QVBoxLayout;
00485   //  QHBoxLayout *devt = new QHBoxLayout;
00486  //   QHBoxLayout *devb = new QHBoxLayout;
00487 
00488     QVBoxLayout *Cb = new QVBoxLayout;
00489     QHBoxLayout *Ctt = new QHBoxLayout;
00490     QHBoxLayout *Ctb = new QHBoxLayout;
00491 
00492 
00493  //   QVBoxLayout *Bb = new QVBoxLayout(newg);
00494     QHBoxLayout *Bbt = new QHBoxLayout;
00495 
00496 
00497    // dev = new QLabel("Device: ");
00498     LVendorID = new QLabel("Vendor ID: ");
00499     LProductID = new QLabel("Product ID :");
00500    // BCustom = new QPushButton("Custom");
00501     BUsave = new QPushButton("Save");
00502     BCancel = new QPushButton("Cancel");
00503     EVendorID = new QLineEdit;
00504     EProductID = new QLineEdit;
00505     Cb_dev = new QComboBox;
00506     EVendorID->setText(vID);
00507     EProductID->setText(pID);
00508 
00509 
00510 
00511 
00512     //LVendorID->setDisabled(true);
00513    // LProductID->setDisabled(true);
00514   //  EVendorID->setDisabled(true);
00515   //  EProductID->setDisabled(true);
00516 
00517 
00518  //   devt->addWidget(dev);
00519   //  devt->addWidget(Cb_dev);
00520  //   devb->addWidget(BCustom);
00521     //Devb->addLayout(devt);
00522    // Devb->addLayout(devb);
00523 
00524 
00525 
00526     Ctt->addWidget(LVendorID);
00527     Ctt->addWidget(EVendorID);
00528     Ctb->addWidget(LProductID);
00529     Ctb->addWidget(EProductID);
00530     Cb->addLayout(Ctt);
00531     Cb->addLayout(Ctb);
00532 
00533 
00534     Bbt->addWidget(BUsave);
00535     Bbt->addWidget(BCancel);
00536 
00537     //Bb->addLayout(Bbt);
00538 
00539    // Main_layout->addLayout(Devb);
00540    // Main_layout->addSpacing(5);
00541     Main_layout->addLayout(Cb);
00542     Main_layout->addSpacing(5);
00543     Main_layout->addLayout(Bbt);
00544     //connect(BCustom,SIGNAL(clicked()),this,SLOT(enable_custome()));
00545     connect(BCancel,SIGNAL(clicked()), this, SLOT(close()));
00546     connect(BUsave,SIGNAL(clicked()), this, SLOT(bsave()));
00547     //connect(BImport,SIGNAL(clicked()), this, SLOT(bImport()));
00548 
00549 
00550 
00551 
00552 }
00553 
00564 SDeviceEditDialog::SDeviceEditDialog(QWidget *parent, gui_settings *sett) : QDialog(parent)
00565 {
00566 
00567 
00568     QWidget *MainW = new QWidget(this);
00569 
00570     QVBoxLayout *Main_layout= new QVBoxLayout(MainW);
00571 
00572     QVBoxLayout *Devb = new QVBoxLayout;
00573     QHBoxLayout *devt = new QHBoxLayout;
00574 
00575 
00576 
00577 
00578 
00579  //   QVBoxLayout *Bb = new QVBoxLayout(newg);
00580     QHBoxLayout *Bbt = new QHBoxLayout;
00581 
00582 
00583     dev = new QLabel("Device: ");
00584 
00585     Bsave = new QPushButton("Save");
00586     BCancel = new QPushButton("Cancel");
00587 
00588     Edev = new QLineEdit;
00589     Edev->setText(sett->SerialDevice);
00590 
00591 
00592 
00593     devt->addWidget(dev);
00594     devt->addWidget(Edev);
00595     Devb->addLayout(devt);
00596 
00597 
00598     Bbt->setAlignment(Qt::AlignRight);
00599     Bbt->addWidget(Bsave);
00600 
00601     Bbt->addWidget(BCancel);
00602 
00603     //Bb->addLayout(Bbt);
00604 
00605     Main_layout->addLayout(Devb);
00606     Main_layout->addSpacing(5);
00607     Main_layout->addLayout(Bbt);
00608 
00609     connect(BCancel,SIGNAL(clicked()), this, SLOT(close()));
00610     connect(Bsave,SIGNAL(clicked()), this, SLOT(save_set()));
00611 
00612 
00613 
00614 }
00615 
00616 void SDeviceEditDialog::save_set() {
00617     QString temp;
00618     temp.clear();
00619     temp.append("#This is a a config for a Project for EZB Technikum Wien BEL4.\n");
00620     temp.append("#<CNC-Cntrl-config\n");
00621     temp.append("#(c) 2004 - 2012, Trilog Studios<Ron Ablinger>\n");
00622     temp.append("#------------------------------------------------------\n");
00623     temp.append("#This file is formated for tsc,tsi,tsd filetype reading!\n\n\n");
00624     temp.append("TSS\n");
00625     temp.append("SERIAL_DEV|");
00626     temp.append(Edev->text());
00627 
00628     QFile tempout(SERIAL_SETTINGS_TSS);
00629     tempout.open(QFile::WriteOnly | QFile::Text);
00630     QTextStream out(&tempout);
00631     QApplication::setOverrideCursor(Qt::WaitCursor);
00632     out <<temp<< endl;
00633     QApplication::restoreOverrideCursor();
00634     tempout.close();
00635     //OKb->setEnabled(false);
00636     //Cancelb->setText("Close");
00637     QMessageBox::information(this, tr("Please restart application!"), tr("To activate new settings, please restart the application!"));
00638     close();
00639 
00640 }
00641 
00652 BDeviceEditDialog::BDeviceEditDialog(QWidget *parent) : QDialog(parent)
00653 {
00654 
00655     int leng;
00656     QString DataB;
00657     QString parity;
00658     QString StopB;
00659     QString dDev;
00660     QString Brate;
00661 
00662 
00663 
00664     QFile usb(SERIAL_SETTINGS_TSS);
00665     usb.open(QIODevice::ReadOnly);
00666 
00667     QTextStream fs(&usb);    // read the data serialized from the file
00668 
00669     str.clear();
00670     while (!fs.atEnd())
00671     {
00672         leng = 0;
00673         str=fs.readLine();
00674         leng = str.length();
00675         if (str[0] == '#')
00676             continue;
00677         if ((str[0] =='d') && (str[3] == '_') && (str[6] == 'v'))//default devices
00678         {
00679             for (int i = 10;i <=leng;i++)
00680             {
00681                 if (str[i] == '>')
00682                     dDev[i-10]='\0';
00683                 else
00684                     dDev[i-10]=str[i];
00685 
00686 
00687             }
00688 
00689 
00690         }
00691         if ((str[0] =='b') && (str[2] == 'u') && (str[5] == 'a') && (str[6] == 't'))//baudrate
00692         {
00693             for (int i = 11;i <=leng;i++)
00694             {
00695                 if (str[i] == '>')
00696                     Brate[i-11]='\0';
00697                 else
00698                     Brate[i-11]=str[i];
00699 
00700 
00701             }
00702 
00703          }
00704         if ((str[0] =='d') && (str[3] == 'a') && (str[5] == 'i') && (str[6] == 't'))//databits
00705         {
00706             for (int i = 11;i <=leng;i++)
00707             {
00708                 if (str[i] == '>')
00709                     DataB[i-11]='\0';
00710                 else
00711                     DataB[i-11]=str[i];
00712 
00713 
00714             }
00715 
00716 
00717         }
00718         if ((str[0] =='s') && (str[3] == 'p') && (str[5] == 'i') && (str[6] == 't'))//stopbits
00719         {
00720             for (int i = 11;i <=leng;i++)
00721             {
00722                 if(str[i] == '>')
00723                     StopB[i-11]='\0';
00724                 else
00725                     StopB[i-11]=str[i];
00726 
00727 
00728             }
00729 
00730         }
00731         if ((str[0] =='p') && (str[2] == 'r') && (str[3] == 'i') && (str[5] == 'y'))//parity
00732         {
00733             for (int i = 12;i <=leng;i++)
00734             {
00735                 if (str[i] == '>')
00736                     parity[i-9]='\0';
00737                 else
00738                     parity[i-9]=str[i];
00739 
00740 
00741             }
00742 
00743         }
00744     }
00745 
00746 
00747 
00748 
00749     QWidget *MainW = new QWidget(this);
00750 
00751     QVBoxLayout *Main_layout= new QVBoxLayout(MainW);
00752 
00753     QVBoxLayout *Devb = new QVBoxLayout;
00754     QHBoxLayout *devt = new QHBoxLayout;
00755 
00756     QVBoxLayout *Cb = new QVBoxLayout;
00757     QHBoxLayout *Ctt = new QHBoxLayout;
00758     QHBoxLayout *Ctb = new QHBoxLayout;
00759     QHBoxLayout *Cbt = new QHBoxLayout;
00760     QHBoxLayout *Cbb = new QHBoxLayout;
00761 
00762 
00763 
00764  //   QVBoxLayout *Bb = new QVBoxLayout(newg);
00765     QHBoxLayout *Bbt = new QHBoxLayout;
00766 
00767 
00768     dev = new QLabel("Device: ");
00769     Lbaud = new QLabel("Baud Rate: ");
00770     Ldatab = new QLabel("Data bits :");
00771     Lstopb = new QLabel("Stop bits :");
00772     Lparity = new QLabel("Parity: ");
00773 
00774     Bsave = new QPushButton("Save");
00775     BCancel = new QPushButton("Cancel");
00776 
00777     Ebaud = new QLineEdit;
00778     Ebaud->setText(Brate);
00779     Edev = new QLineEdit;
00780     Edev->setText(dDev);
00781     Edatab = new QLineEdit;
00782     Edatab->setText(DataB);
00783 
00784     Cb_stopb = new QComboBox;
00785     Cb_parity = new QComboBox;
00786 
00787     if (StopB[0] == '1')
00788     {
00789 
00790         Cb_stopb->addItem("0");
00791         Cb_stopb->addItem(StopB);
00792         Cb_stopb->addItem("2");
00793     }
00794     else if(StopB[0] == '2')
00795     {
00796 
00797         Cb_stopb->addItem("0");
00798         Cb_stopb->addItem("1");
00799         Cb_stopb->addItem(StopB);
00800 
00801 
00802     }
00803     if (StopB[0] == '0')
00804     {
00805         Cb_stopb->addItem(StopB);
00806         Cb_stopb->addItem("1");
00807         Cb_stopb->addItem("2");
00808 
00809     }
00810 
00811     devt->addWidget(dev);
00812     devt->addWidget(Edev);
00813     Devb->addLayout(devt);
00814 
00815     Ctt->addWidget(Lbaud);
00816     Ctt->addWidget(Ebaud);
00817     Ctb->addWidget(Ldatab);
00818     Ctb->addWidget(Edatab);
00819     Cbt->addWidget(Lstopb);
00820     Cbt->addWidget(Cb_stopb);
00821     Cbb->addWidget(Lparity);
00822     Cbb->addWidget(Cb_parity);
00823 
00824     Cb->addLayout(Ctt);
00825     Cb->addLayout(Ctb);
00826     Cb->addLayout(Cbt);
00827     Cb->addLayout(Cbb);
00828 
00829     Bbt->setAlignment(Qt::AlignRight);
00830     Bbt->addWidget(Bsave);
00831 
00832     Bbt->addWidget(BCancel);
00833 
00834     //Bb->addLayout(Bbt);
00835 
00836     Main_layout->addLayout(Devb);
00837     Main_layout->addSpacing(5);
00838     Main_layout->addLayout(Cb);
00839     Main_layout->addSpacing(5);
00840     Main_layout->addLayout(Bbt);
00841 
00842     connect(BCancel,SIGNAL(clicked()), this, SLOT(close()));
00843     connect(Bsave,SIGNAL(clicked()), this, SLOT(bsave()));
00844 
00845 
00846 
00847 }
00859 void DeviceEditDialog::enable_custome()
00860 {
00861     LVendorID->setEnabled(true);
00862     LProductID->setEnabled(true);
00863     EVendorID->setEnabled(true);
00864     EProductID->setEnabled(true);
00865     Cb_dev->setDisabled(true);
00866 
00867 }
00868 
00880 void DeviceEditDialog::bsave()
00881 {
00882   //  QFile file("c://test.txt");
00883    // file.open(QIODevice::WriteOnly);
00884   //  QDataStream out(&file);   // we will serialize the data into the file
00885   //  out << "welcome to the Qt World";   // serialize a string
00886     //file.close();
00887 
00888 
00889 }
00901 void ProgEditDialog::bpsave()
00902 {
00903 
00904 }
00905 
00929 DataViewDialog::DataViewDialog(QWidget *parent) : QDialog(parent)
00930 {
00931 
00932     QWidget *widget = new QWidget(this);
00933     QString str;
00934     QString desc_str;
00935     QVBoxLayout *main = new QVBoxLayout(widget);
00936 
00937 
00938     QFile desc(DESCRIPTION_FILE);
00939     desc.open(QIODevice::ReadOnly);
00940 
00941     QTextStream fs(&desc);
00942 
00943     while(!fs.atEnd())
00944     {
00945         str = fs.readLine();
00946         if(str[0] == '#')
00947             continue;
00948         desc_str.append(str);
00949 
00950     }
00951 
00952 
00953 
00954 
00955     QStringList str_list;
00956 
00957     QVBoxLayout *Desc = new QVBoxLayout;
00958     QLabel *Ldesc = new QLabel("Description:");
00959     QTextBrowser *TB = new QTextBrowser;
00960     TB->setText(desc_str);
00961 
00962     QVBoxLayout *lib = new QVBoxLayout;
00963     QLabel *Llib = new QLabel("Libraries");
00964 
00965     QFile datf(QFileDialog::getOpenFileName(this, tr("Open File"), "/home", tr("Captured Data [*.tsd]  (*.tsd);;Plot Data [*.tsp] (*.tsp)")));
00966     datf.open(QIODevice::ReadOnly);
00967 
00968    /* if(!datf.isOpen())
00969     {
00970         QMessageBox::information(this,"Error Opening File","An error has occured when opening file. Do you have permission?");
00971         return;
00972     }*/
00973     QTextStream ts(&datf);
00974 
00975 
00976     int leng = 0;
00977     QString str1;
00978     QString temp;
00979     QString temp2;
00980     QStringList row1;
00981     QStringList row2;
00982     QStringList row3;
00983     int k = 1;
00984     int y = 0;
00985     while(!ts.atEnd())
00986     {
00987 
00988 
00989         qDebug() << str1 << " " << temp;
00990         str1 = ts.readLine();
00991         k=0;
00992         qDebug() << str1;
00993         if (str1[0] == '#')
00994             continue;
00995         while(1)
00996         {
00997             qDebug() << "we r in while(1)";
00998             if (str1[k] == '>')
00999             {
01000                 temp[k-1] = ':';
01001                 //temp[k] = '\0';
01002                 break;
01003             }
01004             else
01005                 temp[k-1] = str1[k];
01006 
01007             k++;
01008 
01009         }
01010         qDebug() << "this is temp: " << temp;
01011         int v = 0;
01012         int z = 0;
01013         int x = 0;
01014         while (1)
01015         {
01016             while(temp[v] != ':')
01017             {
01018                 temp2[x] = temp[v];
01019                 v++;
01020                 x++;
01021                 qDebug() << "in temp2 loop temp2,v,x,z,temp" << temp2 <<" " << v << " " << x << " " << z << " " << temp;
01022             }
01023             qDebug() << temp2 << v << z;
01024             if(temp[v] == ':')
01025                 v++;
01026             if(z == 0)
01027                 row1 << temp2;
01028             if(z == 1)
01029                 row2 << temp2;
01030             if(z == 2)
01031                 row3 << temp2;
01032 
01033             temp2.clear();
01034             x = 0;
01035             if (z == 2)
01036                 break;
01037             z++;
01038 
01039         }
01040 
01041     }
01042 
01043 
01044 
01045   /*  QTableWidget *Tw = new QTableWidget;
01046 
01047     str_list << "test1" << "test2";
01048     Tw->setHorizontalHeaderLabels(str_list);
01049 
01050    // items << tr("T-shirt") << tr("Badge") << tr("Reference book")
01051                //<< tr("Coffee cup");
01052 
01053          itemsTable = new QTableWidget(items.count(), 2);
01054 
01055          for (int row = 0; row < items.count(); ++row) {
01056              QTableWidgetItem *name = new QTableWidgetItem(items[row]);
01057              name->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
01058              itemsTable->setItem(row, 0, name);
01059              QTableWidgetItem *quantity = new QTableWidgetItem("1");
01060              itemsTable->setItem(row, 1, quantity);
01061          }
01062 
01063 
01064 
01065 */
01066 
01067 }
01068 
01069 netSetupDialog::netSetupDialog(QWidget *parent, gui_settings *sett) : QDialog(parent){
01070 
01071 
01072     QWidget *widget = new QWidget(this);
01073     QVBoxLayout *main = new QVBoxLayout(widget);
01074     QHBoxLayout *ipl = new QHBoxLayout;
01075     QHBoxLayout *pol = new QHBoxLayout;
01076     QHBoxLayout *Tol = new QHBoxLayout;
01077    // QHBoxLayout *debl = new QHBoxLayout;
01078     QHBoxLayout *button_l = new QHBoxLayout;
01079     main->addLayout(ipl);
01080     main->addLayout(pol);
01081     main->addLayout(Tol);
01082    // main->addLayout(debl);
01083     main->addLayout(button_l);
01084     QLabel *ip_address = new QLabel(tr("IP address: "));
01085     QLabel *port = new QLabel(tr("Port: "));
01086     QLabel *Ltimeout =  new QLabel(tr("Timeout: "));
01087     ipAE = new QLineEdit;
01088     ports = new QSpinBox;
01089     ports->setRange(0,65000);
01090     OKb = new QPushButton("&Ok");
01091     Cancelb = new QPushButton("&Cancel");
01092     Stimeout = new QSpinBox;
01093     Stimeout->setRange(0,10000);
01094     QCheckBox *debug_en = new QCheckBox;
01095     debug_en->setText("Enable TCP/IP debuging");
01096     ipl->addWidget(ip_address);
01097     ipl->addWidget(ipAE);
01098     pol->addWidget(port);
01099     pol->addWidget(ports);
01100     Tol->addWidget(Ltimeout);
01101     Tol->addWidget(Stimeout);
01102     button_l->addWidget(OKb);
01103     button_l->addWidget(Cancelb);
01104     ipAE->setText(sett->TCPaddress);
01105     ports->setValue(sett->TCPport);
01106     Stimeout->setValue(sett->TCPStdtimeout);
01107 
01108 
01109 
01110 
01111  //   debl->addWidget(debug_en);
01112     connect(Cancelb,SIGNAL(clicked()), this,SLOT(close()));
01113     connect(OKb,SIGNAL(clicked()), this, SLOT(save_sett()));
01114     //close();
01115 }
01116 void netSetupDialog::save_sett() {
01117     QString temp;
01118     QString sport;
01119     QString stime;
01120     sport.setNum(ports->value());
01121     stime.setNum(Stimeout->value());
01122     temp.clear();
01123     temp.append("#This is a a config for a Project for EZB Technikum Wien BEL4.\n");
01124     temp.append("#<CNC-Cntrl-config\n");
01125     temp.append("#(c) 2004 - 2012, Trilog Studios<Ron Ablinger>\n");
01126     temp.append("#------------------------------------------------------\n");
01127     temp.append("#This file is formated for tsc,tsi,tsd filetype reading!\n\n\n");
01128     temp.append("TSS\n");
01129     temp.append("INET_ADD|");
01130     temp.append(ipAE->text());
01131     temp.append("\n");
01132     temp.append("INET_PORT|");
01133     temp.append(sport);
01134     temp.append("\n");
01135     temp.append("INET_DEL|");
01136     temp.append(stime);
01137 
01138     QFile tempout(TCP_SETTINGS_TSS);
01139     tempout.open(QFile::WriteOnly | QFile::Text);
01140     QTextStream out(&tempout);
01141     QApplication::setOverrideCursor(Qt::WaitCursor);
01142     out <<temp<< endl;
01143     QApplication::restoreOverrideCursor();
01144     tempout.close();
01145     //OKb->setEnabled(false);
01146     //Cancelb->setText("Close");
01147     QMessageBox::information(this, tr("Please restart application!"), tr("To activate new settings, please restart the application!"));
01148     close();
01149      //netSetupDialog.close();
01150 }
01151 
01152 
01153 
01154 
01155 Dialog::Dialog(QWidget *parent, gui_settings *sett) : QDialog(parent), P_ui(new Ui::Dialog) {
01156 P_ui->setupUi(this);
01157 
01158 if (sett->Progenlog == 1) {
01159     P_ui->checkBox->setChecked(true);
01160     P_ui->lineEdit->setEnabled(true);
01161     P_ui->pushButton->setEnabled(true);
01162 }
01163 else {
01164     P_ui->checkBox->setChecked(false);
01165     P_ui->lineEdit->setEnabled(false);
01166     P_ui->pushButton->setEnabled(false);
01167 }
01168 if (sett->Progenkill == 1)
01169     P_ui->checkBox_3->setChecked(true);
01170 else
01171     P_ui->checkBox_3->setChecked(false);
01172 
01173 if (sett->Progenuartdb == 1)
01174     P_ui->checkBox_2->setChecked(true);
01175 else
01176     P_ui->checkBox_2->setChecked(false);
01177 
01178 P_ui->lineEdit->setText(sett->Proglogpath);
01179 
01180 
01181 
01182 connect(P_ui->pushButton_2,SIGNAL(clicked()),this,SLOT(save_sett()));
01183 connect(P_ui->pushButton_3,SIGNAL(clicked()), this, SLOT(close()));
01184 connect(P_ui->checkBox, SIGNAL(toggled(bool)),this, SLOT(enable_edit()));
01185 connect(P_ui->pushButton,SIGNAL(clicked()),this,SLOT(get_log_path()));
01186 
01187 
01188 }
01189 
01190 
01191 void Dialog::enable_edit() {
01192     if (P_ui->checkBox->isChecked()) {
01193         P_ui->lineEdit->setEnabled(true);
01194         P_ui->pushButton->setEnabled(true);
01195     }
01196     else {
01197         P_ui->lineEdit->setEnabled(false);
01198         P_ui->pushButton->setEnabled(false);
01199     }
01200 }
01201 void Dialog::save_sett() {
01202     QString temp;
01203     QString sc1;
01204     QString sc2;
01205     QString sc3;
01206     int c1 = 0, c2 = 0, c3 = 0;
01207     if (P_ui->checkBox->isChecked())
01208         c1 = 1;
01209     else
01210         c1 = 0;
01211     if (P_ui->checkBox_2->isChecked())
01212         c2 = 1;
01213     else
01214         c2 = 0;
01215     if (P_ui->checkBox_3->isChecked())
01216         c3 = 1;
01217     else
01218         c3 = 0;
01219 
01220     sc1.setNum(c1);
01221     sc2.setNum(c2);
01222     sc3.setNum(c3);
01223     temp.clear();
01224     temp.append("#This is a a config for a Project for EZB Technikum Wien BEL4.\n");
01225     temp.append("#<CNC-Cntrl-config\n");
01226     temp.append("#(c) 2004 - 2012, Trilog Studios<Ron Ablinger>\n");
01227     temp.append("#------------------------------------------------------\n");
01228     temp.append("#This file is formated for tsc,tsi,tsd filetype reading!\n\n\n");
01229     temp.append("TSS\n");
01230     temp.append("PROG_enLOG|");
01231     temp.append(sc1);
01232     temp.append("\n");
01233     temp.append("PROG_LOGP|");
01234     temp.append(P_ui->lineEdit->text());
01235     temp.append("\n");
01236     temp.append("PROG_UARTDB|");
01237     temp.append(sc2);
01238     temp.append("\n");
01239     temp.append("PROG_CNCkill|");
01240     temp.append(sc3);
01241 
01242 
01243     QFile tempout(PROG_SETTINGS_TSS);
01244     tempout.open(QFile::WriteOnly | QFile::Text);
01245     QTextStream out(&tempout);
01246     QApplication::setOverrideCursor(Qt::WaitCursor);
01247     out <<temp<< endl;
01248     QApplication::restoreOverrideCursor();
01249     tempout.close();
01250     //OKb->setEnabled(false);
01251     //Cancelb->setText("Close");
01252     QMessageBox::information(this, tr("Please restart application!"), tr("To activate new settings, please restart the application!"));
01253     close();
01254      //netSetupDialog.close();
01255 }
01256 
01257 
01258 void Dialog::get_log_path() {
01259     fileName = QFileDialog::getSaveFileName(this,
01260                             tr("Choose a file name"), ".",
01261                             tr("TSLog [*.tsl] (*.tsl)"));
01262     if (fileName.isEmpty()) {
01263         fileName.clear();
01264         fileName.append("TSDefLog.tsl");
01265     }
01266     else
01267         fileName.append(".tsl");
01268 #if DEBUG
01269     qDebug() << "Dialog::get_log_path()| filename: " << fileName;
01270 #endif
01271     P_ui->lineEdit->setText(fileName);
01272 
01273 }
01274 
01275 PassWD::PassWD(QWidget *parent) : QDialog(parent), ui_Pw(new Ui_PW::PassWD) {
01276 ui_Pw->setupUi(this);
01277 connect(ui_Pw->pushButton,SIGNAL(clicked()),this, SLOT(testPW()));
01278 
01279 }
01280 
01281 void PassWD::testPW() {
01282     QString uname;
01283     uname.clear();
01284     QString passwd;
01285     passwd.clear();
01286 
01287     uname = ui_Pw->lineEdit->text();
01288     passwd = ui_Pw->lineEdit_2->text();
01289     if (uname.isEmpty())
01290     {
01291         //userid = 500;
01292 #if DEBUG
01293         qDebug() << "PassWD::testPw()| no username --> setting default user 500";
01294 #endif
01295         close();
01296     }
01297     if (passwd.isEmpty())
01298     {
01299         QMessageBox::critical(this, "No password Supplied","Please Supply a password");
01300         ui_Pw->lineEdit_2->clear();
01301     }
01302     QString temp;
01303     temp.clear();
01304     int z;
01305     z =0;
01306     z = (passwd.length() * uname.length() + sin(BUILD_V-uname.length()))/(BUILD_V*cos(passwd.length()));
01307 #if DEBUG
01308     qDebug() << "PassWD::testPW()| z is :" << z;
01309 #endif
01310 
01311 }
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Defines