28 #include <sys/types.h>
31 #include <QtCore/QDir>
32 #include <QtCore/QSettings>
34 #if QT_VERSION >= 0x050000
35 # include <QtWidgets/QBoxLayout>
36 # include <QtWidgets/QButtonGroup>
37 # include <QtWidgets/QCheckBox>
38 # include <QtWidgets/QFrame>
39 # include <QtWidgets/QGroupBox>
40 # include <QtWidgets/QGridLayout>
41 # include <QtWidgets/QLabel>
42 # include <QtWidgets/QLineEdit>
43 # include <QtWidgets/QMessageBox>
44 # include <QtWidgets/QPushButton>
45 # include <QtWidgets/QRadioButton>
46 # include <QtWidgets/QSpinBox>
47 # include <QtWidgets/QVBoxLayout>
49 # include <QtGui/QBoxLayout>
50 # include <QtGui/QButtonGroup>
51 # include <QtGui/QCheckBox>
52 # include <QtGui/QFrame>
53 # include <QtGui/QGroupBox>
54 # include <QtGui/QGridLayout>
55 # include <QtGui/QLabel>
56 # include <QtGui/QLineEdit>
57 # include <QtGui/QMessageBox>
58 # include <QtGui/QPushButton>
59 # include <QtGui/QRadioButton>
60 # include <QtGui/QSpinBox>
61 # include <QtGui/QVBoxLayout>
64 #include <QtGui/QPixmap>
92 QSettings *settings,
QWidget *parent)
107 setWizardStyle(ModernStyle);
109 setPixmap(QWizard::LogoPixmap, QPixmap(
":/images/NVI_logo.png"));
110 setPixmap(QWizard::WatermarkPixmap, QPixmap(
":/images/pattern_1.png"));
114 QString(isSystemWideRun?
" (system-wide settings)":
""));
134 w->setTitle(
"<p><font size=+1 face=\"Times\">Welcome to vgosDbMake</font></p>");
137 str =
"The Startup Wizard will ask you few questions about software configuration.";
139 w->setSubTitle(
"<font face=\"Times\"><p>Thank you for installing vgosDbMake version " +
142 w->setSubTitle(
"<font face=\"Times\"><p>Congratulation! You just have upgraded SgLib and "
146 w->setSubTitle(
"<font face=\"Times\"><p>Startup Wizard welcomes you. "
147 "You are using SgLib version " +
152 w->setButtonText(QWizard::NextButton,
"Agree");
154 QVBoxLayout *layout =
new QVBoxLayout;
155 w->setLayout(layout);
159 "<h3>vgosDbMake</h3>"
160 "<p>vgosDbMake is software that converts VLBI data in vgosDb format."
162 "<p>Copyright (C) 2015-2020 Sergei Bolotin.</p>"
164 "<p>This program is free software: you can redistribute it and/or modify "
165 "it under the terms of the GNU General Public License as published by "
166 "the Free Software Foundation, either version 3 of the License, or "
167 "(at your option) any later version.</p>"
169 "<p>This program is distributed in the hope that it will be useful, "
170 "but WITHOUT ANY WARRANTY; without even the implied warranty of "
171 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the "
172 "GNU General Public License for more details.</p>"
174 "<p>You should have received a copy of the GNU General Public License "
175 "along with this program. If not, see http://www.gnu.org/licenses.</p>"
177 "<p>Please, read carefully the license agreement and if you agree, press \"Agree\" button.</p>"
180 QLabel *label=
new QLabel(
"<font face=\"Times\">" + str +
"</font>");
181 label->setWordWrap(
true);
182 layout->addWidget(label);
183 layout->addStretch(1);
185 QCheckBox *cb=
new QCheckBox(
"I have read and accept the conditions.", w);
187 layout->addWidget(cb);
188 layout->addSpacing(40);
200 bool have2ForceUser(
false);
204 QVBoxLayout *layout=
new QVBoxLayout;
206 QGridLayout *gridLayout;
207 w->setLayout(layout);
210 w->setTitle(
"<p><font size=+1 face=\"Times\">Essential directories of vgosDbMake</font></p>");
211 w->setSubTitle(
"<font face=\"Times\"><p>The working directory of the software.</p></font>");
212 w->setPixmap(QWizard::WatermarkPixmap, QPixmap(
":/images/pattern_2.png"));
216 "<h3>Default Directories</h3>"
217 "<p>Please, provide paths to data on your system.</p>"
218 "<p>Users will be able to overwrite default settings.</p>"
222 "<h3>vgosDbMake Home Directory</h3>"
223 "<p>Please, specify the software's home directory.</p>"
224 "<p>All paths that are not absolute will be counted form this directory. The software home "
225 "directory have to be writable for a user and should be different from user's home directory.</p>"
227 label =
new QLabel(
"<font face=\"Times\">" + str +
"</font>");
228 label->setWordWrap(
true);
229 layout->addWidget(label);
230 layout->addSpacing(20);
237 if (path2Home == QDir::homePath())
238 have2ForceUser =
true;
240 gBox =
new QGroupBox(
"vgosDbMake home directory", w);
241 gridLayout =
new QGridLayout(gBox);
242 label =
new QLabel(
"Path to the software home directory:", gBox);
243 label->setMinimumSize(label->sizeHint());
247 gridLayout->addWidget(label, 0, 0);
252 layout->addWidget(gBox);
253 layout->addSpacing(20);
256 gBox =
new QGroupBox(
"Essential directories", w);
257 gridLayout =
new QGridLayout(gBox);
259 label =
new QLabel(
"Path to mark{3,4} files (input):", gBox);
260 label->setMinimumSize(label->sizeHint());
264 gridLayout->addWidget(label, 0, 0);
267 label =
new QLabel(
"Path to vgosDb files (output):", gBox);
268 label->setMinimumSize(label->sizeHint());
272 gridLayout->addWidget(label, 1, 0);
275 label =
new QLabel(
"Path to Master files:", gBox);
276 label->setMinimumSize(label->sizeHint());
280 gridLayout->addWidget(label, 2, 0);
283 layout->addWidget(gBox);
287 gBox =
new QGroupBox(
"General options", w);
288 QVBoxLayout *aLayout=
new QVBoxLayout(gBox);
295 layout->addWidget(gBox);
306 QString userName(
""), userLoginName(
""), userEMail(
""), userInitials(
"");
307 QString hostName(
""), domainName(
"");
319 struct passwd *pw=getpwuid(uid);
321 perror(
"getpwuid: ");
325 userLoginName = pw->pw_name;
326 userName = pw->pw_gecos;
327 if (userName.contains(
","))
328 userName = userName.left(userName.indexOf(
","));
331 if (gethostname(buff,
sizeof(buff))==-1)
333 perror(
"gethostname: ");
334 userEMail = userName +
"@localhost";
342 if (!hostName.contains(
"."))
345 if (getdomainname(buff,
sizeof(buff))==-1)
346 perror(
"getdomainname: ");
350 if (!domainName.contains(
"(none)") && domainName.simplified().size()>0)
351 hostName +=
"." + domainName;
354 userEMail = userLoginName +
"@" + hostName;
356 if (userName.contains(
" "))
358 userInitials = userName.mid(0, 1) + userName.mid(userName.indexOf(
" ") + 1, 1);
360 else if (userName.size()>=2)
361 userInitials = userName.left(2);
373 w->setTitle(
"<p><font size=+1 face=\"Times\">User identities</font></p>");
374 w->setSubTitle(
"<font face=\"Times\"><p>Please, specify your name and e-mail address.</p></font>");
375 w->setPixmap(QWizard::WatermarkPixmap, QPixmap(
":/images/pattern_3.png"));
379 QVBoxLayout *layout=
new QVBoxLayout;
380 w->setLayout(layout);
384 "<h3>User Identities</h3>"
385 "<p>Describe yourself, your name, e-mail, etc.</p>"
386 "<p>[Plus something else, more polite...]</p>"
388 label =
new QLabel(
"<font face=\"Times\">" + str +
"</font>");
389 label->setWordWrap(
true);
390 layout->addWidget(label);
391 layout->addSpacing(20);
393 QGroupBox *gBox=
new QGroupBox(
"User Identities", w);
394 QGridLayout *gridLayout=
new QGridLayout(gBox);
396 label =
new QLabel(
"User Name:", gBox);
397 label->setMinimumSize(label->sizeHint());
401 gridLayout->addWidget(label, 0, 0);
404 label =
new QLabel(
"E-mail address:", gBox);
405 label->setMinimumSize(label->sizeHint());
409 gridLayout->addWidget(label, 1, 0);
412 label =
new QLabel(
"User's default initials:", gBox);
413 label->setMinimumSize(label->sizeHint());
417 gridLayout->addWidget(label, 2, 0);
420 layout->addWidget(gBox);
430 QString acFullName, acAbbrevName, acAbbName;
432 bool have2ForceUser(
false);
443 have2ForceUser =
true;
446 w->setTitle(
"<p><font size=+1 face=\"Times\">Analysis Center identities</font></p>");
447 w->setSubTitle(
"<font face=\"Times\"><p>Please, describe organization where you work.</p></font>");
448 w->setPixmap(QWizard::WatermarkPixmap, QPixmap(
":/images/pattern_4.png"));
452 QVBoxLayout *layout=
new QVBoxLayout;
453 w->setLayout(layout);
457 "<h3>Analysis Center</h3>"
458 "<p>Please, specify the analysis center.</p>"
459 "<p>[Plus something else, more polite...]</p>"
461 label =
new QLabel(
"<font face=\"Times\">" + str +
"</font>");
462 label->setWordWrap(
true);
463 layout->addWidget(label);
464 layout->addSpacing(20);
466 QGroupBox *gBox=
new QGroupBox(
"Analysis Center", w);
467 QGridLayout *gridLayout=
new QGridLayout(gBox);
469 label =
new QLabel(
"Full Name:", gBox);
470 label->setMinimumSize(label->sizeHint());
476 gridLayout->addWidget(label, 0, 0);
479 label =
new QLabel(
"Abbreviation:", gBox);
480 label->setMinimumSize(label->sizeHint());
484 gridLayout->addWidget(label, 1, 0);
487 label =
new QLabel(
"Abbrev.:", gBox);
488 label->setMinimumSize(label->sizeHint());
492 gridLayout->addWidget(label, 2, 0);
502 layout->addWidget(gBox);
512 const QString logLevelNames[4] = {
"Error",
"Warning",
"Info",
"Debug"};
513 int logLevel(
settings_->value(
"Logger/LogLevel", 2).toInt());
515 w->setTitle(
"<p><font size=+1 face=\"Times\">Logger </font></p>");
516 w->setSubTitle(
"<font face=\"Times\"><p>Set up configuration of the logging subsystem.</p></font>");
517 w->setPixmap(QWizard::WatermarkPixmap, QPixmap(
":/images/pattern_5.png"));
521 QVBoxLayout *layout=
new QVBoxLayout;
522 w->setLayout(layout);
526 "<p>Change parameters of the logging subsystem.</p>"
528 label =
new QLabel(
"<font face=\"Times\">" + str +
"</font>");
529 label->setWordWrap(
true);
530 layout->addWidget(label);
531 layout->addSpacing(20);
535 QGridLayout *gridLayout;
537 gBox =
new QGroupBox(
"Main log options", w);
538 gridLayout =
new QGridLayout(gBox);
542 label =
new QLabel(
"Log file name:", gBox);
543 label->setMinimumSize(label->sizeHint());
546 gridLayout->addWidget(label, 0, 0);
551 label =
new QLabel(
"Log capacity:", gBox);
552 label->setMinimumSize(label->sizeHint());
558 gridLayout->addWidget(label, 1, 0);
561 gridLayout->setColumnStretch( 2, 1);
572 gridLayout->activate();
573 layout->addWidget(gBox);
576 gBox =
new QGroupBox(
"Main log level", w);
578 QVBoxLayout *aLayout=
new QVBoxLayout(gBox);
579 QRadioButton *rbLogLevel[4];
580 for (
int i=0; i<4; i++)
582 rbLogLevel[i] =
new QRadioButton(logLevelNames[i], gBox);
583 rbLogLevel[i]-> setMinimumSize(rbLogLevel[i]->sizeHint());
585 aLayout->addWidget(rbLogLevel[i]);
587 rbLogLevel[logLevel]->setChecked(
true);
588 layout->addWidget(gBox);
592 gBox =
new QGroupBox(
"Aux log options", w);
593 gridLayout =
new QGridLayout(gBox);
597 label =
new QLabel(
"Path to logs for each session:", gBox);
598 label->setMinimumSize(label->sizeHint());
600 gridLayout->addWidget(label, 0, 0);
603 cbMakeAuxLog_ =
new QCheckBox(
"Save log file for each session", gBox);
608 gridLayout->activate();
609 layout->addWidget(gBox);
622 w->setTitle(
"<p><font size=+1 face=\"Times\">Ready to run</font></p>");
623 w->setSubTitle(
"<font face=\"Times\"><p>We are done.</p></font>");
624 w->setPixmap(QWizard::WatermarkPixmap, QPixmap(
":/images/pattern_6.png"));
626 QVBoxLayout *layout =
new QVBoxLayout;
627 w->setLayout(layout);
631 "<h3>vgosDbMake is ready to run</h3>"
634 QLabel *label =
new QLabel(
"<font face=\"Times\">" + str +
"</font>");
635 label->setWordWrap(
true);
636 layout->addWidget(label);
673 settings_->setValue(
"Logger/LogLevel", logLevel);
687 QMessageBox::warning(
this,
"Warning",
"Cannot create Home directory " +
SgVersion libraryVersion("SgLib", 0, 8, 2, "Compton Peak (rc2)", SgMJD(2023, 4, 3, 10, 59))
const QString & getPath2AuxLogs() const
const QString & getPath2MasterFiles() const
bool getHave2SavePerSessionLog() const
void setHave2SavePerSessionLog(bool)
const QString & getPath2Home() const
void setPath2Home(const QString &)
SgIdentities & identities()
void setPath2VgosDbFiles(const QString &)
const QString & getPath2VgosDbFiles() const
void setPath2MasterFiles(const QString &)
void setPath2AuxLogs(const QString &)
const QString & getAcAbbrevName() const
const QString & getAcAbbName() const
void setAcAbbrevName(const QString &)
void setAcFullName(const QString &)
const QString & getUserEmailAddress() const
void setAcAbbName(const QString &)
const QString & getUserDefaultInitials() const
const QString & getAcFullName() const
void setUserDefaultInitials(const QString &)
void setUserEmailAddress(const QString &)
void setUserName(const QString &)
const QString & getUserName() const
virtual void write(LogLevel, quint32, const QString &, bool=false)
bool getIsStoreInFile() const
void setIsStoreInFile(bool isStoreInFile)
void setLogFacility(LogLevel lvl, quint32 f)
void setFileName(const QString &fileName)
void setIsNeedTimeMark(bool isNeedTimeMark)
void setCapacity(int capacity)
bool getIsNeedTimeMark() const
const QString & getFileName() const
const QString & getSoftwareName() const
const QString & getCodeName() const
QLineEdit * eLogFileName_
QLineEdit * leInputDirName_
QCheckBox * cbLogStoreInFile_
QLineEdit * leVgosDbDirName_
virtual ~VmStartupWizard()
VmWizardPage * createIntroPage()
VmWizardPage * createPageOne()
QLineEdit * leAcAbbrevName_
VmWizardPage * createPageHomeDir()
QButtonGroup * bgLogLevels_
QCheckBox * cbLogTimeLabel_
QLineEdit * leAcFullName_
VmWizardPage * createPageThree()
QLineEdit * leHomeDirName_
QString className() const
VmWizardPage * createPageTwo()
QCheckBox * cbMakeAuxLog_
QLineEdit * leUserInitials_
VmStartupWizard(bool isFirstRun, bool isForcedRun, bool isSystemWideRun, QSettings *settings, QWidget *parent=0)
static int serialNumber()
QLineEdit * leMasterFilesDirName_
QCheckBox * cbUseLocalLocale_
QLineEdit * leAuxLogsDirName_
static const int serialNumber_
VmWizardPage * createConclusionPage()
void registerField(const QString &name, QWidget *widget, const char *property=0, const char *changedSignal=0)
SgVersion vgosDbMakeVersion