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

0001 /*
0002     SPDX-FileCopyrightText: 2011 Rebetez Etienne <etienne.rebetez@oberwallis.ch>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #include "unitsettingsdialog.h"
0008 
0009 #include <QGridLayout>
0010 #include <QLabel>
0011 
0012 #include <KLocalizedString>
0013 #include <KUnitConversion/Converter>
0014 
0015 UnitSettingsDialog::UnitSettingsDialog(QWidget *parent)
0016     : QWidget(parent)
0017 {
0018     auto labelEnergy = new QLabel(i18n("Energy:"), this);
0019     QList<int> energy;
0020     energy << KUnitConversion::Electronvolt << KUnitConversion::KiloJoulePerMole << KUnitConversion::JoulePerMole << KUnitConversion::Joule;
0021     m_comboBoxLEnergiesUnit = new KalziumUnitCombobox(energy, this);
0022     m_comboBoxLEnergiesUnit->setObjectName(QStringLiteral("kcfg_combobox_energies"));
0023 
0024     auto labelLenght = new QLabel(i18n("Length:"), this);
0025     QList<int> length;
0026     length << KUnitConversion::Picometer << KUnitConversion::Nanometer << KUnitConversion::Angstrom;
0027     m_comboBoxLengthUnit = new KalziumUnitCombobox(length, this);
0028     m_comboBoxLengthUnit->setObjectName(QStringLiteral("kcfg_combobox_length"));
0029 
0030     auto labelTemperature = new QLabel(i18n("Temperature:"), this);
0031     QList<int> temperature;
0032     temperature << KUnitConversion::Kelvin << KUnitConversion::Celsius << KUnitConversion::Fahrenheit << KUnitConversion::Reaumur;
0033     m_comboBoxLTemperatureUnit = new KalziumUnitCombobox(temperature, this);
0034     m_comboBoxLTemperatureUnit->setObjectName(QStringLiteral("kcfg_combobox_temperature"));
0035 
0036     auto layout = new QGridLayout(this);
0037     layout->addWidget(labelEnergy, 0, 0);
0038     layout->addWidget(m_comboBoxLEnergiesUnit, 0, 1);
0039 
0040     layout->addWidget(labelLenght, 1, 0);
0041     layout->addWidget(m_comboBoxLengthUnit, 1, 1);
0042 
0043     layout->addWidget(labelTemperature, 2, 0);
0044     layout->addWidget(m_comboBoxLTemperatureUnit, 2, 1);
0045 
0046     layout->setRowStretch(3, 1);
0047 
0048     setLayout(layout);
0049 }
0050 
0051 int UnitSettingsDialog::getEnergyUnitId() const
0052 {
0053     return m_comboBoxLEnergiesUnit->getCurrentUnitId();
0054 }
0055 
0056 int UnitSettingsDialog::getLenghtUnitId() const
0057 {
0058     return m_comboBoxLengthUnit->getCurrentUnitId();
0059 }
0060 
0061 int UnitSettingsDialog::getTemperatureUnitId() const
0062 {
0063     return m_comboBoxLTemperatureUnit->getCurrentUnitId();
0064 }
0065 
0066 UnitSettingsDialog::~UnitSettingsDialog()
0067 {
0068     delete m_comboBoxLEnergiesUnit;
0069     delete m_comboBoxLengthUnit;
0070     delete m_comboBoxLTemperatureUnit;
0071 }