summaryrefslogtreecommitdiff
path: root/src/settings/settingswidget.cpp
blob: 60f2bf6240c3a6d0384589fe5af1343788df95e9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include "settingswidgets.hpp"

#include <QCheckBox>
#include <QFontComboBox>
#include <QKeySequenceEdit>
#include <QLineEdit>
#include <QSpinBox>

void SettingsWidget::save()
{
  if (objectName() != QLatin1String("General")) m_settings->beginGroup(objectName());

  // Int
  for (const auto *spinbox : findChildren<QSpinBox *>(QString(), Qt::FindDirectChildrenOnly)) {
    m_settings->setValue(spinbox->objectName(), spinbox->value());
  }

  // Bool
  for (const auto *checkbox : findChildren<QCheckBox *>(QString(), Qt::FindDirectChildrenOnly)) {
    m_settings->setValue(checkbox->objectName(), checkbox->isChecked());
  }

  // String
  for (const auto *lineedit : findChildren<QLineEdit *>(QString(), Qt::FindDirectChildrenOnly)) {
    m_settings->setValue(lineedit->objectName(), lineedit->text());
  }

  // Font
  for (const auto *font : findChildren<QFontComboBox *>(QString(), Qt::FindDirectChildrenOnly)) {
    m_settings->setValue(font->objectName(), font->currentFont().family());
  }

  // Shortcut
  for (const auto *shortcut : findChildren<QKeySequenceEdit *>(QString(), Qt::FindDirectChildrenOnly)) {
    m_settings->setValue(shortcut->objectName(), shortcut->keySequence());
  }

  if (objectName() != QLatin1String("General")) m_settings->endGroup();
}