Fork me on GitHub
2.15.20
FGx
A cross-platform launcher for FlightGear
networkwidget.cpp
Go to the documentation of this file.
1 // -=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-
2 // FGx FlightGear Launcher // networkwidget.cpp
3 // -=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-
4 // (c) 2010-2012
5 // Yves Sablonier, Pete Morgan
6 // Geoff McLane
7 // GNU GPLv2, see main.cpp and shipped licence.txt for further information
8 
9 #include <QString>
10 #include <QChar>
11 #include <QMap>
12 #include <QMapIterator>
13 #include <QUrl>
14 
15 #include <QProcess>
16 
17 #include <QHostInfo>
18 #include <QHostAddress>
19 #include <QNetworkInterface>
20 
21 #include <QDesktopServices>
22 #include <QBrush>
23 #include <QColor>
24 
25 #include <QVBoxLayout>
26 #include <QHBoxLayout>
27 #include <QGridLayout>
28 
29 #include <QAction>
30 #include <QMenu>
31 #include <QLabel>
32 #include <QTreeWidgetItem>
33 #include <QHeaderView>
34 #include <QToolButton>
35 #include <QPushButton>
36 
37 #include "network/networkwidget.h"
38 #include "network/mptelnet.h"
39 #include "utilities/helpers.h"
40 
41 
42 
44  QWidget(parent)
45 {
46 
47  mainObject = mOb;
48 
49  //* Main Layout
50  QVBoxLayout *mainLayout = new QVBoxLayout();
51  setLayout(mainLayout);
52  mainLayout->setSpacing(0);
53  int m = 10;
54  mainLayout->setContentsMargins(m,m,m,m);
55 
56 
57  //** MiddleLayout
58  QHBoxLayout *middleLayout = new QHBoxLayout();
59  mainLayout->addLayout(middleLayout);
60  middleLayout->setSpacing(10);
61  int mm = 10;
62  middleLayout->setContentsMargins(mm,mm,mm,mm);
63 
64  //====================================================
65  //== Mp IN
66  QVBoxLayout *leftLayout = new QVBoxLayout();
67  middleLayout->addLayout(leftLayout, 1);
68 
69  grpMpServerIn = new XGroupHBox("MultiPlayer In");
70  grpMpServerIn->setCheckable(true);
71  leftLayout->addWidget(grpMpServerIn);
72  connect(grpMpServerIn, SIGNAL(toggled(bool)), this, SLOT(set_mp_server()));
73 
74 
75  comboLocalIpAddress = new QComboBox();
77  connect(comboLocalIpAddress, SIGNAL(currentIndexChanged(int)), this, SLOT(set_mp_server()));
78 
79  grpMpServerIn->addWidget(new QLabel("port"));
80 
81  comboLocalPort = new QComboBox();
82  comboLocalPort->addItem("5000", "5000");
83  comboLocalPort->addItem("5001", "5001");
84  comboLocalPort->setEditable(true);
85  comboLocalPort->setValidator( new QIntValidator(1000, 30000, this) );
87  connect(comboLocalPort, SIGNAL(currentIndexChanged(int)), this, SLOT(set_mp_server()));
88 
89  grpMpServerIn->addWidget(new QLabel("at"));
90  comboHzIn = new QComboBox();
93  connect(comboHzIn, SIGNAL(currentIndexChanged(int)), this, SLOT(set_mp_server()));
94  grpMpServerIn->addWidget(new QLabel("Hz"));
95 
96  grpMpServerIn->xLayout->addStretch(20);
97 
98 
99  //===============================================
100  //== Mp Out
101  grpMpServerOut = new XGroupVBox("MultiPlayer Out");
102  grpMpServerOut->setCheckable(true);
103  leftLayout->addWidget(grpMpServerOut);
104  connect(grpMpServerOut, SIGNAL(toggled(bool)), this, SLOT(set_mp_server()));
105 
106  QHBoxLayout *layMpOutControl = new QHBoxLayout();
107  grpMpServerOut->addLayout(layMpOutControl);
108 
109  comboRemoteAddress = new QComboBox();
110  comboRemoteAddress->addItem(tr("Use domain"), "domain");
111  comboRemoteAddress->addItem(tr("Use IP"), "ip");
112  comboRemoteAddress->setCurrentIndex(0);
113  layMpOutControl->addWidget(comboRemoteAddress);
114  connect(comboRemoteAddress, SIGNAL(currentIndexChanged(int)), this, SLOT(set_mp_server()));
115 
116  layMpOutControl->addWidget(new QLabel("port"));
117 
118  comboRemotePort = new QComboBox();
119  comboRemotePort->addItem("5000", "5000");
120  comboRemotePort->addItem("5001", "5001");
121  comboRemotePort->setEditable(true);
122  comboRemotePort->setValidator( new QIntValidator(1000, 30000, this) );
123  layMpOutControl->addWidget(comboRemotePort);
124  connect(comboRemotePort, SIGNAL(currentIndexChanged(int)), this, SLOT(set_mp_server()));
125 
126  layMpOutControl->addWidget(new QLabel("at"));
127  comboHzOut = new QComboBox();
128  layMpOutControl->addWidget(comboHzOut);
130  connect(comboHzOut, SIGNAL(currentIndexChanged(int)), this, SLOT(set_mp_server()));
131 
132  layMpOutControl->addWidget(new QLabel("Hz"));
133 
134  layMpOutControl->addStretch(20);
135 
136  QVBoxLayout *mpTreeLayout = new QVBoxLayout();
137  grpMpServerOut->addLayout(mpTreeLayout);
138 
139  //=======================================
140  //* TreeWidget
141  treeWidget = new QTreeWidget();
142  mpTreeLayout->addWidget(treeWidget, 100);
143  treeWidget->setAlternatingRowColors(true);
144  treeWidget->setRootIsDecorated(false);
145  treeWidget->setSortingEnabled(true);
146  treeWidget->sortByColumn(C_SERVER_NAME, Qt::AscendingOrder);
147  //treeWidget->setMinimumWidth();
148 
149  QTreeWidgetItem * headerItem = treeWidget->headerItem();
150  headerItem->setText(C_SERVER_NAME, tr("Name"));
151  headerItem->setText(C_DOMAIN, tr("Domain"));
152  headerItem->setText(C_IP_ADDRESS, tr("IP Address"));
153  headerItem->setText(C_PILOTS_COUNT, tr("Pilots"));
154  headerItem->setText(C_FLAG, "-");
155  treeWidget->header()->setStretchLastSection(true);
156  treeWidget->setColumnWidth(C_SERVER_NAME, 100);
157  treeWidget->setColumnWidth(C_DOMAIN, 100);
158  treeWidget->setColumnWidth(C_PILOTS_COUNT, 50);
159  treeWidget->setColumnHidden(C_PILOTS_COUNT, true); // To be reimplemented
160 
161  treeWidget->setColumnHidden(C_DOMAIN, true);
162  treeWidget->setColumnHidden(C_FLAG, true);
163  //treeWidget->setColumnHidden(C_PILOTS_COUNT, true);
164 
165  connect(treeWidget, SIGNAL(itemSelectionChanged()), this, SLOT(set_mp_server()));
166 
167  //************* Bottom Layout
168  QHBoxLayout *layoutBottomTreeBar = new QHBoxLayout();
169  mpTreeLayout->addLayout(layoutBottomTreeBar);
170  layoutBottomTreeBar->addStretch(30);
171 
172  //* refresh MP servers
173  QToolButton *refreshButton = new QToolButton(this);
174  layoutBottomTreeBar->addWidget(refreshButton);
175  refreshButton->setText("Refresh Server List");
176  refreshButton->setAutoRaise(true);
177  refreshButton->setIcon(QIcon(":/icon/load"));
178  refreshButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
179  connect(refreshButton, SIGNAL(clicked()), this, SLOT(dns_lookup()) );
180 
181 
182 
183  //=================================================================================================
184  // RIGHT side >>>>
185  //=================================================================================================
186  QVBoxLayout *rightLayout = new QVBoxLayout();
187  rightLayout->setSpacing(20);
188  middleLayout->addLayout(rightLayout, 1);
189 
190  //========================================================================
191  // FgCom Box
192  grpFgCom = new XGroupGBox(tr("FGCom - Voice Communications"));
193  rightLayout->addWidget(grpFgCom, 2);
194  grpFgCom->setCheckable(true);
195  connect(grpFgCom, SIGNAL(clicked()), this, SLOT(set_fgcom()));
196 
197  QString style("font-size: 8pt; color: #666666;");
198 
199  // fgCom NO
200  int row = 0;
201  grpFgCom->addWidget(new QLabel("Server"), row, 0, 1, 1, Qt::AlignRight);
202  txtFgComNo = new QLineEdit("");
203  grpFgCom->addWidget(txtFgComNo, row, 1, 1, 1);
204  connect(txtFgComNo, SIGNAL(textChanged(QString)), this, SLOT(set_fgcom()));
205 
206 
207  row++;
208  QLabel *lblHelp1 = new QLabel("eg: fgcom.flightgear.org.uk");
209  lblHelp1->setStyleSheet(style);
210  grpFgCom->addWidget(lblHelp1, row, 1, 1, 2);
211 
212  //* fgCom Port
213  row++;
214  grpFgCom->addWidget(new QLabel("Port"), row, 0, 1, 1, Qt::AlignRight);
215  txtFgComPort = new QLineEdit("");
216  txtFgComPort->setMaximumWidth(100);
217  grpFgCom->addWidget(txtFgComPort, row, 1, 1, 1);
218  connect(txtFgComPort, SIGNAL(textChanged(QString)), this, SLOT(set_fgcom()));
219 
220  row++;
221  QLabel *lblHelp2 = new QLabel("eg: 16661");
222  lblHelp2->setStyleSheet(style);
223  grpFgCom->addWidget(lblHelp2, row, 1, 1, 2);
224 
225  // fgCom exe path
226  row++;
227  labelFgComProgram = new QLabel("Path to FGcom: ");
228  labelFgComCheck = new QLabel("");
229  lineEditFgComPath = new QLineEdit("");
230  lineEditFgComPath->setFixedSize(QSize(240,20));
231  buttonSetFgComPath = new QToolButton();
232  buttonSetFgComPath->setFixedSize(20,20);
233  buttonSetFgComPath->setIcon(QIcon(":/icon/path"));
234  grpFgCom->addWidget(labelFgComProgram,row, 0,1,1, Qt::AlignRight);
235  grpFgCom->addWidget(lineEditFgComPath,row, 1,1,1, Qt::AlignLeft);
236  grpFgCom->addWidget(labelFgComCheck,row, 2,1,1, Qt::AlignRight);
237  grpFgCom->addWidget(buttonSetFgComPath,row, 3,1,1, Qt::AlignRight);
239 
240  // "Set" clicked
241  connect( buttonSetFgComPath, SIGNAL(clicked()),this, SLOT(on_select_fgcombutton()) );
242 
243  //Check if path exists, set pixmap, emit setting
244  connect(lineEditFgComPath, SIGNAL(textChanged(QString)), this, SLOT(fgcom_check_path()));
245  connect(lineEditFgComPath, SIGNAL(textChanged(QString)), this, SLOT(on_fgcom_path(QString)));
246  connect(buttonSetFgComPath, SIGNAL(clicked()), this, SLOT(fgcom_set_path()));
247 
248 
249  //===========================================================
250  //** Telnet
251  grpTelnet = new XGroupHBox(tr("Telnet Properties Server"));
252  grpTelnet->setCheckable(true);
253  grpTelnet->setChecked(false);
254  rightLayout->addWidget(grpTelnet);
255  connect(grpTelnet, SIGNAL(clicked()), this, SLOT(on_telnet()));
256 
257  grpTelnet->xLayout->setSpacing(10);
258  grpTelnet->xLayout->setContentsMargins(m,m,m,m);
259 
260  QLabel *lblTelnet = new QLabel();
261  lblTelnet->setText(tr("Set Port No:"));
262  grpTelnet->addWidget( lblTelnet);
263 
264  txtTelnet = new QLineEdit("5500");
265  txtTelnet->setValidator(new QIntValidator(80, 32000, this));
267  connect(txtTelnet, SIGNAL(textChanged(QString)), this, SLOT(on_telnet()));
268 
269  QToolButton *buttTelnet = new QToolButton();
270  grpTelnet->addWidget(buttTelnet);
271  buttTelnet->setIcon(QIcon(":/icon/terminal"));
272  buttTelnet->setToolButtonStyle(Qt::ToolButtonIconOnly);
273  connect(buttTelnet, SIGNAL(clicked()), this, SLOT(on_open_telnet()));
274  buttTelnet->hide();
275 
276  //===========================================================
277  //** Screenshot
278  grpScreenShot = new XGroupHBox(tr("Screen Shot Server"));
279  grpScreenShot->setCheckable(true);
280  grpScreenShot->setChecked(false);
281  rightLayout->addWidget(grpScreenShot);
282  connect(grpScreenShot, SIGNAL(clicked()), this, SLOT(on_screenshot()) );
283 
284  grpScreenShot->xLayout->setSpacing(10);
285  grpScreenShot->xLayout->setContentsMargins(m,m,m,m);
286  grpScreenShot->addWidget( new QLabel(tr("Port No:")));
287 
288  txtScreenShot = new QLineEdit("8088");
289  txtScreenShot->setValidator(new QIntValidator(80, 32000, this));
291  connect(txtScreenShot, SIGNAL(textChanged(QString)), this, SLOT(on_screenshot()));
292 
293  QToolButton *buttScreenshot = new QToolButton();
294  grpScreenShot->addWidget(buttScreenshot);
295  buttScreenshot->setIcon(QIcon(":/icon/browse"));
296  buttScreenshot->setToolButtonStyle(Qt::ToolButtonIconOnly);
297  connect(buttScreenshot, SIGNAL(clicked()), this, SLOT(on_browse_screenshot()));
298 
299  //==========================================================
300  //** HTTP
301  grpHttp = new XGroupHBox(tr("HTTP Web Server"));
302  grpHttp->setCheckable(true);
303  grpHttp->setChecked(false);
304  rightLayout->addWidget(grpHttp);
305  connect(grpHttp, SIGNAL(clicked()), this, SLOT(on_http()));
306 
307 
308  grpHttp->addWidget( new QLabel(tr("Port No:")) );
309 
310  txtHttp = new QLineEdit("8080");
311  txtHttp->setValidator(new QIntValidator(80, 32000, this));
313  connect(txtHttp, SIGNAL(textChanged(QString)), this, SLOT(on_http()));
314 
315  QToolButton *butHttp = new QToolButton();
316  grpHttp->addWidget(butHttp);
317  butHttp->setIcon(QIcon(":/icon/browse"));
318  butHttp->setToolButtonStyle(Qt::ToolButtonIconOnly);
319  connect(butHttp, SIGNAL(clicked()), this, SLOT(on_browse_http()));
320 
321 
322  rightLayout->addStretch(20);
323 
324 
325  //** Setup network stuff
326  dns_lookup();
328  //set_mp_server();
329 
330  //== Connect Settings
331  connect(this, SIGNAL(setx(QString,bool,QString)), mainObject->X, SLOT(set_option(QString,bool,QString)) );
332  connect(mainObject->X, SIGNAL(upx(QString,bool,QString)), this, SLOT(on_upx(QString,bool,QString)));
333 
334 
335 }
336 /* end constructor */
337 
338 
339 //=============================================================
340 //** Network Addresses
342  QList<QHostAddress> addresses = QNetworkInterface::allAddresses();
343  for (int i = 0; i < addresses.size(); ++i) {
344  if(addresses.at(i).protocol() == QAbstractSocket::IPv4Protocol){
345  comboLocalIpAddress->addItem( addresses.at(i).toString(), addresses.at(i).toString() );
346  }
347  }
348 }
349 
350 
351 
352 //=============================================================
353 //** Dns Lookup All
355  treeWidget->model()->removeRows(0, treeWidget->model()->rowCount());
356  for(int i=1; i < 25; i++){
357  QString domain_name = QString("mpserver%1.flightgear.org").arg(i, 2, 10, QChar('0'));
358  QHostInfo::lookupHost(domain_name, this, SLOT(on_dns_lookup_callback(QHostInfo)));
359  }
360 }
361 
362 
363 // DNS Callback
364 void NetworkWidget::on_dns_lookup_callback(const QHostInfo &hostInfo){
365 
366  if(hostInfo.addresses().count() == 0){
367  return;
368  }
369  QTreeWidgetItem *newItem = new QTreeWidgetItem();
370  newItem->setText(C_SERVER_NAME, hostInfo.hostName().split(".")[0]);
371  newItem->setText(C_DOMAIN, hostInfo.hostName());
372  newItem->setText(C_IP_ADDRESS, hostInfo.addresses().first().toString());
373  newItem->setText(C_PILOTS_COUNT, "-");
374  treeWidget->addTopLevelItem(newItem);
375  QString serv = mainObject->X->getx("--multiplay=out");
376  if(serv.indexOf(",") > 0){
377  if(serv.split(",",QString::SkipEmptyParts).at(1) == hostInfo.hostName()){
378  treeWidget->setCurrentItem(newItem);
379  }
380  }
381  return;
382 
383  // TODO Connect to telnet and get players list
384  MpTelnet *telnet = new MpTelnet(this );
385  telnet->get_info(hostInfo.addresses().first().toString());
386  connect(telnet, SIGNAL(telnet_data(QString, QString)),
387  this, SLOT(on_telnet_data(QString, QString))
388  );
389 }
390 
391 /* Example Output >>
392 Trying 85.214.37.14...
393 Connected to mpserver01.flightgear.org.
394 Escape character is '^]'.
395 # This is mpserver01
396 # FlightGear Multiplayer Server v0.10.3 using protocol version v1.1 (LazyRelay enabled)
397 # This server is tracked: 62.112.194.20
398 # 38 pilots online
399 airdomi@LOCAL: 4107968.717705 3824275.355909 3041539.588760 28.615373 42.951713 34195.591451 -3.696031 1.916703 0.573010 Aircraft/777-200/Models/777-200ER.xml
400 minaya@mpserver10: 4008833.892465 -10727.752073 4944410.518456 51.153549 -0.153324 562.061917 -2.642317 2.096125 1.046300 Aircraft/777-200/Models/777-200ER.xml
401 */
402 void NetworkWidget::on_telnet_data(QString ip_address, QString telnet_reply){
403 
404  //** Split the reply into lines and parse each line
405  QStringList lines = telnet_reply.split("\n");
406  QString line;
407  int pilots_count = 0;
408 
409  for(int i = 0; i < lines.size(); ++i){
410 
411  line = lines.at(i).trimmed();
412  if(i == 0){
413  // skip first line
414  }else if(line.startsWith("#")){
415  // skip lines starting with #
416  }else if(line.length() == 0){
417  // skip blank lines
418  }else{
419 
420  //*** Process the line
421  QString mp_server = line.split(" ").at(0).split("@").at(1);
422  mp_server = mp_server.replace(QString(":"), QString("")); //* get rid of trailing ":" at end eg a.b.c.192:
423  //** Map to an IP address
424  if(mp_server == "LOCAL"){
425  //* Its ip_address from callback
426  pilots_count++;
427  }
428  }
429  } /* for lines() */
430 
431  //** Update the Pilots Count
432  QList<QTreeWidgetItem*> items = treeWidget->findItems(ip_address, Qt::MatchExactly, C_IP_ADDRESS);
433  items[0]->setText(C_PILOTS_COUNT, QString::number(pilots_count));
434  items[0]->setText(C_FLAG, "1");
435 }
436 
437 
438 
439 
440 //=====================================
441 // Mp Server Selected
443  QString in(",");
444  in.append(comboHzIn->currentText());
445  in.append(",");
446  in.append(comboLocalIpAddress->currentText());
447  in.append(",").append(comboLocalPort->currentText());
448 
449  emit setx("--multiplay=in", grpMpServerIn->isChecked(), in);
450 
451 
452  //if(!treeWidget->currentIndex()){
453  //treeWidget->setCu
454  //}
455  QTreeWidgetItem *item = treeWidget->currentItem();
456  //bool mp_out_valid = !item; //or item->text(C_FLAG).length() == 0;
457  if(!item){ // or item->text(C_FLAG).length() == 0){
458  //emit setx("--multiplay=in", grpMpServerIn->isChecked(), in);
459  return;
460  }
461 
462  QString out(",");
463  out.append(comboHzOut->currentText());
464  out.append(",");
465  out.append( item->text(C_IP_ADDRESS) );
466  out.append(",").append(comboRemotePort->currentText());
467 
468  //=out,10,server.ip.address,5000
469  emit setx("--multiplay=out", grpMpServerOut->isChecked(), out);
470 
471 
472 }
473 
474 
475 //=====================================
476 // Setup fgCom
478 
479  emit setx( "fgcom_enabled",
480  grpFgCom->isChecked(),
481  QString("--generic=socket,out,10,localhost,%1,udp,fgcom").arg(txtFgComPort->text())
482  );
483 
484  emit setx( "fgcom_server", grpFgCom->isChecked(), QString("%0:%1").arg(txtFgComNo->text()).arg(txtFgComPort->text()) );
485 }
486 
487 //======================================================================
488 // Check fgcom path and give some feedback
489 //======================================================================
490 
492 {
493  bool fgcom_exists = QFile::exists(lineEditFgComPath->text());
494  if (fgcom_exists) {
495  labelFgComCheck->setPixmap(QPixmap(":/icon/ok"));
496  } else {
497  labelFgComCheck->setPixmap(QPixmap(":/icon/not-ok"));
498  }
499 
500 }
501 
502 //======================================================================
503 // Set fgcom path with button
504 //======================================================================
505 
507 
508 {
509 #ifdef USE_ALTERNATE_GETFILE
510  QString filePathFgCom = util_getFileName((QWidget *)this, tr("Select fgcom binary"),
511  lineEditFgComPath->text());
512 #else // !#ifdef USE_ALTERNATE_GETFILE
513  QString filePathFgCom = QFileDialog::getOpenFileName(this, tr("Select fgcom binary"),
514  lineEditFgComPath->text());
515 #endif // #ifdef USE_ALTERNATE_GETFILE y/n
516  if(filePathFgCom.length() > 0){
517  lineEditFgComPath->setText(filePathFgCom);
518  }
519 
521 }
522 
523 //=====================================
524 // Emit fgcom path
526 {
527  emit( mainObject->X->set_option("fgcom_exe_path", true, txt));
528 }
529 
530 
531 //=====================================
532 // Setup Combo Hz
533 void NetworkWidget::populate_combo_hz(QComboBox *combo){
534  for(int i=5; i < 15; i++){
535  combo->addItem(QString("%1").arg(i), QString("%1").arg(i));
536  }
537  combo->setCurrentIndex(4);
538 }
539 
540 
541 //=================================================
542 // Open Browsers
544  QString url = QString("http://localhost:%1").arg(txtHttp ->text());
545  QDesktopServices::openUrl(QUrl(url));
546 }
547 
549  QString url = QString("http://localhost:%1").arg(txtScreenShot ->text());
550  QDesktopServices::openUrl(QUrl(url));
551 }
552 
553 //=================================================
554 // Open Telnet
556  // TODO
557 }
558 
559 
560 
561 
562 //=============================================================
563 // Validate
565  if(grpMpServerOut->isChecked()){
566  if(!treeWidget->currentItem()){
567  treeWidget->setFocus();
568  return QString("No multiplayer out server selected");;
569  }
570  }
571  return QString("");
572 }
573 
574 
575 
576 //================================================================
577 
579 {
580  emit setx("--telnet=", grpTelnet->isChecked(), txtTelnet->text());
581 }
582 
584 {
585  emit setx("--httpd=", grpHttp->isChecked(), txtHttp->text());
586 }
587 
589 {
590  emit setx("--jpg-httpd=", grpScreenShot->isChecked(), txtScreenShot->text());
591 }
592 
594  emit setx("fgcom_exe_path", true, lineEditFgComPath->text());
595 }
596 
597 //=============================================================
598 // Update Widgets
599 void NetworkWidget::on_upx(QString option, bool enabled, QString value)
600 {
601 
602 
603  if(option == "--multiplay=in" || option == "--multiplay=out"){
604 
605  // --multiplay=out,10,server.ip.address,5000
606  if(value.contains(",")){
607  QStringList parts;
608  parts = value.split(",",QString::SkipEmptyParts);
609 
610  if(option == "--multiplay=in"){
611  grpMpServerIn->setChecked(enabled);
612  Helpers::select_combo(comboLocalIpAddress, parts.at(1));
613  Helpers::select_combo(comboHzIn, parts.at(0));
614  Helpers::select_combo(comboLocalPort, parts.at(2));
615 
616  }else{
617  grpMpServerOut->setChecked(enabled);
618  Helpers::select_combo(comboHzOut, parts.at(0));
619  Helpers::select_combo(comboRemotePort, parts.at(2));
620  QList<QTreeWidgetItem *> items = treeWidget->findItems(parts.at(1), Qt::MatchExactly, C_IP_ADDRESS);
621  if(items.size() > 0){
622  treeWidget->setCurrentItem(items.at(0));
623  }
624  }
625  }
626 
627 
628  }else if(option == "fgcom_enabled"){
629  grpFgCom->setChecked(enabled);
630 
631  }else if(option == "fgcom_server"){
632  if(value.contains(":")){
633  txtFgComNo->setText( value.split(":").at(0));
634  txtFgComPort->setText( value.split(":").at(1));
635  }
636  else {
637  txtFgComNo->setText("Not valid");
638  txtFgComPort->setText("Not valid");
639  }
640 
641 
642  }else if(option == "--telnet="){
643  grpTelnet->setChecked(enabled);
644  txtTelnet->setText(value);
645 
646 
647  }else if(option == "--httpd="){
648  grpHttp->setChecked(enabled);
649  txtHttp->setText(value);
650 
651 
652  }else if(option == "--jpg-httpd="){
653  grpScreenShot->setChecked(enabled);
654  txtScreenShot->setText(value);
655 
656  }else if(option == "fgcom_exe_path"){
658  }
659 
660 }
QComboBox * comboLocalIpAddress
Definition: networkwidget.h:50
void set_option(QString option, bool enabled, QString value)
QString validate()
A QGroupBox with a QVBoxLyout layout.
Definition: xgroupboxes.h:19
QLabel * labelFgComProgram
Definition: networkwidget.h:65
void on_telnet_data(QString, QString)
NetworkWidget(MainObject *mOb, QWidget *parent=0)
void setx(QString option, bool enabled, QString value)
QHBoxLayout * xLayout
Definition: xgroupboxes.h:45
QLineEdit * txtFgComNo
Definition: networkwidget.h:60
XGroupHBox * grpScreenShot
Definition: networkwidget.h:74
QLineEdit * txtTelnet
Definition: networkwidget.h:69
The MainObject is an extended QObject, and the main "controller" for FGx.
Definition: mainobject.h:66
void on_fgcom_path(QString)
void load_local_addresses()
QComboBox * comboRemotePort
Definition: networkwidget.h:52
void fgcom_check_path()
QString fgcom_exe_path()
Path to fgcom executable.
QComboBox * comboHzIn
Definition: networkwidget.h:55
QTreeWidget * treeWidget
Definition: networkwidget.h:56
QLineEdit * txtHttp
Definition: networkwidget.h:72
QLineEdit * txtScreenShot
Definition: networkwidget.h:75
QLabel * labelFgComCheck
Definition: networkwidget.h:66
A QGroupBox with a QGridLayout layout.
Definition: xgroupboxes.h:59
A QGroupBox with a QHBoxLyout layout.
Definition: xgroupboxes.h:39
void on_upx(QString option, bool enabled, QString value)
void on_select_fgcombutton()
XGroupGBox * grpFgCom
Definition: networkwidget.h:59
void addWidget(QWidget *w, int row, int col, int row_span, int col_span)
Definition: xgroupboxes.cpp:71
void addWidget(QWidget *w)
Definition: xgroupboxes.cpp:21
XSettingsModel * X
Definition: mainobject.h:86
QComboBox * comboHzOut
Definition: networkwidget.h:54
XGroupVBox * grpMpServerOut
Definition: networkwidget.h:47
void addWidget(QWidget *w)
Definition: xgroupboxes.cpp:45
QLineEdit * txtFgComPort
Definition: networkwidget.h:61
void get_info(QString ip_address)
Definition: mptelnet.cpp:24
QToolButton * buttonSetFgComPath
Definition: networkwidget.h:64
XGroupHBox * grpTelnet
Definition: networkwidget.h:68
void on_dns_lookup_callback(const QHostInfo &hostInfo)
QComboBox * comboRemoteAddress
Definition: networkwidget.h:51
MainObject * mainObject
Definition: networkwidget.h:44
QLineEdit * lineEditFgComPath
Definition: networkwidget.h:63
XGroupHBox * grpMpServerIn
Definition: networkwidget.h:46
void populate_combo_hz(QComboBox *combo)
void addLayout(QBoxLayout *lay)
Definition: xgroupboxes.cpp:27
XGroupHBox * grpHttp
Definition: networkwidget.h:71
void on_browse_screenshot()
QString getx(QString option)
QComboBox * comboLocalPort
Definition: networkwidget.h:53