General Purpose Geodetic Library
VcStartupWizard.cpp
Go to the documentation of this file.
1 /*
2  * This file is a part of vgosDbCalc. vgosDbCalc is a part of CALC/SOLVE
3  * system and is designed to calculate theoretical values and store them
4  * in the vgosDb format.
5  * Copyright (C) 2016-2020 Sergei Bolotin.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #include <iostream>
23 #include <stdlib.h>
24 #include <unistd.h>
25 #include <sys/types.h>
26 #include <pwd.h>
27 
28 #include <QtCore/QDir>
29 #include <QtCore/QSettings>
30 
31 
32 #if QT_VERSION >= 0x050000
33 # include <QtWidgets/QBoxLayout>
34 # include <QtWidgets/QButtonGroup>
35 # include <QtWidgets/QCheckBox>
36 # include <QtWidgets/QFrame>
37 # include <QtWidgets/QGroupBox>
38 # include <QtWidgets/QGridLayout>
39 # include <QtWidgets/QLabel>
40 # include <QtWidgets/QLineEdit>
41 # include <QtWidgets/QMessageBox>
42 # include <QtWidgets/QPushButton>
43 # include <QtWidgets/QRadioButton>
44 # include <QtWidgets/QSpinBox>
45 # include <QtWidgets/QVBoxLayout>
46 #else
47 # include <QtGui/QBoxLayout>
48 # include <QtGui/QButtonGroup>
49 # include <QtGui/QCheckBox>
50 # include <QtGui/QFrame>
51 # include <QtGui/QGroupBox>
52 # include <QtGui/QGridLayout>
53 # include <QtGui/QLabel>
54 # include <QtGui/QLineEdit>
55 # include <QtGui/QMessageBox>
56 # include <QtGui/QPushButton>
57 # include <QtGui/QRadioButton>
58 # include <QtGui/QSpinBox>
59 # include <QtGui/QVBoxLayout>
60 #endif
61 
62 #include <QtGui/QPixmap>
63 
64 
65 #include <SgLogger.h>
66 
67 #include "vgosDbCalc.h"
68 #include "VcStartupWizard.h"
69 
70 
71 //
72 const int VcStartupWizard::serialNumber_ = 20161121; // 2016/11/21
73 //
74 /*=======================================================================================================
75 *
76 * METHODS:
77 *
78 *======================================================================================================*/
80 {
82 };
83 
84 
85 
86 //
87 VcStartupWizard::VcStartupWizard(bool isFirstRun, bool isForcedRun, bool isSystemWideRun,
88  QSettings *settings, QWidget *parent)
89  : QWizard(parent)
90 {
91  //serialNumber_ = 20161121; // 2016/11/21
92  isFirstRun_ = isFirstRun;
93  isForcedRun_ = isForcedRun;
94  isSystemWideRun_ = isSystemWideRun;
95  settings_ = settings;
96  addPage(createIntroPage());
97  addPage(createPageHomeDir());
98  if (!isSystemWideRun_)
99  addPage(createPageOne());
100  addPage(createPageTwo());
101  addPage(createPageThree());
102  addPage(createConclusionPage());
103 
104  setWizardStyle(ModernStyle);
105 
106  setPixmap(QWizard::LogoPixmap, QPixmap(":/images/NVI_logo.png"));
107  setPixmap(QWizard::WatermarkPixmap, QPixmap(":/images/pattern_1.png"));
108 
109  setWindowTitle(vgosDbCalcVersion.getSoftwareName() + " Startup Wizard" +
110  QString(isSystemWideRun?" (system-wide settings)":""));
111 };
112 
113 
114 
115 //
117 {
118 };
119 
120 
121 
122 //
124 {
125  VcWizardPage *w=new VcWizardPage();
126  QString str;
127 
128  // title:
129  // w->setTitle("<p><font size=+1 face=\"Times\">Wellcome to <b>&nu;Solve</b>!</font></p>");
130  w->setTitle("<p><font size=+1 face=\"Times\">Welcome to vgosDbCalc</font></p>");
131 
132  // subTitle:
133  str = "The Startup Wizard will ask you few questions about software configuration.";
134  if (isFirstRun_)
135  w->setSubTitle("<font face=\"Times\"><p>Thank you for installing vgosDbCalc version " +
136  vgosDbCalcVersion.toString() + ".</p><p>" + str + "</p></font>");
137  else if (!isForcedRun_)
138  w->setSubTitle( "<font face=\"Times\"><p>Congratulation! You just have upgraded SgLib and "
139  "vgosDbCalc software to the versions " + libraryVersion.toString() + " and " +
140  vgosDbCalcVersion.toString() + ".</p><p>" + str + "</p></font>");
141  else
142  w->setSubTitle( "<font face=\"Times\"><p>And so it begins. "
143  "You are using SgLib version " +
145  ") and vgosDbCalc version " + vgosDbCalcVersion.toString() + " (" +
146  vgosDbCalcVersion.getCodeName() + ").</p><p>" + str + "</p></font>");
147 
148  w->setButtonText(QWizard::NextButton, "Agree");
149 
150  QVBoxLayout *layout = new QVBoxLayout;
151  w->setLayout(layout);
152 
153  // first label:
154  str =
155  "<h3>vgosDbCalc</h3>"
156  "<p>vgosDbCalc is software that calculates theoretical values and parameter partials"
157  "and stores them in vgosDb format."
158 
159  "<p>Copyright (C) 2016-2020 Sergei Bolotin.</p>"
160 
161  "<p>This program is free software: you can redistribute it and/or modify "
162  "it under the terms of the GNU General Public License as published by "
163  "the Free Software Foundation, either version 3 of the License, or "
164  "(at your option) any later version.</p>"
165 
166  "<p>This program is distributed in the hope that it will be useful, "
167  "but WITHOUT ANY WARRANTY; without even the implied warranty of "
168  "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the "
169  "GNU General Public License for more details.</p>"
170 
171  "<p>You should have received a copy of the GNU General Public License "
172  "along with this program. If not, see http://www.gnu.org/licenses.</p>"
173 
174  "<p>Please, read carefully the license agreement and if you agree, press \"Agree\" button.</p>"
175  ""
176  "";
177  QLabel *label=new QLabel("<font face=\"Times\">" + str + "</font>");
178  label->setWordWrap(true);
179  layout->addWidget(label);
180  layout->addStretch(1);
181 
182  if (isFirstRun_)
183  {
184 // if (!isFirstRun_)
185 // cb->setChecked(true);
186  };
187 
188  QCheckBox *cb=new QCheckBox("I have read and accept the conditions.", w);
189  w->registerField("warrantyAccepted*", cb);
190  layout->addWidget(cb);
191  layout->addSpacing(40);
192  return w;
193 };
194 
195 
196 
197 //
199 {
200  VcWizardPage *w=new VcWizardPage();
201  QString path2Home;
202  bool have2ForceUser(false);
203 
204  QString str;
205  QLabel *label;
206  QVBoxLayout *layout=new QVBoxLayout;
207  QGroupBox *gBox;
208  QGridLayout *gridLayout;
209  w->setLayout(layout);
210 
211  w->setTitle("<p><font size=+1 face=\"Times\">Essential directories of vgosDbCalc</font></p>");
212  w->setSubTitle("<font face=\"Times\"><p>The working directory of the software.</p></font>");
213  w->setPixmap(QWizard::WatermarkPixmap, QPixmap(":/images/pattern_2.png"));
214 
215  if (isSystemWideRun_)
216  str =
217  "<h3>Default Directories</h3>"
218  "<p>Please, provide paths to data on your system.</p>"
219  "<p>Users will be able to overwrite default settings.</p>"
220  "";
221  else
222  str =
223  "<h3>vgosDbCalc Home Directory</h3>"
224  "<p>Please, specify the software's home directory.</p>"
225  "<p>All paths that are not absolute will be counted form this directory. The software home "
226  "directory have to be writable for a user and should be different from user's home directory.</p>"
227  "";
228  label = new QLabel("<font face=\"Times\">" + str + "</font>");
229  label->setWordWrap(true);
230  layout->addWidget(label);
231  layout->addSpacing(20);
232 
233  if (!isSystemWideRun_)
234  {
235  path2Home = setup.getPath2Home();
236  if (isFirstRun_ || setup.getPath2Home()=="")
237  path2Home = QDir::homePath() + "/" + vgosDbCalcVersion.getSoftwareName();
238  if (path2Home == QDir::homePath()) // cannot be user's home
239  have2ForceUser = true;
240 
241  gBox = new QGroupBox("vgosDbCalc home directory", w);
242  gridLayout = new QGridLayout(gBox);
243  label = new QLabel("Path to the software home directory:", gBox);
244  label->setMinimumSize(label->sizeHint());
245  leHomeDirName_ = new QLineEdit(gBox);
246  leHomeDirName_->setText(path2Home);
247  leHomeDirName_->setMinimumSize(leHomeDirName_->sizeHint());
248  gridLayout->addWidget(label, 0, 0);
249  gridLayout->addWidget(leHomeDirName_, 0, 1);
250 
251  if (have2ForceUser)
252  w->registerField("path2Home*", leHomeDirName_);
253  layout->addWidget(gBox);
254  layout->addSpacing(20);
255  };
256 
257 
258  gBox = new QGroupBox("Essential directories", w);
259  gridLayout = new QGridLayout(gBox);
260 
261  label = new QLabel("Path to CALC a priori files:", gBox);
262  label->setMinimumSize(label->sizeHint());
263  leSolveAPrioriDirName_ = new QLineEdit(gBox);
264  leSolveAPrioriDirName_->setText(setup.getPath2SolveAprioriFiles());
265  leSolveAPrioriDirName_->setMinimumSize(leSolveAPrioriDirName_->sizeHint());
266  gridLayout->addWidget(label, 0, 0);
267  gridLayout->addWidget(leSolveAPrioriDirName_, 0, 1);
268 
269  label = new QLabel("Path to vgosDb files:", gBox);
270  label->setMinimumSize(label->sizeHint());
271  leVgosDbDirName_ = new QLineEdit(gBox);
273  leVgosDbDirName_->setMinimumSize(leVgosDbDirName_->sizeHint());
274  gridLayout->addWidget(label, 1, 0);
275  gridLayout->addWidget(leVgosDbDirName_, 1, 1);
276 
277  label = new QLabel("Path to Master files:", gBox);
278  label->setMinimumSize(label->sizeHint());
279  leMasterFilesDirName_ = new QLineEdit(gBox);
281  leMasterFilesDirName_->setMinimumSize(leMasterFilesDirName_->sizeHint());
282  gridLayout->addWidget(label, 2, 0);
283  gridLayout->addWidget(leMasterFilesDirName_, 2, 1);
284 
285  layout->addWidget(gBox);
286 
287  //
288  //
289  gBox = new QGroupBox("SOLVE a priori files", w);
290  gridLayout = new QGridLayout(gBox);
291 
292  label = new QLabel("Site a priori file:", gBox);
293  label->setMinimumSize(label->sizeHint());
294  leFile4Sites_ = new QLineEdit(gBox);
295  leFile4Sites_->setText(setup.getAprioriFile4Sites());
296  leFile4Sites_->setMinimumSize(leFile4Sites_->sizeHint());
297  gridLayout->addWidget(label, 0, 0);
298  gridLayout->addWidget(leFile4Sites_, 0, 1);
299 
300  label = new QLabel("Source a priori file:", gBox);
301  label->setMinimumSize(label->sizeHint());
302  leFile4Sources_ = new QLineEdit(gBox);
303  leFile4Sources_->setText(setup.getAprioriFile4Sources());
304  leFile4Sources_->setMinimumSize(leFile4Sources_->sizeHint());
305  gridLayout->addWidget(label, 1, 0);
306  gridLayout->addWidget(leFile4Sources_, 1, 1);
307 
308  label = new QLabel("Ocean loading a priori file:", gBox);
309  label->setMinimumSize(label->sizeHint());
310  leFile4OceanLd_ = new QLineEdit(gBox);
311  leFile4OceanLd_->setText(setup.getAprioriFile4OceanLd());
312  leFile4OceanLd_->setMinimumSize(leFile4OceanLd_->sizeHint());
313  gridLayout->addWidget(label, 2, 0);
314  gridLayout->addWidget(leFile4OceanLd_, 2, 1);
315 
316  label = new QLabel("EOP a priori file:", gBox);
317  label->setMinimumSize(label->sizeHint());
318  leFile4Eops_ = new QLineEdit(gBox);
319  leFile4Eops_->setText(setup.getAprioriFile4Eops());
320  leFile4Eops_->setMinimumSize(leFile4Eops_->sizeHint());
321  gridLayout->addWidget(label, 3, 0);
322  gridLayout->addWidget(leFile4Eops_, 3, 1);
323 
324  label = new QLabel("Tilt a priori file:", gBox);
325  label->setMinimumSize(label->sizeHint());
326  leFile4Tilts_ = new QLineEdit(gBox);
327  leFile4Tilts_->setText(setup.getAprioriFile4Tilts());
328  leFile4Tilts_->setMinimumSize(leFile4Tilts_->sizeHint());
329  gridLayout->addWidget(label, 4, 0);
330  gridLayout->addWidget(leFile4Tilts_, 4, 1);
331 
332  label = new QLabel("Ocean pole tide loading a priori file:", gBox);
333  label->setMinimumSize(label->sizeHint());
334  leFile4OceanPoleTideLd_ = new QLineEdit(gBox);
335  leFile4OceanPoleTideLd_->setText(setup.getAprioriFile4OceanPoleTideLd());
336  leFile4OceanPoleTideLd_->setMinimumSize(leFile4OceanPoleTideLd_->sizeHint());
337  gridLayout->addWidget(label, 5, 0);
338  gridLayout->addWidget(leFile4OceanPoleTideLd_, 5, 1);
339 
340  layout->addWidget(gBox);
341 
342 
343  // general options:
344  gBox = new QGroupBox("General options", w);
345  QVBoxLayout *aLayout=new QVBoxLayout(gBox);
346  cbUseLocalLocale_ = new QCheckBox("Do not alternate locale set up", gBox);
347  cbUseLocalLocale_->setMinimumSize(cbUseLocalLocale_->sizeHint());
348  cbUseLocalLocale_->setChecked(setup.getUseLocalLocale());
349  aLayout -> addWidget(cbUseLocalLocale_);
350 
351  layout->addWidget(gBox);
352 
353 
354  return w;
355 };
356 
357 
358 
359 //
361 {
362  VcWizardPage *w=new VcWizardPage();
363  QString userName(""), userLoginName(""), userEMail(""), userInitials("");
364  QString hostName(""), domainName("");
365  bool isDUN(false);
366  SgIdentities ids;
367  if (!isFirstRun_ &&
370  isDUN = true;
371 
372  if (isFirstRun_ || isDUN)
373  {
374  // guess user login name:
375  uid_t uid=geteuid();
376  struct passwd *pw=getpwuid(uid);
377  if (!pw)
378  perror("getpwuid: ");
379  else
380  {
381  char buff[256];
382  userLoginName = pw->pw_name;
383  userName = pw->pw_gecos;
384  if (userName.contains(","))
385  userName = userName.left(userName.indexOf(","));
386 
387  // guess host name:
388  if (gethostname(buff, sizeof(buff))==-1)
389  {
390  perror("gethostname: ");
391  userEMail = userName + "@localhost";
392  }
393  else
394  {
395  hostName = buff;
396  // If hostname contains at least one dot, assume this is F.Q.D.N. host name
397  // and do not ask about the domain name:
398  //
399  if (!hostName.contains("."))
400  {
401  // guess domain name:
402  if (getdomainname(buff, sizeof(buff))==-1)
403  perror("getdomainname: ");
404  else
405  {
406  domainName = buff;
407  if (!domainName.contains("(none)") && domainName.simplified().size()>0)
408  hostName += "." + domainName;
409  };
410  };
411  userEMail = userLoginName + "@" + hostName;
412  };
413  if (userName.contains(" "))
414  {
415  userInitials = userName.mid(0, 1) + userName.mid(userName.indexOf(" ") + 1, 1);
416  }
417  else if (userName.size()>=2)
418  userInitials = userName.left(2);
419  else
420  userInitials = "??";
421  };
422  }
423  else
424  {
425  userName = setup.identities().getUserName();
426  userEMail = setup.identities().getUserEmailAddress();
427  userInitials = setup.identities().getUserDefaultInitials();
428  };
429 
430  w->setTitle("<p><font size=+1 face=\"Times\">User identities</font></p>");
431  w->setSubTitle("<font face=\"Times\"><p>Please, specify your name and e-mail address.</p></font>");
432  w->setPixmap(QWizard::WatermarkPixmap, QPixmap(":/images/pattern_3.png"));
433 
434  QString str;
435  QLabel *label;
436  QVBoxLayout *layout=new QVBoxLayout;
437  w->setLayout(layout);
438  // layout->addStretch(1);
439 
440  str =
441  "<h3>User Identities</h3>"
442  "<p>Describe yourself, your name, e-mail, etc.</p>"
443  "<p>[Plus something else, more polite...]</p>"
444  "";
445  label = new QLabel("<font face=\"Times\">" + str + "</font>");
446  label->setWordWrap(true);
447  layout->addWidget(label);
448  layout->addSpacing(20);
449 
450  QGroupBox *gBox=new QGroupBox("User Identities", w);
451  QGridLayout *gridLayout=new QGridLayout(gBox);
452 
453  label = new QLabel("User Name:", gBox);
454  label->setMinimumSize(label->sizeHint());
455  leUserName_ = new QLineEdit(gBox);
456  leUserName_->setText(userName);
457  leUserName_->setMinimumSize(leUserName_->sizeHint());
458  gridLayout->addWidget(label, 0, 0);
459  gridLayout->addWidget(leUserName_, 0, 1);
460  //
461  label = new QLabel("E-mail address:", gBox);
462  label->setMinimumSize(label->sizeHint());
463  leUserEmail_ = new QLineEdit(gBox);
464  leUserEmail_->setText(userEMail);
465  leUserEmail_->setMinimumSize(leUserEmail_->sizeHint());
466  gridLayout->addWidget(label, 1, 0);
467  gridLayout->addWidget(leUserEmail_, 1, 1);
468  //
469  label = new QLabel("User's default initials:", gBox);
470  label->setMinimumSize(label->sizeHint());
471  leUserInitials_ = new QLineEdit(gBox);
472  leUserInitials_->setText(userInitials);
473  leUserInitials_->setMinimumSize(leUserInitials_->sizeHint());
474  gridLayout->addWidget(label, 2, 0);
475  gridLayout->addWidget(leUserInitials_, 2, 1);
476 
477  layout->addWidget(gBox);
478  return w;
479 };
480 
481 
482 
483 //
485 {
486  VcWizardPage *w=new VcWizardPage();
487  QString acFullName, acAbbrevName, acAbbName;
488  SgIdentities ids;
489  bool have2ForceUser(false);
490 
491  acFullName = setup.identities().getAcFullName();
492  acAbbrevName = setup.identities().getAcAbbrevName();
493  acAbbName = setup.identities().getAcAbbName();
494 
496  {
497  acFullName = "";
498  acAbbrevName = "";
499  acAbbName = "";
500  have2ForceUser = true;
501  };
502 
503  w->setTitle("<p><font size=+1 face=\"Times\">Analysis Center identities</font></p>");
504  w->setSubTitle("<font face=\"Times\"><p>Please, describe organization where you work.</p></font>");
505  w->setPixmap(QWizard::WatermarkPixmap, QPixmap(":/images/pattern_4.png"));
506 
507  QString str;
508  QLabel *label;
509  QVBoxLayout *layout=new QVBoxLayout;
510  w->setLayout(layout);
511  // layout->addStretch(1);
512 
513  str =
514  "<h3>Analysis Center</h3>"
515  "<p>Please, specify the analysis center.</p>"
516  "<p>[Plus something else, more polite...]</p>"
517  "";
518  label = new QLabel("<font face=\"Times\">" + str + "</font>");
519  label->setWordWrap(true);
520  layout->addWidget(label);
521  layout->addSpacing(20);
522 
523  QGroupBox *gBox=new QGroupBox("Analysis Center", w);
524  QGridLayout *gridLayout=new QGridLayout(gBox);
525  // int l;
526  label = new QLabel("Full Name:", gBox);
527  label->setMinimumSize(label->sizeHint());
528  leAcFullName_ = new QLineEdit(gBox);
529  leAcFullName_->setText(acFullName);
530  leAcFullName_->setMinimumSize(leAcFullName_->sizeHint());
531  // AC names could be long:
532  // leAcFullName_->setMinimumWidth(leAcFullName_->fontMetrics().width(acFullName) + 20);
533  gridLayout->addWidget(label, 0, 0);
534  gridLayout->addWidget(leAcFullName_, 0, 1);
535  //
536  label = new QLabel("Abbreviation:", gBox);
537  label->setMinimumSize(label->sizeHint());
538  leAcAbbrevName_ = new QLineEdit(gBox);
539  leAcAbbrevName_->setText(acAbbrevName);
540  leAcAbbrevName_->setMinimumSize(leAcAbbrevName_->sizeHint());
541  gridLayout->addWidget(label, 1, 0);
542  gridLayout->addWidget(leAcAbbrevName_, 1, 1);
543  //
544  label = new QLabel("Abbrev.:", gBox);
545  label->setMinimumSize(label->sizeHint());
546  leAcAbbName_ = new QLineEdit(gBox);
547  leAcAbbName_->setText(acAbbName);
548  leAcAbbName_->setMinimumSize(leAcAbbName_->sizeHint());
549  gridLayout->addWidget(label, 2, 0);
550  gridLayout->addWidget(leAcAbbName_, 2, 1);
551 
552  if (have2ForceUser)
553  {
554  w->registerField("acFullName*", leAcFullName_);
555  w->registerField("acAbbrevName*", leAcAbbrevName_);
556 // w->registerField("acAbbName*", leAcAbbName_);
557  };
558 
559  layout->addWidget(gBox);
560  return w;
561 };
562 
563 
564 
565 //
567 {
568  VcWizardPage *w=new VcWizardPage();
569  const QString logLevelNames[4] = {"Error", "Warning", "Info", "Debug"};
570  int logLevel(settings_->value("Logger/LogLevel", 2).toInt());
571 
572  w->setTitle("<p><font size=+1 face=\"Times\">Logger </font></p>");
573  w->setSubTitle("<font face=\"Times\"><p>Set up configuration of the logging subsystem.</p></font>");
574  w->setPixmap(QWizard::WatermarkPixmap, QPixmap(":/images/pattern_5.png"));
575 
576  QString str;
577  QLabel *label;
578  QVBoxLayout *layout=new QVBoxLayout;
579  w->setLayout(layout);
580 
581  str =
582  "<h3>Logger</h3>"
583  "<p>Change parameters of the logging subsystem.</p>"
584  "";
585  label = new QLabel("<font face=\"Times\">" + str + "</font>");
586  label->setWordWrap(true);
587  layout->addWidget(label);
588  layout->addSpacing(20);
589 
590 
591  QGroupBox *gBox;
592  QGridLayout *gridLayout;
593 
594  gBox = new QGroupBox("Main log options", w);
595  gridLayout = new QGridLayout(gBox);
596 
597  eLogFileName_ = new QLineEdit(gBox);
598  eLogFileName_->setText(logger->getFileName());
599  label = new QLabel("Log file name:", gBox);
600  label->setMinimumSize(label->sizeHint());
601  eLogFileName_->setMinimumSize(eLogFileName_->sizeHint());
602 
603  gridLayout->addWidget(label, 0, 0);
604  gridLayout->addWidget(eLogFileName_, 0, 1);
605 
606  sLogCapacity_ = new QSpinBox(gBox);
607  sLogCapacity_ -> setSuffix(" lines");
608  label = new QLabel("Log capacity:", gBox);
609  label->setMinimumSize(label->sizeHint());
610  sLogCapacity_->setMinimumSize(sLogCapacity_->sizeHint());
611  sLogCapacity_->setMaximum(100000);
612  sLogCapacity_->setMinimum(100);
613  sLogCapacity_->setSingleStep(100);
614  sLogCapacity_->setValue(logger->getCapacity());
615  gridLayout->addWidget(label, 1, 0);
616  gridLayout->addWidget(sLogCapacity_, 1, 1);
617 
618  gridLayout->setColumnStretch( 2, 1);
619 
620  cbLogStoreInFile_ = new QCheckBox("Save log to the file", gBox);
621  cbLogTimeLabel_ = new QCheckBox("Put time stamps", gBox);
622  cbLogStoreInFile_->setMinimumSize(cbLogStoreInFile_->sizeHint());
623  cbLogTimeLabel_->setMinimumSize(cbLogTimeLabel_->sizeHint());
624  cbLogStoreInFile_->setChecked(logger->getIsStoreInFile());
625  cbLogTimeLabel_->setChecked(logger->getIsNeedTimeMark());
626  gridLayout->addWidget(cbLogStoreInFile_, 0, 3);
627  gridLayout->addWidget(cbLogTimeLabel_ , 1, 3);
628 
629  gridLayout->activate();
630  layout->addWidget(gBox);
631 
632 
633  gBox = new QGroupBox("Main log levels", w);
634  bgLogLevels_ = new QButtonGroup(gBox);
635  QVBoxLayout *aLayout=new QVBoxLayout(gBox);
636  QRadioButton *rbLogLevel[4];
637  for (int i=0; i<4; i++)
638  {
639  rbLogLevel[i] = new QRadioButton(logLevelNames[i], gBox);
640  rbLogLevel[i]-> setMinimumSize(rbLogLevel[i]->sizeHint());
641  bgLogLevels_->addButton(rbLogLevel[i], i);
642  aLayout->addWidget(rbLogLevel[i]);
643  };
644  rbLogLevel[logLevel]->setChecked(true);
645  layout->addWidget(gBox);
646 
647  // ----
648  //
649  gBox = new QGroupBox("Aux log options", w);
650  gridLayout = new QGridLayout(gBox);
651 
652  leAuxLogsDirName_ = new QLineEdit(gBox);
654  label = new QLabel("Path to logs for each session:", gBox);
655  label->setMinimumSize(label->sizeHint());
656  leAuxLogsDirName_->setMinimumSize(leAuxLogsDirName_->sizeHint());
657  gridLayout->addWidget(label, 0, 0);
658  gridLayout->addWidget(leAuxLogsDirName_, 0, 1);
659 
660  cbMakeAuxLog_ = new QCheckBox("Save log file for each session", gBox);
661  cbMakeAuxLog_->setMinimumSize(cbMakeAuxLog_->sizeHint());
663  gridLayout->addWidget(cbMakeAuxLog_, 1, 0, 1, 2);
664 
665  layout->addWidget(gBox);
666 
667  return w;
668 };
669 
670 
671 
672 //
674 {
675  VcWizardPage *w=new VcWizardPage();
676  QString str;
677 
678  w->setTitle("<p><font size=+1 face=\"Times\">Ready to run</font></p>");
679  w->setSubTitle("<font face=\"Times\"><p>We are done.</p></font>");
680  w->setPixmap(QWizard::WatermarkPixmap, QPixmap(":/images/pattern_6.png"));
681 
682  QVBoxLayout *layout = new QVBoxLayout;
683  w->setLayout(layout);
684 
685  // first label:
686  str =
687  "<h3>vgosDbCalc is ready to run</h3>"
688  "<p>Good luck.</p>"
689  "";
690  QLabel *label = new QLabel("<font face=\"Times\">" + str + "</font>");
691  label->setWordWrap(true);
692  layout->addWidget(label);
693 
694  return w;
695 };
696 
697 
698 
699 //
701 {
702  if (!isSystemWideRun_)
703  {
708  };
713  setup.setPath2SolveAprioriFiles(leSolveAPrioriDirName_->text());
715 
716  setup.setAprioriFile4Sites(leFile4Sites_->text());
717  setup.setAprioriFile4Sources(leFile4Sources_->text());
718  setup.setAprioriFile4OceanLd(leFile4OceanLd_->text());
719  setup.setAprioriFile4Eops(leFile4Eops_->text());
720  setup.setAprioriFile4Tilts(leFile4Tilts_->text());
721  setup.setAprioriFile4OceanPoleTideLd(leFile4OceanPoleTideLd_->text());
722 
725  setup.setUseLocalLocale(cbUseLocalLocale_->isChecked());
726  //
727  logger->setFileName(eLogFileName_->text());
728  logger->setCapacity(sLogCapacity_->value());
731 
732  int logLevel=bgLogLevels_->checkedId();
733  if (logLevel != -1)
734  {
735  settings_->setValue("Logger/LogLevel", logLevel);
736  logger->setLogFacility(SgLogger::ERR, logLevel>=0?0xFFFFFFFF:0);
737  logger->setLogFacility(SgLogger::WRN, logLevel>=1?0xFFFFFFFF:0);
738  logger->setLogFacility(SgLogger::INF, logLevel>=2?0xFFFFFFFF:0);
739  logger->setLogFacility(SgLogger::DBG, logLevel==3?0xFFFFFFFF:0);
740  };
741  //
742  // check home dir:
743  if (!isSystemWideRun_)
744  {
745  QDir dir;
746  if (!dir.exists(setup.getPath2Home()))
747  {
748  if (!dir.mkpath(setup.getPath2Home()))
749  QMessageBox::warning(this, "Warning", "Cannot create Home directory " +
750  setup.getPath2Home());
751  else
753  "::the directory " + setup.getPath2Home() + " has been created");
754  };
755  };
756  //
757  QWizard::accept();
758 };
759 /*=====================================================================================================*/
SgLogger * logger
Definition: SgLogger.cpp:231
SgVersion libraryVersion("SgLib", 0, 8, 2, "Compton Peak (rc2)", SgMJD(2023, 4, 3, 10, 59))
SgVersion vgosDbCalcVersion("vgosDbCalc", 0, 5, 2, "Fort Windham Rocks (rc2)", SgMJD(2023, 4, 3, 11, 6))
const QString & getPath2AuxLogs() const
Definition: NsSetup.h:510
const QString & getPath2MasterFiles() const
Definition: NsSetup.h:446
bool getHave2SavePerSessionLog() const
Definition: NsSetup.h:518
void setHave2SavePerSessionLog(bool)
Definition: NsSetup.h:816
const QString & getPath2Home() const
Definition: NsSetup.h:406
void setPath2Home(const QString &)
Definition: NsSetup.h:704
SgIdentities & identities()
Definition: NsSetup.h:566
void setPath2VgosDbFiles(const QString &)
Definition: NsSetup.h:728
const QString & getPath2VgosDbFiles() const
Definition: NsSetup.h:430
void setPath2MasterFiles(const QString &)
Definition: NsSetup.h:744
void setPath2AuxLogs(const QString &)
Definition: NsSetup.h:808
const QString & getAcAbbrevName() const
Definition: SgIdentities.h:247
const QString & getAcAbbName() const
Definition: SgIdentities.h:255
void setAcAbbrevName(const QString &)
Definition: SgIdentities.h:367
void setAcFullName(const QString &)
Definition: SgIdentities.h:359
const QString & getUserEmailAddress() const
Definition: SgIdentities.h:223
void setAcAbbName(const QString &)
Definition: SgIdentities.h:375
const QString & getUserDefaultInitials() const
Definition: SgIdentities.h:231
const QString & getAcFullName() const
Definition: SgIdentities.h:239
void setUserDefaultInitials(const QString &)
Definition: SgIdentities.h:351
void setUserEmailAddress(const QString &)
Definition: SgIdentities.h:343
void setUserName(const QString &)
Definition: SgIdentities.h:335
const QString & getUserName() const
Definition: SgIdentities.h:215
virtual void write(LogLevel, quint32, const QString &, bool=false)
Definition: SgLogger.cpp:88
bool getIsStoreInFile() const
Definition: SgLogger.h:137
void setIsStoreInFile(bool isStoreInFile)
Definition: SgLogger.h:127
void setLogFacility(LogLevel lvl, quint32 f)
Definition: SgLogger.h:131
void setFileName(const QString &fileName)
Definition: SgLogger.h:125
void setIsNeedTimeMark(bool isNeedTimeMark)
Definition: SgLogger.h:129
void setCapacity(int capacity)
Definition: SgLogger.h:126
bool getIsNeedTimeMark() const
Definition: SgLogger.h:139
const QString & getFileName() const
Definition: SgLogger.h:135
int getCapacity() const
Definition: SgLogger.h:136
const QString & getSoftwareName() const
Definition: SgVersion.h:254
const QString & getCodeName() const
Definition: SgVersion.h:286
QString toString() const
Definition: SgVersion.h:356
QLineEdit * leFile4OceanLd_
QLineEdit * leMasterFilesDirName_
QLineEdit * leFile4Eops_
QButtonGroup * bgLogLevels_
QLineEdit * leAuxLogsDirName_
QLineEdit * leFile4Tilts_
QLineEdit * leVgosDbDirName_
QCheckBox * cbLogTimeLabel_
VcStartupWizard(bool isFirstRun, bool isForcedRun, bool isSystemWideRun, QSettings *settings, QWidget *parent=0)
static int serialNumber()
QLineEdit * leAcAbbrevName_
VcWizardPage * createConclusionPage()
QLineEdit * leUserName_
static const int serialNumber_
virtual ~VcStartupWizard()
QLineEdit * eLogFileName_
QLineEdit * leUserEmail_
QLineEdit * leFile4Sites_
QCheckBox * cbMakeAuxLog_
QString className() const
VcWizardPage * createPageOne()
QLineEdit * leFile4OceanPoleTideLd_
QLineEdit * leSolveAPrioriDirName_
QSettings * settings_
QCheckBox * cbLogStoreInFile_
QLineEdit * leHomeDirName_
VcWizardPage * createPageHomeDir()
QLineEdit * leFile4Sources_
QLineEdit * leUserInitials_
QLineEdit * leAcAbbName_
VcWizardPage * createPageTwo()
QSpinBox * sLogCapacity_
QCheckBox * cbUseLocalLocale_
QLineEdit * leAcFullName_
VcWizardPage * createIntroPage()
VcWizardPage * createPageThree()
void registerField(const QString &name, QWidget *widget, const char *property=0, const char *changedSignal=0)
NsSetup setup
Definition: nuSolve.cpp:61