|
@@ -19,6 +19,10 @@
|
|
#include "ui_settingswidget.h"
|
|
#include "ui_settingswidget.h"
|
|
#include "src/database/dbinfo.h"
|
|
#include "src/database/dbinfo.h"
|
|
|
|
|
|
|
|
+// Debug Makro
|
|
|
|
+#define DEB(expr) \
|
|
|
|
+ qDebug() << __PRETTY_FUNCTION__ << "\t" << expr
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
SettingsWidget::SettingsWidget(QWidget *parent) :
|
|
SettingsWidget::SettingsWidget(QWidget *parent) :
|
|
@@ -27,18 +31,46 @@ SettingsWidget::SettingsWidget(QWidget *parent) :
|
|
{
|
|
{
|
|
ui->setupUi(this);
|
|
ui->setupUi(this);
|
|
ui->tabWidget->setCurrentIndex(0);
|
|
ui->tabWidget->setCurrentIndex(0);
|
|
- QSettings settings;
|
|
|
|
|
|
|
|
- /*
|
|
|
|
- * General Tab
|
|
|
|
- */
|
|
|
|
auto *themeGroup = new QButtonGroup;
|
|
auto *themeGroup = new QButtonGroup;
|
|
themeGroup->addButton(ui->systemThemeCheckBox, 0);
|
|
themeGroup->addButton(ui->systemThemeCheckBox, 0);
|
|
themeGroup->addButton(ui->lightThemeCheckBox, 1);
|
|
themeGroup->addButton(ui->lightThemeCheckBox, 1);
|
|
themeGroup->addButton(ui->darkThemeCheckBox, 2);
|
|
themeGroup->addButton(ui->darkThemeCheckBox, 2);
|
|
connect(themeGroup, SIGNAL(buttonClicked(int)), this, SLOT(themeGroup_toggled(int)));
|
|
connect(themeGroup, SIGNAL(buttonClicked(int)), this, SLOT(themeGroup_toggled(int)));
|
|
|
|
|
|
|
|
+ fillSettings();
|
|
|
|
+ setupValidators();
|
|
|
|
+
|
|
|
|
+}
|
|
|
|
|
|
|
|
+SettingsWidget::~SettingsWidget()
|
|
|
|
+{
|
|
|
|
+ delete ui;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void SettingsWidget::fillSettings()
|
|
|
|
+{
|
|
|
|
+ QSettings settings;
|
|
|
|
+ /*
|
|
|
|
+ * Personal Tab
|
|
|
|
+ */
|
|
|
|
+ ui->piclastnameLineEdit->setText(settings.value("userdata/piclastname").toString());
|
|
|
|
+ ui->picfirstnameLineEdit->setText(settings.value("userdata/picfirstname").toString());
|
|
|
|
+ ui->employeeidLineEdit->setText(settings.value("userdata/employeeid").toString());
|
|
|
|
+ ui->phoneLineEdit->setText(settings.value("userdata/phone").toString());
|
|
|
|
+ ui->emailLineEdit->setText(settings.value("userdata/email").toString());
|
|
|
|
+ /*
|
|
|
|
+ * Flight Logging Tab
|
|
|
|
+ */
|
|
|
|
+ ui->aliasComboBox->setCurrentIndex(settings.value("userdata/displayselfas").toInt());
|
|
|
|
+ ui->functionComboBox->setCurrentText(settings.value("flightlogging/function").toString());
|
|
|
|
+ ui->rulesComboBox->setCurrentText(settings.value("flightlogging/rules").toString());
|
|
|
|
+ ui->approachComboBox->setCurrentText(settings.value("flightlogging/approach").toString());
|
|
|
|
+ ui->nightComboBox->setCurrentIndex(settings.value("flightlogging/nightlogging").toInt());
|
|
|
|
+ ui->prefixLineEdit->setText(settings.value("flightlogging/flightnumberPrefix").toString());
|
|
|
|
+ /*
|
|
|
|
+ * Theme Group
|
|
|
|
+ */
|
|
switch (settings.value("main/theme").toInt()) {
|
|
switch (settings.value("main/theme").toInt()) {
|
|
case 0:
|
|
case 0:
|
|
ui->systemThemeCheckBox->setChecked(true);
|
|
ui->systemThemeCheckBox->setChecked(true);
|
|
@@ -50,39 +82,131 @@ SettingsWidget::SettingsWidget(QWidget *parent) :
|
|
ui->darkThemeCheckBox->setChecked(true);
|
|
ui->darkThemeCheckBox->setChecked(true);
|
|
}
|
|
}
|
|
/*
|
|
/*
|
|
- * Flight Logging Tab
|
|
|
|
|
|
+ * Aircraft Tab
|
|
*/
|
|
*/
|
|
- //QString storedPrefix = db::singleSelect("setting","settings","setting_id","50",sql::exactMatch);
|
|
|
|
- QString storedPrefix = settings.value("flightlogging/flightnumberPrefix").toString();
|
|
|
|
- if (storedPrefix.length() != 0) {
|
|
|
|
- ui->flightNumberPrefixLineEdit->setText(storedPrefix);
|
|
|
|
- }
|
|
|
|
|
|
+ ui->acSortComboBox->setCurrentIndex(settings.value("userdata/acSortColumn").toInt());
|
|
|
|
+ ui->pilotSortComboBox->setCurrentIndex(settings.value("userdata/pilSortColumn").toInt());
|
|
|
|
+ ui->acAllowIncompleteComboBox->setCurrentIndex(settings.value("userdata/acAllowIncomplete").toInt());
|
|
|
|
+}
|
|
|
|
|
|
|
|
+void SettingsWidget::setupValidators()
|
|
|
|
+{
|
|
QRegExp flightNumberPrefix_rx("[a-zA-Z0-9]?[a-zA-Z0-9]?[a-zA-Z0-9]"); // allow max 3 letters (upper and lower) and numbers
|
|
QRegExp flightNumberPrefix_rx("[a-zA-Z0-9]?[a-zA-Z0-9]?[a-zA-Z0-9]"); // allow max 3 letters (upper and lower) and numbers
|
|
QValidator *flightNumberPrefixValidator = new QRegExpValidator(flightNumberPrefix_rx, this);
|
|
QValidator *flightNumberPrefixValidator = new QRegExpValidator(flightNumberPrefix_rx, this);
|
|
- ui->flightNumberPrefixLineEdit->setValidator(flightNumberPrefixValidator);
|
|
|
|
- /*
|
|
|
|
- * Aircraft Tab
|
|
|
|
- */
|
|
|
|
- ui->acSortComboBox->setCurrentIndex(settings.value("userdata/acSortColumn").toInt());
|
|
|
|
|
|
+ ui->prefixLineEdit->setValidator(flightNumberPrefixValidator);
|
|
|
|
+}
|
|
|
|
|
|
|
|
+/*
|
|
|
|
+ * Slots
|
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+/*
|
|
|
|
+ * Personal Tab
|
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+void SettingsWidget::on_piclastnameLineEdit_editingFinished()
|
|
|
|
+{
|
|
|
|
+ QSettings settings;
|
|
|
|
+ if(ui->piclastnameLineEdit->text().isEmpty()){
|
|
|
|
+ ui->piclastnameLineEdit->setText(settings.value("userdata/piclastname").toString());
|
|
|
|
+ ui->piclastnameLineEdit->setFocus();
|
|
|
|
+ } else {
|
|
|
|
+ settings.setValue("userdata/piclastname",ui->piclastnameLineEdit->text());
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
-SettingsWidget::~SettingsWidget()
|
|
|
|
|
|
+void SettingsWidget::on_picfirstnameLineEdit_editingFinished()
|
|
{
|
|
{
|
|
- delete ui;
|
|
|
|
|
|
+ QSettings settings;
|
|
|
|
+ if(ui->picfirstnameLineEdit->text().isEmpty()){
|
|
|
|
+ ui->picfirstnameLineEdit->setText(settings.value("userdata/picfirstname").toString());
|
|
|
|
+ ui->picfirstnameLineEdit->setFocus();
|
|
|
|
+ } else {
|
|
|
|
+ settings.setValue("userdata/picfirstname",ui->picfirstnameLineEdit->text());
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void SettingsWidget::on_employeeidLineEdit_editingFinished()
|
|
|
|
+{
|
|
|
|
+ QSettings settings;
|
|
|
|
+ settings.setValue("userdata/employeeid",ui->employeeidLineEdit->text());
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void SettingsWidget::on_emailLineEdit_editingFinished()
|
|
|
|
+{
|
|
|
|
+ QSettings settings;
|
|
|
|
+ settings.setValue("userdata/email",ui->emailLineEdit->text());
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void SettingsWidget::on_phoneLineEdit_editingFinished()
|
|
|
|
+{
|
|
|
|
+ QSettings settings;
|
|
|
|
+ settings.setValue("userdata/phone",ui->phoneLineEdit->text());
|
|
}
|
|
}
|
|
|
|
|
|
/*
|
|
/*
|
|
- * Slots
|
|
|
|
|
|
+ * Flight Logging Tab
|
|
*/
|
|
*/
|
|
|
|
|
|
-void SettingsWidget::on_flightNumberPrefixLineEdit_textEdited(const QString &arg1)
|
|
|
|
|
|
+void SettingsWidget::on_aliasComboBox_currentIndexChanged(int index)
|
|
|
|
+{
|
|
|
|
+ QSettings settings;
|
|
|
|
+ settings.setValue("userdata/displayselfas",index);
|
|
|
|
+ /*QSettings settings;
|
|
|
|
+ switch (index) {
|
|
|
|
+ case 0:
|
|
|
|
+ settings.setValue("userdata/displayselfas","self");
|
|
|
|
+ break;
|
|
|
|
+ case 1:
|
|
|
|
+ settings.setValue("userdata/displayselfas","SELF");
|
|
|
|
+ break;
|
|
|
|
+ default:
|
|
|
|
+ settings.setValue("userdata/displayselfas","Last,F.");
|
|
|
|
+ }*/
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void SettingsWidget::on_functionComboBox_currentIndexChanged(const QString &arg1)
|
|
|
|
+{
|
|
|
|
+ QSettings settings;
|
|
|
|
+ settings.setValue("flightlogging/function", arg1);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void SettingsWidget::on_rulesComboBox_currentIndexChanged(const QString &arg1)
|
|
|
|
+{
|
|
|
|
+ QSettings settings;
|
|
|
|
+ settings.setValue("flightlogging/rules", arg1);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void SettingsWidget::on_approachComboBox_currentIndexChanged(const QString &arg1)
|
|
|
|
+{
|
|
|
|
+ QSettings settings;
|
|
|
|
+ settings.setValue("flightlogging/approach", arg1);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void SettingsWidget::on_nightComboBox_currentIndexChanged(int index)
|
|
|
|
+{
|
|
|
|
+ if(index == 2){
|
|
|
|
+ auto mb = new QMessageBox(this);
|
|
|
|
+ mb->setText("This option is not yet available.");
|
|
|
|
+ mb->show();
|
|
|
|
+ ui->nightComboBox->setCurrentIndex(0);
|
|
|
|
+ } else {
|
|
|
|
+ QSettings settings;
|
|
|
|
+ settings.setValue("flightlogging/nightlogging", index);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void SettingsWidget::on_prefixLineEdit_textChanged(const QString &arg1)
|
|
{
|
|
{
|
|
QSettings settings;
|
|
QSettings settings;
|
|
settings.setValue("flightlogging/flightnumberPrefix", arg1);
|
|
settings.setValue("flightlogging/flightnumberPrefix", arg1);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+/*
|
|
|
|
+ * Misc Tab
|
|
|
|
+ */
|
|
void SettingsWidget::themeGroup_toggled(int id)
|
|
void SettingsWidget::themeGroup_toggled(int id)
|
|
{
|
|
{
|
|
QSettings settings;
|
|
QSettings settings;
|
|
@@ -104,6 +228,46 @@ void SettingsWidget::themeGroup_toggled(int id)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+void SettingsWidget::on_pilotSortComboBox_currentIndexChanged(int index)
|
|
|
|
+{
|
|
|
|
+ QSettings settings;
|
|
|
|
+ settings.setValue("userdata/pilSortColumn", index);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void SettingsWidget::on_acSortComboBox_currentIndexChanged(int index)
|
|
|
|
+{
|
|
|
|
+ QSettings settings;
|
|
|
|
+ settings.setValue("userdata/acSortColumn", index);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void SettingsWidget::on_acAllowIncompleteComboBox_currentIndexChanged(int index)
|
|
|
|
+{
|
|
|
|
+ QSettings settings;
|
|
|
|
+ settings.setValue("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) {
|
|
|
|
+ QSettings settings;
|
|
|
|
+ settings.setValue("userdata/acAllowIncomplete", index);
|
|
|
|
+ } else {
|
|
|
|
+ ui->acAllowIncompleteComboBox->setCurrentIndex(0);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/*
|
|
|
|
+ * About Tab
|
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+
|
|
void SettingsWidget::on_aboutPushButton_clicked()
|
|
void SettingsWidget::on_aboutPushButton_clicked()
|
|
{
|
|
{
|
|
auto mb = new QMessageBox(this);
|
|
auto mb = new QMessageBox(this);
|
|
@@ -142,32 +306,3 @@ void SettingsWidget::on_aboutPushButton_clicked()
|
|
mb->setText(text);
|
|
mb->setText(text);
|
|
mb->open();
|
|
mb->open();
|
|
}
|
|
}
|
|
-
|
|
|
|
-void SettingsWidget::on_acSortComboBox_currentIndexChanged(int index)
|
|
|
|
-{
|
|
|
|
- QSettings settings;
|
|
|
|
- settings.setValue("userdata/acSortColumn", index);
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-void SettingsWidget::on_acAllowIncompleteComboBox_currentIndexChanged(int index)
|
|
|
|
-{
|
|
|
|
- QSettings settings;
|
|
|
|
- settings.setValue("userdata/acAllowIncomplete", index);
|
|
|
|
- if (index) {
|
|
|
|
- QMessageBox::StandardButton reply;
|
|
|
|
- reply = QMessageBox::question(this, "Warning",
|
|
|
|
- "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.\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) {
|
|
|
|
- QSettings settings;
|
|
|
|
- settings.setValue("userdata/acAllowIncomplete", index);
|
|
|
|
- } else {
|
|
|
|
- ui->acAllowIncompleteComboBox->setCurrentIndex(0);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-}
|
|
|