settingswidget.cpp 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600
  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. #include "settingswidget.h"
  19. #include "ui_settingswidget.h"
  20. #include "src/testing/adebug.h"
  21. #include "src/classes/astyle.h"
  22. #include "src/classes/asettings.h"
  23. #include "src/database/adatabase.h"
  24. #include "src/classes/apilotentry.h"
  25. #include "src/oplconstants.h"
  26. static const auto FIRSTNAME_VALID = QPair<QString, QRegularExpression> {
  27. QStringLiteral("firstnameLineEdit"), QRegularExpression("[a-zA-Z]+")};
  28. static const auto LASTNAME_VALID = QPair<QString, QRegularExpression> {
  29. QStringLiteral("lastnameLineEdit"), QRegularExpression("\\w+")};
  30. static const auto PHONE_VALID = QPair<QString, QRegularExpression> {
  31. QStringLiteral("phoneLineEdit"), QRegularExpression("^[+]{0,1}[0-9\\-\\s]+")};
  32. static const auto EMAIL_VALID = QPair<QString, QRegularExpression> {
  33. QStringLiteral("emailLineEdit"), QRegularExpression("\\A[a-z0-9!#$%&'*+/=?^_‘{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_‘{|}~-]+)*@"
  34. "(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\z")};
  35. static const auto COMPANY_VALID = QPair<QString, QRegularExpression> {
  36. QStringLiteral("companyLineEdit"), QRegularExpression("\\w+")};
  37. static const auto EMPLOYEENR_VALID = QPair<QString, QRegularExpression> {
  38. QStringLiteral("employeeidLineEdit"), QRegularExpression("\\w+")};
  39. static const auto PREFIX_VALID = QPair<QString, QRegularExpression> {
  40. QStringLiteral("prefixLineEdit"), QRegularExpression("[a-zA-Z0-9]?[a-zA-Z0-9]?[a-zA-Z0-9]")};
  41. static const auto LINE_EDIT_VALIDATORS = QVector<QPair<QString, QRegularExpression>>{
  42. FIRSTNAME_VALID, LASTNAME_VALID, PHONE_VALID, EMAIL_VALID,
  43. COMPANY_VALID, EMPLOYEENR_VALID, PREFIX_VALID};
  44. SettingsWidget::SettingsWidget(QWidget *parent) :
  45. QWidget(parent),
  46. ui(new Ui::SettingsWidget)
  47. {
  48. ui->setupUi(this);
  49. ui->tabWidget->setCurrentIndex(0);
  50. setupComboBoxes();
  51. setupValidators();
  52. readSettings();
  53. }
  54. SettingsWidget::~SettingsWidget()
  55. {
  56. delete ui;
  57. }
  58. void SettingsWidget::setupComboBoxes(){
  59. {
  60. // Style combo box
  61. const QSignalBlocker blocker_style(ui->styleComboBox);
  62. ui->styleComboBox->addItems(AStyle::styles);
  63. for (const auto &style_sheet : AStyle::styleSheets) {
  64. ui->styleComboBox->addItem(style_sheet.styleSheetName);
  65. }
  66. ui->styleComboBox->addItem(QStringLiteral("Dark-Palette"));
  67. ui->styleComboBox->model()->sort(0);
  68. // Approach Combo Box
  69. const QSignalBlocker blocker_approach(ui->approachComboBox);
  70. for (const auto &approach : Opl::ApproachTypes) {
  71. ui->approachComboBox->addItem(approach);
  72. }
  73. }
  74. }
  75. void SettingsWidget::readSettings()
  76. {
  77. /*
  78. * Personal Tab
  79. */
  80. {
  81. const QSignalBlocker blocker(this); // don't emit editing finished for setting these values
  82. auto user_data = aDB->getPilotEntry(1).getData();
  83. ui->lastnameLineEdit->setText(user_data.value(Opl::Db::PILOTS_LASTNAME).toString());
  84. ui->firstnameLineEdit->setText(user_data.value(Opl::Db::PILOTS_FIRSTNAME).toString());
  85. ui->companyLineEdit->setText(user_data.value(Opl::Db::PILOTS_COMPANY).toString());
  86. ui->employeeidLineEdit->setText(user_data.value(Opl::Db::PILOTS_EMPLOYEEID).toString());
  87. ui->phoneLineEdit->setText(user_data.value(Opl::Db::PILOTS_PHONE).toString());
  88. ui->emailLineEdit->setText(user_data.value(Opl::Db::PILOTS_EMAIL).toString());
  89. }
  90. /*
  91. * Flight Logging Tab
  92. */
  93. ui->aliasComboBox->setCurrentIndex(ASettings::read(ASettings::UserData::DisplaySelfAs).toInt());
  94. ui->functionComboBox->setCurrentText(ASettings::read(ASettings::FlightLogging::Function).toString());
  95. ui->rulesComboBox->setCurrentText(ASettings::read(ASettings::FlightLogging::Rules).toString());
  96. ui->approachComboBox->setCurrentText(ASettings::read(ASettings::FlightLogging::Approach).toString());
  97. ui->nightComboBox->setCurrentIndex(ASettings::read(ASettings::FlightLogging::NightLogging).toInt());
  98. ui->prefixLineEdit->setText(ASettings::read(ASettings::FlightLogging::FlightNumberPrefix).toString());
  99. ui->logbookViewComboBox->setCurrentIndex(ASettings::read(ASettings::Main::LogbookView).toInt());
  100. /*
  101. * Currencies Tab
  102. */
  103. ui->currToLdgCheckBox->setChecked(ASettings::read(ASettings::UserData::ShowToLgdCurrency).toBool());
  104. ui->currLicDateEdit->setDate(ASettings::read(ASettings::UserData::LicCurrencyDate).toDate());
  105. ui->currLicCheckBox->setChecked(ASettings::read(ASettings::UserData::ShowLicCurrency).toBool());
  106. ui->currTrDateEdit->setDate(ASettings::read(ASettings::UserData::TrCurrencyDate).toDate());
  107. ui->currTrCheckBox->setChecked(ASettings::read(ASettings::UserData::ShowTrCurrency).toBool());
  108. ui->currLckDateEdit->setDate(ASettings::read(ASettings::UserData::LckCurrencyDate).toDate());
  109. ui->currLckCheckBox->setChecked(ASettings::read(ASettings::UserData::ShowLckCurrency).toBool());
  110. ui->currMedDateEdit->setDate(ASettings::read(ASettings::UserData::MedCurrencyDate).toDate());
  111. ui->currMedCheckBox->setChecked(ASettings::read(ASettings::UserData::ShowMedCurrency).toBool());
  112. ui->currCustom1DateEdit->setDate(ASettings::read(ASettings::UserData::Custom1CurrencyDate).toDate());
  113. ui->currCustom1CheckBox->setChecked(ASettings::read(ASettings::UserData::ShowCustom1Currency).toBool());
  114. ui->currCustom2DateEdit->setDate(ASettings::read(ASettings::UserData::Custom2CurrencyDate).toDate());
  115. ui->currCustom2CheckBox->setChecked(ASettings::read(ASettings::UserData::ShowCustom2Currency).toBool());
  116. /*
  117. * Misc Tab
  118. */
  119. ui->acSortComboBox->setCurrentIndex(ASettings::read(ASettings::UserData::TailSortColumn).toInt());
  120. ui->pilotSortComboBox->setCurrentIndex(ASettings::read(ASettings::UserData::PilotSortColumn).toInt());
  121. ui->acAllowIncompleteComboBox->setCurrentIndex(ASettings::read(ASettings::UserData::AcftAllowIncomplete).toInt());
  122. ui->styleComboBox->setCurrentText(ASettings::read(ASettings::Main::Style).toString());
  123. {
  124. const QSignalBlocker font_blocker1(ui->fontSpinBox);
  125. const QSignalBlocker font_blocker2(ui->fontComboBox);
  126. const QSignalBlocker font_blocker3(ui->fontCheckBox);
  127. ui->fontSpinBox->setValue(ASettings::read(ASettings::Main::FontSize).toUInt());
  128. ui->fontComboBox->setCurrentFont(QFont(ASettings::read(ASettings::Main::Font).toString()));
  129. ui->fontCheckBox->setChecked(ASettings::read(ASettings::Main::UseSystemFont).toBool());
  130. }
  131. }
  132. void SettingsWidget::setupValidators()
  133. {
  134. DEB << "Setting up Validators...";
  135. for(const auto& pair : LINE_EDIT_VALIDATORS){
  136. auto line_edit = parent()->findChild<QLineEdit*>(pair.first);
  137. if(line_edit != nullptr){
  138. auto validator = new QRegularExpressionValidator(pair.second,line_edit);
  139. line_edit->setValidator(validator);
  140. }else{
  141. DEB << "Error: Line Edit not found: "<< pair.first << " - skipping.";
  142. }
  143. }
  144. }
  145. void SettingsWidget::updatePersonalDetails()
  146. {
  147. RowData_T user_data;
  148. switch (ui->aliasComboBox->currentIndex()) {
  149. case 0:
  150. user_data.insert(Opl::Db::PILOTS_ALIAS, QStringLiteral("self"));
  151. break;
  152. case 1:
  153. user_data.insert(Opl::Db::PILOTS_ALIAS, QStringLiteral("SELF"));
  154. break;
  155. case 2:{
  156. QString name;
  157. name.append(ui->lastnameLineEdit->text());
  158. name.append(QLatin1String(", "));
  159. name.append(ui->firstnameLineEdit->text().left(1));
  160. name.append(QLatin1Char('.'));
  161. user_data.insert(Opl::Db::PILOTS_ALIAS, name);
  162. }
  163. break;
  164. default:
  165. break;
  166. }
  167. user_data.insert(Opl::Db::PILOTS_LASTNAME, ui->lastnameLineEdit->text());
  168. user_data.insert(Opl::Db::PILOTS_FIRSTNAME, ui->firstnameLineEdit->text());
  169. user_data.insert(Opl::Db::PILOTS_COMPANY, ui->companyLineEdit->text());
  170. user_data.insert(Opl::Db::PILOTS_EMPLOYEEID, ui->employeeidLineEdit->text());
  171. user_data.insert(Opl::Db::PILOTS_PHONE, ui->phoneLineEdit->text());
  172. user_data.insert(Opl::Db::PILOTS_EMAIL, ui->emailLineEdit->text());
  173. auto user = APilotEntry(1);
  174. user.setData(user_data);
  175. aDB->commit(user);
  176. }
  177. /*
  178. * Slots
  179. */
  180. /*
  181. * Personal Tab
  182. */
  183. void SettingsWidget::on_lastnameLineEdit_editingFinished()
  184. {
  185. updatePersonalDetails();
  186. }
  187. void SettingsWidget::on_firstnameLineEdit_editingFinished()
  188. {
  189. updatePersonalDetails();
  190. }
  191. void SettingsWidget::on_companyLineEdit_editingFinished()
  192. {
  193. updatePersonalDetails();
  194. }
  195. void SettingsWidget::on_employeeidLineEdit_editingFinished()
  196. {
  197. updatePersonalDetails();
  198. }
  199. void SettingsWidget::on_emailLineEdit_editingFinished()
  200. {
  201. updatePersonalDetails();
  202. }
  203. void SettingsWidget::on_phoneLineEdit_editingFinished()
  204. {
  205. updatePersonalDetails();
  206. }
  207. /*
  208. * Flight Logging Tab
  209. */
  210. void SettingsWidget::on_aliasComboBox_currentIndexChanged(int index)
  211. {
  212. ASettings::write(ASettings::UserData::DisplaySelfAs, index);
  213. updatePersonalDetails();
  214. }
  215. void SettingsWidget::on_functionComboBox_currentIndexChanged(const QString &arg1)
  216. {
  217. ASettings::write(ASettings::FlightLogging::Function, arg1);
  218. }
  219. void SettingsWidget::on_rulesComboBox_currentIndexChanged(const QString &arg1)
  220. {
  221. ASettings::write(ASettings::FlightLogging::Rules, arg1);
  222. }
  223. void SettingsWidget::on_approachComboBox_currentIndexChanged(const QString &arg1)
  224. {
  225. ASettings::write(ASettings::FlightLogging::Approach, arg1);
  226. }
  227. void SettingsWidget::on_nightComboBox_currentIndexChanged(int index)
  228. {
  229. ASettings::write(ASettings::FlightLogging::NightLogging, index);
  230. switch (index) {
  231. case 1:
  232. ASettings::write(ASettings::FlightLogging::NightAngle, -6);
  233. break;
  234. case 2:
  235. ASettings::write(ASettings::FlightLogging::NightAngle, 0);
  236. break;
  237. default:
  238. ASettings::write(ASettings::FlightLogging::NightAngle, -6);
  239. }
  240. }
  241. void SettingsWidget::on_prefixLineEdit_textChanged(const QString &arg1)
  242. {
  243. ASettings::write(ASettings::FlightLogging::FlightNumberPrefix, arg1);
  244. }
  245. /*
  246. * Misc Tab
  247. */
  248. void SettingsWidget::on_logbookViewComboBox_currentIndexChanged(int index)
  249. {
  250. ASettings::write(ASettings::Main::LogbookView, index);
  251. emit viewSelectionChanged(index);
  252. }
  253. void SettingsWidget::on_pilotSortComboBox_currentIndexChanged(int index)
  254. {
  255. ASettings::write(ASettings::UserData::PilotSortColumn, index);
  256. }
  257. void SettingsWidget::on_acSortComboBox_currentIndexChanged(int index)
  258. {
  259. ASettings::write(ASettings::UserData::TailSortColumn, index);
  260. }
  261. void SettingsWidget::on_acAllowIncompleteComboBox_currentIndexChanged(int index)
  262. {
  263. ASettings::write(ASettings::UserData::AcftAllowIncomplete, index);
  264. if (index) {
  265. QMessageBox::StandardButton reply;
  266. reply = QMessageBox::warning(this, tr("Warning"),
  267. tr("Enabling incomplete logging will enable you to add aircraft with incomplete data.<br><br>"
  268. "If you do not fill out the aircraft details, "
  269. "it will be impossible to automatically determine Single/Multi Pilot Times or Single/Multi Engine Time. "
  270. "This will also impact statistics and auto-logging capabilites as well as jeopardise database integrity.<br><br>"
  271. "It is highly recommended to keep this option off unless you have a specific reason not to.<br><br>"
  272. "Are you sure you want to proceed?"),
  273. QMessageBox::Yes | QMessageBox::No);
  274. if (reply == QMessageBox::Yes) {
  275. ASettings::write(ASettings::UserData::AcftAllowIncomplete, index);
  276. } else {
  277. ui->acAllowIncompleteComboBox->setCurrentIndex(0);
  278. }
  279. }
  280. }
  281. /*
  282. * About Tab
  283. */
  284. void SettingsWidget::on_aboutPushButton_clicked()
  285. {
  286. QMessageBox message_box(this);
  287. QString SQLITE_VERSION = aDB->sqliteVersion();
  288. QString text = QMessageBox::tr(
  289. "<h3><center>About openPilotLog</center></h3>"
  290. "<br>"
  291. "(c) 2020-2021 Felix Turowsky"
  292. "<br>"
  293. "<p>This is a collaboratively developed Free and Open Source Application. "
  294. "Visit us <a href=\"https://%1/\">here</a> for more information.</p>"
  295. "<p>This program is free software: you can redistribute it and/or modify "
  296. "it under the terms of the GNU General Public License as published by "
  297. "the Free Software Foundation, either version 3 of the License, or "
  298. "(at your option) any later version.</p>"
  299. "<p>This program is distributed in the hope that it will be useful, "
  300. "but WITHOUT ANY WARRANTY; without even the implied warranty of "
  301. "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the "
  302. "GNU General Public License for more details.</p> "
  303. "<p>You should have received a copy of the GNU General Public License "
  304. "along with this program. If not, "
  305. "please click <a href=\"https://%2\">here</a>.</p>"
  306. "<br>"
  307. "<p>This program uses <a href=\"http://%3/\">Qt</a> version %4 and "
  308. "<a href=\"https://%5/\">SQLite</a> version %6</p>"
  309. ).arg(QStringLiteral("github.com/fiffty-50/openpilotlog"),
  310. QStringLiteral("gnu.org/licenses/"),
  311. QStringLiteral("qt.io"),
  312. QT_VERSION_STR,
  313. QStringLiteral("sqlite.org/about.html"),
  314. SQLITE_VERSION);
  315. message_box.setText(text);
  316. message_box.exec();
  317. }
  318. void SettingsWidget::on_styleComboBox_currentTextChanged(const QString& new_style_setting)
  319. {
  320. if (new_style_setting == QLatin1String("Dark-Palette")) {
  321. AStyle::setStyle(AStyle::darkPalette());
  322. return;
  323. }
  324. for (const auto &style_name : AStyle::styles) {
  325. if (new_style_setting == style_name) {
  326. AStyle::setStyle(style_name);
  327. ASettings::write(ASettings::Main::Style, new_style_setting);
  328. return;
  329. }
  330. }
  331. for (const auto &style_sheet : AStyle::styleSheets) {
  332. if (new_style_setting == style_sheet.styleSheetName) {
  333. AStyle::setStyle(style_sheet);
  334. ASettings::write(ASettings::Main::Style, new_style_setting);
  335. return;
  336. }
  337. }
  338. }
  339. void SettingsWidget::on_fontComboBox_currentFontChanged(const QFont &f)
  340. {
  341. qApp->setFont(f);
  342. ASettings::write(ASettings::Main::Font, f.toString());
  343. DEB << "Setting Font:" << f.toString();
  344. }
  345. void SettingsWidget::on_fontSpinBox_valueChanged(int arg1)
  346. {
  347. QFont f = qApp->font();
  348. f.setPointSize(arg1);
  349. qApp->setFont(f);
  350. ASettings::write(ASettings::Main::FontSize, arg1);
  351. DEB << "Setting Font:" << f.toString();
  352. }
  353. void SettingsWidget::on_fontCheckBox_stateChanged(int arg1)
  354. {
  355. if (usingStylesheet() && arg1 == Qt::Unchecked) {
  356. QMessageBox message_box(this);
  357. message_box.setText(tr("The style you have currently selected may not be fully compatible "
  358. "with changing to a custom font while the application is running.<br><br>"
  359. "Applying your changes may require restarting the application.<br>"));
  360. message_box.exec();
  361. }
  362. switch (arg1) {
  363. case Qt::Unchecked:
  364. {
  365. ui->fontComboBox->setEnabled(true);
  366. ui->fontSpinBox->setEnabled(true);
  367. ASettings::write(ASettings::Main::UseSystemFont, false);
  368. QFont font(ui->fontComboBox->currentFont());
  369. font.setPointSize(ui->fontSpinBox->value());
  370. qApp->setFont(font);
  371. DEB << "Setting Font:" << font.toString();
  372. break;
  373. }
  374. case Qt::Checked:
  375. {
  376. ui->fontComboBox->setEnabled(false);
  377. ui->fontSpinBox->setEnabled(false);
  378. ASettings::write(ASettings::Main::UseSystemFont, true);
  379. QMessageBox message_box(this);
  380. message_box.setText(tr("The application will be restarted for this change to take effect."));
  381. message_box.exec();
  382. qApp->quit();
  383. QProcess::startDetached(qApp->arguments()[0], qApp->arguments());
  384. }
  385. break;
  386. default:
  387. break;
  388. }
  389. }
  390. /*!
  391. * \brief Determines if the user has selected a stylesheet or is using a Qt Style Factory Style
  392. */
  393. bool SettingsWidget::usingStylesheet()
  394. {
  395. for (const auto &style_sheet : AStyle::styleSheets) {
  396. if (style_sheet.styleSheetName == ui->styleComboBox->currentText())
  397. return true;
  398. }
  399. return false;
  400. }
  401. void SettingsWidget::on_resetStylePushButton_clicked()
  402. {
  403. DEB << "Resetting style to default...";
  404. ui->styleComboBox->setCurrentText(AStyle::defaultStyle);
  405. ui->fontCheckBox->setChecked(true);
  406. }
  407. void SettingsWidget::on_currLicDateEdit_userDateChanged(const QDate &date)
  408. {
  409. ASettings::write(ASettings::UserData::LicCurrencyDate, date);
  410. }
  411. void SettingsWidget::on_currTrDateEdit_userDateChanged(const QDate &date)
  412. {
  413. ASettings::write(ASettings::UserData::TrCurrencyDate, date);
  414. }
  415. void SettingsWidget::on_currLckDateEdit_userDateChanged(const QDate &date)
  416. {
  417. ASettings::write(ASettings::UserData::LckCurrencyDate, date);
  418. }
  419. void SettingsWidget::on_currMedDateEdit_userDateChanged(const QDate &date)
  420. {
  421. ASettings::write(ASettings::UserData::MedCurrencyDate, date);
  422. }
  423. void SettingsWidget::on_currCustom1DateEdit_userDateChanged(const QDate &date)
  424. {
  425. ASettings::write(ASettings::UserData::Custom1CurrencyDate, date);
  426. }
  427. void SettingsWidget::on_currCustom2DateEdit_userDateChanged(const QDate &date)
  428. {
  429. ASettings::write(ASettings::UserData::Custom2CurrencyDate, date);
  430. }
  431. void SettingsWidget::on_currToLdgCheckBox_stateChanged(int arg1)
  432. {
  433. switch (arg1) {
  434. case Qt::CheckState::Checked:
  435. ASettings::write(ASettings::UserData::ShowToLgdCurrency, true);
  436. break;
  437. case Qt::CheckState::Unchecked:
  438. ASettings::write(ASettings::UserData::ShowToLgdCurrency, false);
  439. break;
  440. default:
  441. break;
  442. }
  443. }
  444. void SettingsWidget::on_currLicCheckBox_stateChanged(int arg1)
  445. {
  446. switch (arg1) {
  447. case Qt::CheckState::Checked:
  448. ASettings::write(ASettings::UserData::ShowLicCurrency, true);
  449. break;
  450. case Qt::CheckState::Unchecked:
  451. ASettings::write(ASettings::UserData::ShowLicCurrency, false);
  452. break;
  453. default:
  454. break;
  455. }
  456. ASettings::write(ASettings::UserData::LicCurrencyDate, ui->currLicDateEdit->date());
  457. }
  458. void SettingsWidget::on_currTrCheckBox_stateChanged(int arg1)
  459. {
  460. switch (arg1) {
  461. case Qt::CheckState::Checked:
  462. ASettings::write(ASettings::UserData::ShowTrCurrency, true);
  463. break;
  464. case Qt::CheckState::Unchecked:
  465. ASettings::write(ASettings::UserData::ShowTrCurrency, false);
  466. break;
  467. default:
  468. break;
  469. }
  470. ASettings::write(ASettings::UserData::TrCurrencyDate, ui->currTrDateEdit->date());
  471. }
  472. void SettingsWidget::on_currLckCheckBox_stateChanged(int arg1)
  473. {
  474. switch (arg1) {
  475. case Qt::CheckState::Checked:
  476. ASettings::write(ASettings::UserData::ShowLckCurrency, true);
  477. break;
  478. case Qt::CheckState::Unchecked:
  479. ASettings::write(ASettings::UserData::ShowLckCurrency, false);
  480. break;
  481. default:
  482. break;
  483. }
  484. ASettings::write(ASettings::UserData::LckCurrencyDate, ui->currLckDateEdit->date());
  485. }
  486. void SettingsWidget::on_currMedCheckBox_stateChanged(int arg1)
  487. {
  488. switch (arg1) {
  489. case Qt::CheckState::Checked:
  490. ASettings::write(ASettings::UserData::ShowMedCurrency, true);
  491. break;
  492. case Qt::CheckState::Unchecked:
  493. ASettings::write(ASettings::UserData::ShowMedCurrency, false);
  494. break;
  495. default:
  496. break;
  497. }
  498. ASettings::write(ASettings::UserData::MedCurrencyDate, ui->currMedDateEdit->date());
  499. }
  500. void SettingsWidget::on_currCustom1CheckBox_stateChanged(int arg1)
  501. {
  502. switch (arg1) {
  503. case Qt::CheckState::Checked:
  504. ASettings::write(ASettings::UserData::ShowCustom1Currency, true);
  505. break;
  506. case Qt::CheckState::Unchecked:
  507. ASettings::write(ASettings::UserData::ShowCustom1Currency, false);
  508. break;
  509. default:
  510. break;
  511. }
  512. ASettings::write(ASettings::UserData::Custom1CurrencyDate, ui->currCustom1DateEdit->date());
  513. }
  514. void SettingsWidget::on_currCustom2CheckBox_stateChanged(int arg1)
  515. {
  516. switch (arg1) {
  517. case Qt::CheckState::Checked:
  518. ASettings::write(ASettings::UserData::ShowCustom2Currency, true);
  519. break;
  520. case Qt::CheckState::Unchecked:
  521. ASettings::write(ASettings::UserData::ShowCustom2Currency, false);
  522. break;
  523. default:
  524. break;
  525. }
  526. ASettings::write(ASettings::UserData::Custom2CurrencyDate, ui->currCustom2DateEdit->date());
  527. }