| 1 | // For license of this file, see <project-root-folder>/LICENSE.md. |
| 2 | |
| 3 | #ifndef TIMESPINBOX_H |
| 4 | #define TIMESPINBOX_H |
| 5 | |
| 6 | #include <QDoubleSpinBox> |
| 7 | |
| 8 | class TimeSpinBox : public QDoubleSpinBox { |
| 9 | Q_OBJECT |
| 10 | |
| 11 | public: |
| 12 | enum class Mode { |
| 13 | HoursMinutes, |
| 14 | MinutesSeconds, |
| 15 | DaysHours |
| 16 | }; |
| 17 | |
| 18 | explicit TimeSpinBox(QWidget* parent = nullptr); |
| 19 | |
| 20 | double valueFromText(const QString& text) const; |
| 21 | QString textFromValue(double val) const; |
| 22 | void fixup(QString& input) const; |
| 23 | QValidator::State validate(QString& input, int& pos) const; |
| 24 | |
| 25 | Mode mode() const; |
| 26 | void setMode(Mode mode); |
| 27 | |
| 28 | private: |
| 29 | Mode m_mode; |
| 30 | }; |
| 31 | |
| 32 | #endif // TIMESPINBOX_H |