File indexing completed on 2022-11-22 12:51:03

0001 #include "kalziumconfigdialog.h"
0002 
0003 #include "ui_settings_calc.h"
0004 #include "ui_settings_colors.h"
0005 #include "ui_settings_gradients.h"
0006 
0007 KalziumConfigDialog::KalziumConfigDialog(QWidget *parent, const QString &name, KCoreConfigSkeleton *config)
0008     : KConfigDialog(parent, name, config)
0009 {
0010     // colors page
0011     Ui_setupColors ui_colors;
0012     auto w_colors = new QWidget(this);
0013     w_colors->setObjectName(QStringLiteral("colors_page"));
0014     ui_colors.setupUi(w_colors);
0015     addPage(w_colors, i18n("Schemes"), QStringLiteral("preferences-desktop-color"));
0016 
0017     // gradients page
0018     Ui_setupGradients ui_gradients;
0019     auto w_gradients = new QWidget(this);
0020     w_gradients->setObjectName(QStringLiteral("gradients_page"));
0021     ui_gradients.setupUi(w_gradients);
0022     addPage(w_gradients, i18n("Gradients"), QStringLiteral("preferences-desktop-color"));
0023 
0024     // units page
0025     m_unitsDialog = new UnitSettingsDialog(this);
0026     m_unitsDialog->setObjectName(QStringLiteral("units_page"));
0027     addPage(m_unitsDialog, i18n("Units"), QStringLiteral("system-run"));
0028 
0029     // isotope table page
0030     m_isotopeTableSettingsDialog = new IsotopeTableSettingsDialog(this);
0031     m_isotopeTableSettingsDialog->setObjectName(QStringLiteral("isotopemap"));
0032     connect(m_isotopeTableSettingsDialog, &IsotopeTableSettingsDialog::modeChanged, this, &KalziumConfigDialog::updateButtons);
0033     addPage(m_isotopeTableSettingsDialog, i18n("Isotope Table"), QStringLiteral("isotopemap"));
0034 
0035     Ui_setupCalc ui_calc;
0036     auto w_calc = new QWidget(this);
0037     ui_calc.setupUi(w_calc);
0038     addPage(w_calc, i18n("Calculator"), QStringLiteral("accessories-calculator"));
0039 }
0040 
0041 bool KalziumConfigDialog::hasChanged()
0042 {
0043     return m_isotopeTableSettingsDialog->hasChanged();
0044 }
0045 
0046 bool KalziumConfigDialog::isDefault()
0047 {
0048     return m_isotopeTableSettingsDialog->isDefault();
0049 }
0050 
0051 void KalziumConfigDialog::updateWidgetsDefault()
0052 {
0053     m_isotopeTableSettingsDialog->setMode(Prefs::defaultIsotopeTableModeValue());
0054 }
0055 
0056 void KalziumConfigDialog::updateSettings()
0057 {
0058     Prefs::setLengthUnit(m_unitsDialog->getLenghtUnitId());
0059     Prefs::setEnergiesUnit(m_unitsDialog->getEnergyUnitId());
0060     Prefs::setTemperatureUnit(m_unitsDialog->getTemperatureUnitId());
0061 
0062     Prefs::setIsotopeTableMode(m_isotopeTableSettingsDialog->getMode());
0063 
0064     Prefs::self()->save();
0065 }