data;
switch (ui->aliasComboBox->currentIndex()) {
case 0:
data.insert("displayname","self");
break;
case 1:
data.insert("displayname","SELF");
break;
case 2:{
QString name;
name.append(ui->piclastnameLineEdit->text());
name.append(QLatin1String(", "));
name.append(ui->picfirstnameLineEdit->text().left(1));
name.append(QLatin1Char('.'));
data.insert("displayname",name);
}
break;
default:
break;
}
data.insert("piclastname",ui->piclastnameLineEdit->text());
data.insert("picfirstname",ui->picfirstnameLineEdit->text());
data.insert("company",ui->companyLineEdit->text());
data.insert("employeeid",ui->employeeidLineEdit->text());
data.insert("phone",ui->phoneLineEdit->text());
data.insert("email",ui->emailLineEdit->text());
Pilot pic(1);
pic.setData(data);
pic.commit();
}
/*
* Slots
*/
/*
* Personal Tab
*/
void SettingsWidget::on_piclastnameLineEdit_editingFinished()
{
if(ui->piclastnameLineEdit->text().isEmpty()){
ui->piclastnameLineEdit->setText(Settings::read("userdata/piclastname").toString());
ui->piclastnameLineEdit->setFocus();
} else {
Settings::write("userdata/piclastname",ui->piclastnameLineEdit->text());
updatePersonalDetails();
}
}
void SettingsWidget::on_picfirstnameLineEdit_editingFinished()
{
if(ui->picfirstnameLineEdit->text().isEmpty()){
ui->picfirstnameLineEdit->setText(Settings::read("userdata/picfirstname").toString());
ui->picfirstnameLineEdit->setFocus();
} else {
Settings::write("userdata/picfirstname",ui->picfirstnameLineEdit->text());
updatePersonalDetails();
}
}
void SettingsWidget::on_companyLineEdit_editingFinished()
{
Settings::write("userdata/company",ui->companyLineEdit->text());
updatePersonalDetails();
}
void SettingsWidget::on_employeeidLineEdit_editingFinished()
{
Settings::write("userdata/employeeid",ui->employeeidLineEdit->text());
updatePersonalDetails();
}
void SettingsWidget::on_emailLineEdit_editingFinished()
{
Settings::write("userdata/email",ui->emailLineEdit->text());
updatePersonalDetails();
}
void SettingsWidget::on_phoneLineEdit_editingFinished()
{
Settings::write("userdata/phone",ui->phoneLineEdit->text());
updatePersonalDetails();
}
/*
* Flight Logging Tab
*/
void SettingsWidget::on_aliasComboBox_currentIndexChanged(int index)
{
Settings::write("userdata/displayselfas",index);
updatePersonalDetails();
}
void SettingsWidget::on_functionComboBox_currentIndexChanged(const QString &arg1)
{
Settings::write("flightlogging/function", arg1);
}
void SettingsWidget::on_rulesComboBox_currentIndexChanged(const QString &arg1)
{
Settings::write("flightlogging/rules", arg1);
}
void SettingsWidget::on_approachComboBox_currentIndexChanged(const QString &arg1)
{
Settings::write("flightlogging/approach", arg1);
}
void SettingsWidget::on_nightComboBox_currentIndexChanged(int index)
{
Settings::write("flightlogging/nightlogging", index);
switch (index) {
case 1:
Settings::write("flightlogging/nightangle",-6);
break;
case 2:
Settings::write("flightlogging/nightangle",0);
break;
default:
Settings::write("flightlogging/nightangle",-6);
}
}
void SettingsWidget::on_prefixLineEdit_textChanged(const QString &arg1)
{
Settings::write("flightlogging/flightnumberPrefix", arg1);
}
/*
* Misc Tab
*/
void SettingsWidget::themeGroup_toggled(int id)
{
Settings::write("main/theme", id);
QMessageBox::StandardButton reply;
reply = QMessageBox::question(this, "Changing Themes",
"Changing the theme requires restarting the Application.\n\nWould you like to restart now?",
QMessageBox::Yes | QMessageBox::No);
if (reply == QMessageBox::Yes) {
qApp->quit();
QProcess::startDetached(qApp->arguments()[0], qApp->arguments());
} else {
QMessageBox *info = new QMessageBox(this);
info->setText("Theme change will take effect the next time you start the application.");
info->exec();
}
}
void SettingsWidget::on_logbookViewComboBox_currentIndexChanged(int index)
{
Settings::write("logbook/view", index);
}
void SettingsWidget::on_pilotSortComboBox_currentIndexChanged(int index)
{
Settings::write("userdata/pilSortColumn", index);
}
void SettingsWidget::on_acSortComboBox_currentIndexChanged(int index)
{
Settings::write("userdata/acSortColumn", index);
}
void SettingsWidget::on_acAllowIncompleteComboBox_currentIndexChanged(int index)
{
Settings::write("userdata/acAllowIncomplete", index);
if (index) {
QMessageBox::StandardButton reply;
reply = QMessageBox::warning(this, "Warning",
"Enabling incomplete logging will enable you to add aircraft with incomplete data.\n\n"
"If you do not fill out the aircraft details, "
"it will be impossible to automatically determine Single/Multi Pilot Times or Single/Multi Engine Time. "
"This will also impact statistics and auto-logging capabilites as well as jeopardise database integrity.\n\n"
"It is highly recommended to keep this option off unless you have a specific reason not to.\n\n"
"Are you sure you want to proceed?",
QMessageBox::Yes | QMessageBox::No);
if (reply == QMessageBox::Yes) {
Settings::write("userdata/acAllowIncomplete", index);
} else {
ui->acAllowIncompleteComboBox->setCurrentIndex(0);
}
}
}
/*
* About Tab
*/
void SettingsWidget::on_aboutPushButton_clicked()
{
auto mb = new QMessageBox(this);
QString SQLITE_VERSION = DbInfo().version;
QString text = QMessageBox::tr(
"About openPilotLog
"
"
"
"(c) 2020 Felix Turowsky"
"
"
"This is a collaboratively developed Free and Open Source Application. "
"Visit us here for more information.
"
"This program is free software: you can redistribute it and/or modify "
"it under the terms of the GNU General Public License as published by "
"the Free Software Foundation, either version 3 of the License, or "
"(at your option) any later version.
"
"This program is distributed in the hope that it will be useful, "
"but WITHOUT ANY WARRANTY; without even the implied warranty of "
"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the "
"GNU General Public License for more details.
"
"You should have received a copy of the GNU General Public License "
"along with this program. If not, "
"please click here.
"
"
"
"This program uses Qt version %3 and "
"SQLite version %4
"
).arg(QLatin1String("github.com/fiffty-50/openpilotlog"),
QLatin1String("qt.io"),
QLatin1String(QT_VERSION_STR),
QString(SQLITE_VERSION));
mb->setText(text);
mb->open();
}