File indexing completed on 2024-04-14 14:11:47

0001 /*
0002     SPDX-FileCopyrightText: 2015 Utkarsh Simha <utkarshsimha@gmail.com>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #ifndef UNITSPINBOXWIDGET_H
0008 #define UNITSPINBOXWIDGET_H
0009 
0010 #include "ui_unitspinboxwidget.h"
0011 
0012 /**
0013  * @brief The UnitSpinBoxWidget class
0014     * It is a widget that provides a DoubleSpinBox
0015     * and a ComboBox for conversions from different
0016     * units.
0017  * @author Utkarsh Simha
0018  */
0019 class UnitSpinBoxWidget : public QWidget
0020 {
0021     Q_OBJECT
0022 
0023   public:
0024     explicit UnitSpinBoxWidget(QWidget *parent = nullptr);
0025     ~UnitSpinBoxWidget() override;
0026 
0027     /**
0028          * @brief addUnit Adds a item to the combo box
0029          * @param unitName The name of the unit to be displayed
0030          * @param conversionFactor The factor the value of a unit must be multiplied by
0031          */
0032     void addUnit(const QString &unitName, double conversionFactor);
0033 
0034     /**
0035          * @brief value Returns value upon conversion
0036          */
0037     double value() const;
0038 
0039   private:
0040     Ui::UnitSpinBoxWidget *ui;
0041     QComboBox *comboBox;
0042     QDoubleSpinBox *doubleSpinBox;
0043 };
0044 
0045 #endif // UNITSPINBOXWIDGET_H