settingswidget.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. /*
  2. *openPilotLog - A FOSS Pilot Logbook Application
  3. *Copyright (C) 2020-2021 Felix Turowsky
  4. *
  5. *This program is free software: you can redistribute it and/or modify
  6. *it under the terms of the GNU General Public License as published by
  7. *the Free Software Foundation, either version 3 of the License, or
  8. *(at your option) any later version.
  9. *
  10. *This program is distributed in the hope that it will be useful,
  11. *but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. *GNU General Public License for more details.
  14. *
  15. *You should have received a copy of the GNU General Public License
  16. *along with this program. If not, see <https://www.gnu.org/licenses/>.
  17. */
  18. #ifndef SETTINGSWIDGET_H
  19. #define SETTINGSWIDGET_H
  20. #include <QWidget>
  21. #include <QButtonGroup>
  22. #include <QValidator>
  23. #include <QProcess>
  24. #include <QDebug>
  25. #include <QFontDialog>
  26. namespace Ui {
  27. class SettingsWidget;
  28. }
  29. /*!
  30. * \brief The SettingsWidget is used to to display and alter Settings.
  31. *
  32. * \details Most Inputs are collected and processed in various slots and
  33. * written to the settings file via the ASettings class. In the `Personal` Settings
  34. * tab, the user can edit his personal details, which are then written to the Database
  35. * (The Logbook owner is registered in the Pilots Database with `pilot_id = 1`).
  36. */
  37. class SettingsWidget : public QWidget
  38. {
  39. Q_OBJECT
  40. public:
  41. explicit SettingsWidget(QWidget *parent = nullptr);
  42. ~SettingsWidget();
  43. /*!
  44. * \brief enumerates Widgets that need to receive a signal when a setting is updated.
  45. */
  46. enum SettingSignal {LogbookWidget, HomeWidget, AircraftWidget, PilotsWidget};
  47. private slots:
  48. void on_aboutPushButton_clicked();
  49. void on_acftSortComboBox_currentIndexChanged(int index);
  50. void on_acAllowIncompleteComboBox_currentIndexChanged(int index);
  51. void on_prefixLineEdit_textChanged(const QString &arg1);
  52. void on_lastnameLineEdit_editingFinished();
  53. void on_firstnameLineEdit_editingFinished();
  54. void on_employeeidLineEdit_editingFinished();
  55. void on_emailLineEdit_editingFinished();
  56. void on_phoneLineEdit_editingFinished();
  57. void on_aliasComboBox_currentIndexChanged(int index);
  58. void on_functionComboBox_currentIndexChanged(const QString &arg1);
  59. void on_rulesComboBox_currentIndexChanged(const QString &arg1);
  60. void on_approachComboBox_currentIndexChanged(const QString &arg1);
  61. void on_nightComboBox_currentIndexChanged(int index);
  62. void on_pilotSortComboBox_currentIndexChanged(int index);
  63. void on_logbookViewComboBox_currentIndexChanged(int index);
  64. void on_companyLineEdit_editingFinished();
  65. void on_styleComboBox_currentTextChanged(const QString& new_style_setting);
  66. void on_fontComboBox_currentFontChanged(const QFont &f);
  67. void on_fontSpinBox_valueChanged(int arg1);
  68. void on_fontCheckBox_stateChanged(int arg1);
  69. void on_resetStylePushButton_clicked();
  70. void on_currLicDateEdit_userDateChanged(const QDate &date);
  71. void on_currTrDateEdit_userDateChanged(const QDate &date);
  72. void on_currLckDateEdit_userDateChanged(const QDate &date);
  73. void on_currMedDateEdit_userDateChanged(const QDate &date);
  74. void on_currCustom1DateEdit_userDateChanged(const QDate &date);
  75. void on_currCustom2DateEdit_userDateChanged(const QDate &date);
  76. void on_currToLdgCheckBox_stateChanged(int arg1);
  77. void on_currLicCheckBox_stateChanged(int arg1);
  78. void on_currTrCheckBox_stateChanged(int arg1);
  79. void on_currLckCheckBox_stateChanged(int arg1);
  80. void on_currMedCheckBox_stateChanged(int arg1);
  81. void on_currCustom1CheckBox_stateChanged(int arg1);
  82. void on_currCustom2CheckBox_stateChanged(int arg1);
  83. void on_currWarningCheckBox_stateChanged(int arg1);
  84. void on_currWarningThresholdSpinBox_valueChanged(int arg1);
  85. void on_currCustom1LineEdit_editingFinished();
  86. void on_currCustom2LineEdit_editingFinished();
  87. void on_dateFormatComboBox_currentIndexChanged(int index);
  88. void on_languageComboBox_activated(const QString &arg1);
  89. private:
  90. Ui::SettingsWidget *ui;
  91. void readSettings();
  92. void setupValidators();
  93. void setupComboBoxes();
  94. void setupDateEdits();
  95. void updatePersonalDetails();
  96. bool usingStylesheet();
  97. signals:
  98. /*!
  99. * \brief settingChanged is emitted when a setting change occurs that needs to trigger
  100. * an update (repaint) to another widget.
  101. */
  102. void settingChanged(SettingSignal widget);
  103. };
  104. #endif // SETTINGSWIDGET_H