source: ntrip/trunk/BNS/bnswindow.cpp@ 964

Last change on this file since 964 was 964, checked in by weber, 16 years ago

* empty log message *

File size: 24.0 KB
Line 
1
2/* -------------------------------------------------------------------------
3 * BKG NTRIP Server
4 * -------------------------------------------------------------------------
5 *
6 * Class: bnsWindow
7 *
8 * Purpose: This class implements the main application window.
9 *
10 * Author: L. Mervart
11 *
12 * Created: 29-Mar-2008
13 *
14 * Changes:
15 *
16 * -----------------------------------------------------------------------*/
17
18#include <iostream>
19
20#include "bnswindow.h"
21#include "bnshlpdlg.h"
22
23using namespace std;
24
25// About Dialog - Constructor
26////////////////////////////////////////////////////////////////////////////
27bnsAboutDlg::bnsAboutDlg(QWidget* parent) :
28 QDialog(parent) {
29
30 QTextBrowser* tb = new QTextBrowser;
31 QUrl url; url.setPath(":bnsabout.html");
32 tb->setSource(url);
33 tb->setReadOnly(true);
34
35 int ww = QFontMetrics(font()).width('w');
36 QPushButton* _closeButton = new QPushButton("Close");
37 _closeButton->setMaximumWidth(10*ww);
38 connect(_closeButton, SIGNAL(clicked()), this, SLOT(close()));
39
40 QGridLayout* dlgLayout = new QGridLayout();
41 QLabel* img = new QLabel();
42 img->setPixmap(QPixmap(":ntrip-logo.png"));
43 dlgLayout->addWidget(img, 0,0);
44 dlgLayout->addWidget(new QLabel("BKG Ntrip Server (BNS) Version 1.0"), 0,1);
45 dlgLayout->addWidget(tb,1,0,1,2);
46 dlgLayout->addWidget(_closeButton,2,1,Qt::AlignRight);
47
48 setLayout(dlgLayout);
49 resize(60*ww, 60*ww);
50 show();
51}
52
53// About Dialog - Destructor
54////////////////////////////////////////////////////////////////////////////
55bnsAboutDlg::~bnsAboutDlg() {
56};
57
58// Constructor
59////////////////////////////////////////////////////////////////////////////
60bnsWindow::bnsWindow() {
61
62 _bns = 0;
63
64 QSettings settings;
65
66 QString fontString = settings.value("font").toString();
67 if ( !fontString.isEmpty() ) {
68 QFont newFont;
69 if (newFont.fromString(fontString)) {
70 this->setFont(newFont);
71 }
72 }
73
74 int ww = QFontMetrics(this->font()).width('w');
75 setMinimumSize(77*ww, 65*ww);
76 setWindowTitle(tr("BKG Ntrip Server (BNS) Version 1.0"));
77 setWindowIcon(QPixmap(":ntrip-logo.png"));
78
79 // Create Actions
80 // --------------
81 _actHelp = new QAction(tr("&Help Contents"),this);
82 connect(_actHelp, SIGNAL(triggered()), SLOT(slotHelp()));
83
84 _actAbout = new QAction(tr("&About BNS"),this);
85 connect(_actAbout, SIGNAL(triggered()), SLOT(slotAbout()));
86
87 _actFontSel = new QAction(tr("Select &Font"),this);
88 connect(_actFontSel, SIGNAL(triggered()), SLOT(slotFontSel()));
89
90 _actSaveOpt = new QAction(tr("&Save Options"),this);
91 connect(_actSaveOpt, SIGNAL(triggered()), SLOT(slotSaveOptions()));
92
93 _actQuit = new QAction(tr("&Quit"),this);
94 connect(_actQuit, SIGNAL(triggered()), SLOT(close()));
95
96 _actWhatsThis= new QAction(tr("Help=Shift+F1"),this);
97 connect(_actWhatsThis, SIGNAL(triggered()), SLOT(slotWhatsThis()));
98
99 _actStart = new QAction(tr("Sta&rt"),this);
100 connect(_actStart, SIGNAL(triggered()), SLOT(slotStart()));
101
102 _actStop = new QAction(tr("Sto&p"),this);
103 connect(_actStop, SIGNAL(triggered()), SLOT(slotStop()));
104 _actStop->setEnabled(false);
105
106 CreateMenu();
107 AddToolbar();
108
109 // Canvas with Editable Fields
110 // ---------------------------
111 _canvas = new QWidget;
112 setCentralWidget(_canvas);
113
114 _proxyHostLineEdit = new QLineEdit(settings.value("proxyHost").toString());
115 _proxyHostLineEdit->setWhatsThis(tr("<p>If you are running BNS within a protected Local Area Network (LAN), you might need to use a proxy server to access the Internet. Enter your proxy server IP and port number in case one is operated in front of BNS. If you do not know the IP and port of your proxy server, check the proxy server settings in your Internet browser or ask your network administrator.</p><p>Note that IP streaming is sometimes not allowed in a LAN. In this case you need to ask your network administrator for an appropriate modification of the local security policy or for the installation of a TCP relay to the NTRIP broadcasters. If these are not possible, you might need to run BNS outside your LAN on a network that has unobstructed connection to the Internet.</p>"));
116 _proxyPortLineEdit = new QLineEdit(settings.value("proxyPort").toString());
117 _proxyPortLineEdit->setWhatsThis(tr("<p>Enter your proxy server port number in case one is operated in front of BNS.</p>"));
118 _proxyPortLineEdit->setMaximumWidth(9*ww);
119
120 _logFileLineEdit = new QLineEdit(settings.value("logFile").toString());
121 _logFileLineEdit->setWhatsThis(tr("<p>Records of BNS activities are shown in the Log section on the bottom of this window. They can be saved into a file when a valid path is specified in the 'Logfile (full path)' field.</p>"));
122 _fileAppendCheckBox = new QCheckBox();
123 _fileAppendCheckBox->setCheckState(Qt::CheckState(settings.value("fileAppend").toInt()));
124 _fileAppendCheckBox->setWhatsThis(tr("<p>When BNS is started, new files are created by default and any existing files with the same name will be overwritten. However, users might want to append already existing files following a restart of BNS, a system crash or when BNS crashed. Tick 'Append files' to continue with existing files and keep what has been recorded so far.</p>"));
125
126 _refSysComboBox = new QComboBox;
127 _refSysComboBox->setMaximumWidth(9*ww);
128 _refSysComboBox->setEditable(false);
129 _refSysComboBox->addItems(QString("IGS05,ETRS89").split(","));
130 int ii = _refSysComboBox->findText(settings.value("refSys").toString());
131 if (ii != -1) {
132 _refSysComboBox->setCurrentIndex(ii);
133 }
134 _refSysComboBox->setWhatsThis(tr("Select the target reference system for outgoing clock and orbit corrections."));
135
136 _ephHostLineEdit = new QLineEdit(settings.value("ephHost").toString());
137 _ephHostLineEdit->setWhatsThis(tr("BNS reads Broadcast Ephemeris in RINEX Version 3 Navigation file format from an IP address. Specify the host IP e.g. of a BNC installation providing this information."));
138 _ephPortLineEdit = new QLineEdit(settings.value("ephPort").toString());
139 _ephPortLineEdit->setWhatsThis(tr("BNS reads Broadcast Ephemeris in RINEX Version 3 Navigation file format from an IP address. Specify the IP port e.g. of a BNC installation providing this information."));
140 _ephProxyCheckBox = new QCheckBox();
141 _ephProxyCheckBox->setCheckState(Qt::CheckState(settings.value("ephProxy").toInt()));
142 _ephProxyCheckBox->setWhatsThis(tr("If a proxy server is operated between BNS and the server providing Broadcast Ephemeris, you may need to use the proxy server settings you have specified. Tick 'Use proxy' to activate them for stream access."));
143 _ephPortLineEdit->setMaximumWidth(9*ww);
144
145 _clkHostLineEdit = new QLineEdit(settings.value("clkHost").toString());
146 _clkHostLineEdit->setWhatsThis(tr("BNS reads Clocks & Orbits referring to the IGS system (X,Y,Z, ECEF) in plain ASCII format from an IP address. Specify the host IP e.g. of an RTNet installation providing this information."));
147 _clkPortLineEdit = new QLineEdit(settings.value("clkPort").toString());
148 _clkPortLineEdit->setWhatsThis(tr("BNS reads Clocks & Orbits referring to the IGS system (X,Y,Z, ECEF) in plain ASCII format from an IP address. Specify the IP port e.g. of a RTNet installation providing this information."));
149 _clkProxyCheckBox = new QCheckBox();
150 _clkProxyCheckBox->setCheckState(Qt::CheckState(settings.value("clkProxy").toInt()));
151 _clkProxyCheckBox->setWhatsThis(tr("If a proxy server is operated between BNS and the server providing Clocks & Orbits, you may need to use the proxy server settings you have specified. Tick 'Use proxy' to activate them for stream access."));
152 _clkFileLineEdit = new QLineEdit(settings.value("clkFile").toString());
153 _clkFileLineEdit->setWhatsThis(tr("Specify the full path to a file where incoming IGS Clocks & Orbits are saved. Beware that the size of this file can rapidly increase. Default is an empty option field meaning that incoming Clocks & Orbits corrections are not saved."));
154 _clkPortLineEdit->setMaximumWidth(9*ww);
155
156 _outHostLineEdit = new QLineEdit(settings.value("outHost").toString());
157 _outHostLineEdit->setWhatsThis(tr("BNS can stream clock and orbit corrections to Broadcast Ephemeris in RTCM Version 3 format. Specify the host IP of an NTRIP Broadcaster to upload the stream. An empty option field means that you don't want to upload corrections."));
158 _outPortLineEdit = new QLineEdit(settings.value("outPort").toString());
159 _outPortLineEdit->setWhatsThis(tr("Specify the IP port of an NTRIP Broadcaster to upload the stream. Default is port 80."));
160 _outPortLineEdit->setMaximumWidth(9*ww);
161 _mountpointLineEdit = new QLineEdit(settings.value("mountpoint").toString());
162 _mountpointLineEdit->setWhatsThis(tr("Specify the mounpoint for stream upload to an NTRIP Broadcaster."));
163 _mountpointLineEdit->setMaximumWidth(9*ww);
164 _passwordLineEdit = new QLineEdit(settings.value("password").toString());
165 _passwordLineEdit->setWhatsThis(tr("Specify the stream upload password protecting the mounpoint on an NTRIP Broadcaster."));
166 _passwordLineEdit->setMaximumWidth(9*ww);
167 _passwordLineEdit->setEchoMode(QLineEdit::Password);
168 _outProxyCheckBox = new QCheckBox();
169 _outProxyCheckBox->setCheckState(Qt::CheckState(settings.value("outProxy").toInt()));
170 _outProxyCheckBox->setWhatsThis(tr("If a proxy server is operated between BNS and the NTRIP Broadcaster, you may need to use the proxy server settings you have specified. Tick 'Use proxy' to activate them for stream upload."));
171 _outFileLineEdit = new QLineEdit(settings.value("outFile").toString());
172 _outFileLineEdit->setWhatsThis(tr("Specify the full path to a file where outgoing clock and orbit corrections to Broadcast Ephemeris are saved. Beware that the size of this file can rapidly increase. Default is an empty option field meaning that outgoing corrections are not saved."));
173
174 _rnxPathLineEdit = new QLineEdit(settings.value("rnxPath").toString());
175 _rnxPathLineEdit->setWhatsThis(tr("Specify the path for saving the generated clock corrections as Clock RINEX files. If the specified directory does not exist, BNS will not create Clock RINEX files."));
176 _rnxIntrComboBox = new QComboBox;
177 _rnxIntrComboBox->setMaximumWidth(9*ww);
178 _rnxIntrComboBox->setEditable(false);
179 _rnxIntrComboBox->addItems(QString("1 min,2 min,5 min,10 min,15 min,30 min,1 hour,1 day").split(","));
180 ii = _rnxIntrComboBox->findText(settings.value("rnxIntr").toString());
181 if (ii != -1) {
182 _rnxIntrComboBox->setCurrentIndex(ii);
183 }
184 _rnxIntrComboBox->setWhatsThis(tr("Select the length of the Clock RINEX file."));
185 _rnxSamplSpinBox = new QSpinBox;
186 _rnxSamplSpinBox->setMinimum(0);
187 _rnxSamplSpinBox->setMaximum(60);
188 _rnxSamplSpinBox->setSingleStep(5);
189 _rnxSamplSpinBox->setMaximumWidth(9*ww);
190 _rnxSamplSpinBox->setValue(settings.value("rnxSampl").toInt());
191 _rnxSamplSpinBox->setSuffix(" sec");
192 _rnxSamplSpinBox->setWhatsThis(tr("Select the Clock RINEX file sampling interval in seconds. A value of zero '0' tells BNS to store all available samples into Clock RINEX files."));
193
194 _sp3PathLineEdit = new QLineEdit(settings.value("sp3Path").toString());
195 _sp3PathLineEdit->setWhatsThis(tr("Specify the path for saving the generated orbit corrections as SP3 orbit files. If the specified directory does not exist, BNS will not create Clock RINEX files."));
196 _sp3IntrComboBox = new QComboBox;
197 _sp3IntrComboBox->setMaximumWidth(9*ww);
198 _sp3IntrComboBox->setEditable(false);
199 _sp3IntrComboBox->addItems(QString("1 min,2 min,5 min,10 min,15 min,30 min,1 hour,1 day").split(","));
200 ii = _sp3IntrComboBox->findText(settings.value("sp3Intr").toString());
201 if (ii != -1) {
202 _sp3IntrComboBox->setCurrentIndex(ii);
203 }
204 _sp3IntrComboBox->setWhatsThis(tr("Select the length of the SP3 orbit file."));
205 _sp3SamplSpinBox = new QSpinBox;
206 _sp3SamplSpinBox->setMinimum(0);
207 _sp3SamplSpinBox->setMaximum(900);
208 _sp3SamplSpinBox->setSingleStep(60);
209 _sp3SamplSpinBox->setMaximumWidth(9*ww);
210 _sp3SamplSpinBox->setValue(settings.value("sp3Sampl").toInt());
211 _sp3SamplSpinBox->setSuffix(" sec");
212 _sp3SamplSpinBox->setWhatsThis(tr("Select the SP3 orbit file sampling interval in seconds. A value of zero '0' tells BNS to store all available samples into SP3 orbit files."));
213
214 // TabWidget
215 // ---------
216 QTabWidget* tabs = new QTabWidget();
217
218 // Proxy Tab
219 // ---------
220 QWidget* tab_prx = new QWidget();
221 tabs->setMaximumHeight(20*ww);
222 tabs->addTab(tab_prx, "Proxy");
223
224 QGridLayout* layout_prx = new QGridLayout;
225 layout_prx->setColumnMinimumWidth(0,9*ww);
226
227 layout_prx->addWidget(new QLabel("Proxy host"), 0, 0, Qt::AlignLeft);
228 layout_prx->addWidget(_proxyHostLineEdit, 0, 1);
229 layout_prx->addWidget(new QLabel("Proxy port"), 1, 0, Qt::AlignLeft);
230 layout_prx->addWidget(_proxyPortLineEdit, 1, 1);
231 layout_prx->addWidget(new QLabel("Settings for the proxy in protected networks, leave boxes blank if none."),2, 0, 1, 2, Qt::AlignLeft);
232 layout_prx->addWidget(new QLabel(" "), 3, 0);
233 layout_prx->addWidget(new QLabel(" "), 4, 0);
234
235 tab_prx->setLayout(layout_prx);
236
237 // General Tab
238 // -----------
239 QWidget* tab_gen = new QWidget();
240 tabs->addTab(tab_gen, "General");
241
242 QGridLayout* layout_gen = new QGridLayout;
243 layout_gen->setColumnMinimumWidth(0,9*ww);
244
245 layout_gen->addWidget(new QLabel("Logfile (full path)"), 0, 0);
246 layout_gen->addWidget(_logFileLineEdit, 0, 1);
247 layout_gen->addWidget(new QLabel("Append files"), 1, 0);
248 layout_gen->addWidget(_fileAppendCheckBox, 1, 1);
249 layout_gen->addWidget(new QLabel("Reference System"), 2, 0);
250 layout_gen->addWidget(_refSysComboBox, 2, 1);
251 layout_gen->addWidget(new QLabel("General settings for logfile, file handling and target reference system."),3, 0, 1, 2, Qt::AlignLeft);
252 layout_gen->addWidget(new QLabel(" "), 4, 0);
253
254 tab_gen->setLayout(layout_gen);
255
256 // Input Tab
257 // ---------
258 QWidget* tab_inp = new QWidget();
259 tabs->addTab(tab_inp, "Input");
260
261 QGridLayout* layout_inp = new QGridLayout;
262 layout_inp->setColumnMinimumWidth(0, 9*ww);
263
264 layout_inp->addWidget(new QLabel("Ephemeris"), 0, 0, Qt::AlignLeft);
265 layout_inp->addWidget(new QLabel("Host"), 0, 1, Qt::AlignRight);
266 layout_inp->addWidget(_ephHostLineEdit, 0, 2);
267 layout_inp->addWidget(new QLabel("Port"), 0, 3, Qt::AlignLeft);
268 layout_inp->addWidget(_ephPortLineEdit, 0, 4);
269 layout_inp->addWidget(new QLabel("Use proxy"), 0, 5, Qt::AlignLeft);
270 layout_inp->addWidget(_ephProxyCheckBox, 0, 6);
271 layout_inp->addWidget(new QLabel("Clocks & Orbits"), 1, 0, Qt::AlignLeft);
272 layout_inp->addWidget(new QLabel("Host"), 1, 1, Qt::AlignRight);
273 layout_inp->addWidget(_clkHostLineEdit, 1, 2);
274 layout_inp->addWidget(new QLabel("Port"), 1, 3, Qt::AlignLeft);
275 layout_inp->addWidget(_clkPortLineEdit, 1, 4);
276 layout_inp->addWidget(new QLabel("Use proxy"), 1, 5, Qt::AlignLeft);
277 layout_inp->addWidget(_clkProxyCheckBox, 1, 6);
278 layout_inp->addWidget(new QLabel("Save Clocks & Orbits"), 2, 0, Qt::AlignLeft);
279 layout_inp->addWidget(new QLabel("(full path)"), 2, 1, Qt::AlignRight);
280 layout_inp->addWidget(_clkFileLineEdit, 2, 2);
281 layout_inp->addWidget(new QLabel("Read broadcast ephemeris and IGS clocks and orbits."), 3, 0, 1, 6, Qt::AlignLeft);
282 layout_inp->addWidget(new QLabel(""), 4, 0);
283
284 tab_inp->setLayout(layout_inp);
285
286 // NTRIP Caster Tab
287 // ----------------
288 QWidget* tab_cas = new QWidget();
289 tabs->addTab(tab_cas, "NTRIP Caster");
290
291 QGridLayout* layout_cas = new QGridLayout;
292 layout_cas->setColumnMinimumWidth(0, 9*ww);
293
294 layout_cas->addWidget(new QLabel("Host"), 0, 0, Qt::AlignLeft);
295 layout_cas->addWidget(_outHostLineEdit, 0, 1);
296 layout_cas->addWidget(new QLabel("Port"), 0, 3, Qt::AlignLeft);
297 layout_cas->addWidget(_outPortLineEdit, 0, 4);
298 layout_cas->addWidget(new QLabel("Mountpoint"), 1, 0, Qt::AlignLeft);
299 layout_cas->addWidget(_mountpointLineEdit, 1, 1);
300 layout_cas->addWidget(new QLabel("Password"), 1, 3, Qt::AlignLeft);
301 layout_cas->addWidget(_passwordLineEdit, 1, 4);
302 layout_cas->addWidget(new QLabel("Use proxy"), 2, 0, Qt::AlignLeft);
303 layout_cas->addWidget(_outProxyCheckBox, 2, 1);
304 layout_cas->addWidget(new QLabel("Save stream (full path)"), 3, 0, Qt::AlignLeft);
305 layout_cas->addWidget(_outFileLineEdit, 3, 1);
306 layout_cas->addWidget(new QLabel("Stream upload of clock and orbit corrections to NTRIP broadcaster."),4, 0, 1, 2, Qt::AlignLeft);
307
308 tab_cas->setLayout(layout_cas);
309
310 // RINEX Tab
311 // ---------
312 QWidget* tab_rin = new QWidget();
313 tabs->addTab(tab_rin, "RINEX Clocks ");
314
315 QGridLayout* layout_rin = new QGridLayout;
316 layout_rin->setColumnMinimumWidth(0, 9*ww);
317
318 layout_rin->addWidget(new QLabel("Directory"), 0, 0);
319 layout_rin->addWidget(_rnxPathLineEdit, 0, 1);
320 layout_rin->addWidget(new QLabel("Interval"), 1, 0);
321 layout_rin->addWidget(_rnxIntrComboBox, 1, 1);
322 layout_rin->addWidget(new QLabel("Sampling"), 2, 0);
323 layout_rin->addWidget(_rnxSamplSpinBox, 2, 1);
324 layout_rin->addWidget(new QLabel("Save clock corrections in Clock RINEX file format."), 3, 0, 1, 2, Qt::AlignLeft);
325 layout_rin->addWidget(new QLabel(""), 4, 0);
326
327 tab_rin->setLayout(layout_rin);
328
329 // SP3 Tab
330 // -------
331 QWidget* tab_sp3 = new QWidget();
332 tabs->addTab(tab_sp3, "SP3 Orbits");
333
334 QGridLayout* layout_sp3 = new QGridLayout;
335 layout_sp3->setColumnMinimumWidth(0, 9*ww);
336
337 layout_sp3->addWidget(new QLabel("Directory"), 0, 0);
338 layout_sp3->addWidget(_sp3PathLineEdit, 0, 1);
339 layout_sp3->addWidget(new QLabel("Interval"), 1, 0);
340 layout_sp3->addWidget(_sp3IntrComboBox, 1, 1);
341 layout_sp3->addWidget(new QLabel("Sampling"), 2, 0);
342 layout_sp3->addWidget(_sp3SamplSpinBox, 2, 1);
343 layout_sp3->addWidget(new QLabel("Save orbit corrections in SP3 file format."), 3, 0, 1, 2, Qt::AlignLeft);
344 layout_sp3->addWidget(new QLabel(""), 4, 0);
345
346 tab_sp3->setLayout(layout_sp3);
347
348 // Log
349 // ---
350 _log = new QTextBrowser();
351 _log->setReadOnly(true);
352 _log->setWhatsThis(tr("Records of BNS's activities are shown in the Log section."));
353
354 // Main Layout
355 // -----------
356 QVBoxLayout* mainLayout = new QVBoxLayout;
357 mainLayout->addWidget(tabs);
358 mainLayout->addWidget(_log);
359
360 _canvas->setLayout(mainLayout);
361}
362
363// Destructor
364////////////////////////////////////////////////////////////////////////////
365bnsWindow::~bnsWindow() {
366}
367
368// Close Application gracefully
369////////////////////////////////////////////////////////////////////////////
370void bnsWindow::closeEvent(QCloseEvent* event) {
371
372int iRet = QMessageBox::question(this, "Close", "Save Options?",
373 QMessageBox::Yes, QMessageBox::No,
374 QMessageBox::Cancel);
375
376 if (iRet == QMessageBox::Cancel) {
377 event->ignore();
378 return;
379 }
380 else if (iRet == QMessageBox::Yes) {
381 slotSaveOptions();
382 }
383
384 QMainWindow::closeEvent(event);
385}
386
387// About Message
388////////////////////////////////////////////////////////////////////////////
389void bnsWindow::slotAbout() {
390 new bnsAboutDlg(0);
391}
392
393// Help Window
394////////////////////////////////////////////////////////////////////////////
395void bnsWindow::slotHelp() {
396 QUrl url;
397 url.setPath(":bnshelp.html");
398 new bnsHlpDlg(0, url);
399}
400
401// Select Fonts
402////////////////////////////////////////////////////////////////////////////
403void bnsWindow::slotFontSel() {
404 bool ok;
405 QFont newFont = QFontDialog::getFont(&ok, this->font(), this);
406 if (ok) {
407 QSettings settings;
408 settings.setValue("font", newFont.toString());
409 QApplication::setFont(newFont);
410 int ww = QFontMetrics(newFont).width('w');
411 setMinimumSize(77*ww, 65*ww);
412 }
413}
414
415// Whats This Help
416////////////////////////////////////////////////////////////////////////////
417void bnsWindow::slotWhatsThis() {
418QWhatsThis::enterWhatsThisMode();
419}
420
421// Create Menus
422////////////////////////////////////////////////////////////////////////////
423void bnsWindow::CreateMenu() {
424 _menuFile = menuBar()->addMenu(tr("&File"));
425 _menuFile->addAction(_actFontSel);
426 _menuFile->addSeparator();
427 _menuFile->addAction(_actSaveOpt);
428 _menuFile->addSeparator();
429 _menuFile->addAction(_actQuit);
430
431 _menuHlp = menuBar()->addMenu(tr("&Help"));
432 _menuHlp->addAction(_actHelp);
433 _menuHlp->addAction(_actAbout);
434}
435
436// Tool (Command) Bar
437////////////////////////////////////////////////////////////////////////////
438void bnsWindow::AddToolbar() {
439 QToolBar* toolBar = new QToolBar;
440 addToolBar(Qt::BottomToolBarArea, toolBar);
441 toolBar->setMovable(false);
442 toolBar->addAction(_actStart);
443 toolBar->addAction(_actStop);
444 toolBar->addWidget(new QLabel(" "));
445 toolBar->addAction(_actWhatsThis);
446}
447
448// Save Options
449////////////////////////////////////////////////////////////////////////////
450void bnsWindow::slotSaveOptions() {
451 QSettings settings;
452 settings.setValue("proxyHost", _proxyHostLineEdit->text());
453 settings.setValue("proxyPort", _proxyPortLineEdit->text());
454 settings.setValue("logFile", _logFileLineEdit->text());
455 settings.setValue("fileAppend", _fileAppendCheckBox->checkState());
456 settings.setValue("refSys", _refSysComboBox->currentText());
457 settings.setValue("ephHost", _ephHostLineEdit->text());
458 settings.setValue("ephPort", _ephPortLineEdit->text());
459 settings.setValue("ephProxy", _ephProxyCheckBox->checkState());
460 settings.setValue("clkHost", _clkHostLineEdit->text());
461 settings.setValue("clkPort", _clkPortLineEdit->text());
462 settings.setValue("clkProxy", _clkProxyCheckBox->checkState());
463 settings.setValue("clkFile", _clkFileLineEdit->text());
464 settings.setValue("outHost", _outHostLineEdit->text());
465 settings.setValue("outPort", _outPortLineEdit->text());
466 settings.setValue("outProxy", _outProxyCheckBox->checkState());
467 settings.setValue("mountpoint", _mountpointLineEdit->text());
468 settings.setValue("outFile", _outFileLineEdit->text());
469 settings.setValue("password", _passwordLineEdit->text());
470 settings.setValue("rnxPath", _rnxPathLineEdit->text());
471 settings.setValue("rnxIntr", _rnxIntrComboBox->currentText());
472 settings.setValue("rnxSampl", _rnxSamplSpinBox->value());
473 settings.setValue("sp3Path", _sp3PathLineEdit->text());
474 settings.setValue("sp3Intr", _sp3IntrComboBox->currentText());
475 settings.setValue("sp3Sampl", _sp3SamplSpinBox->value());
476}
477
478// Display Program Messages
479////////////////////////////////////////////////////////////////////////////
480void bnsWindow::slotMessage(const QByteArray msg) {
481
482 const int maxBufferSize = 10000;
483
484 QString txt = _log->toPlainText() + "\n" +
485 QDateTime::currentDateTime().toUTC().toString("yy-MM-dd hh:mm:ss ") + msg;
486 _log->clear();
487 _log->append(txt.right(maxBufferSize));
488}
489
490// Delete bns
491////////////////////////////////////////////////////////////////////////////
492void bnsWindow::deleteBns() {
493 _actStart->setEnabled(true);
494 _actStop->setEnabled(false);
495 _bns->terminate();
496 _bns->wait(100);
497 delete _bns;
498 _bns = 0;
499}
500
501// Error in bns
502////////////////////////////////////////////////////////////////////////////
503void bnsWindow::slotError(const QByteArray msg) {
504 slotMessage(msg);
505 deleteBns();
506}
507
508// Stop
509////////////////////////////////////////////////////////////////////////////
510void bnsWindow::slotStop() {
511 int iRet = QMessageBox::question(this, "Stop", "Do you want to stop?",
512 QMessageBox::Yes, QMessageBox::No,
513 QMessageBox::NoButton);
514 if (iRet == QMessageBox::Yes) {
515 deleteBns();
516 }
517}
518
519// Start
520////////////////////////////////////////////////////////////////////////////
521void bnsWindow::slotStart() {
522 slotSaveOptions();
523
524 _actStart->setEnabled(false);
525 _actStop->setEnabled(true);
526
527 _bns = new t_bns(0);
528
529 connect(_bns, SIGNAL(newMessage(QByteArray)),
530 this, SLOT(slotMessage(const QByteArray)));
531
532 connect(_bns, SIGNAL(error(QByteArray)),
533 this, SLOT(slotError(const QByteArray)));
534
535 _bns->start();
536}
Note: See TracBrowser for help on using the repository browser.