src/widgets/doublespinbox.h

Tue, 28 Sep 2021 23:07:23 +0300

author
Teemu Piippo <teemu@hecknology.net>
date
Tue, 28 Sep 2021 23:07:23 +0300
changeset 145
4dea24d3eda0
parent 82
70c67c2c4e36
permissions
-rw-r--r--

Use QSaveFile to save the file more safely

82
70c67c2c4e36 added doublespinbox
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1 /*
70c67c2c4e36 added doublespinbox
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
2 * LDForge: LDraw parts authoring CAD
70c67c2c4e36 added doublespinbox
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
3 * Copyright (C) 2013 - 2020 Teemu Piippo
70c67c2c4e36 added doublespinbox
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
4 *
70c67c2c4e36 added doublespinbox
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
5 * This program is free software: you can redistribute it and/or modify
70c67c2c4e36 added doublespinbox
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
6 * it under the terms of the GNU General Public License as published by
70c67c2c4e36 added doublespinbox
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
7 * the Free Software Foundation, either version 3 of the License, or
70c67c2c4e36 added doublespinbox
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
8 * (at your option) any later version.
70c67c2c4e36 added doublespinbox
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
9 *
70c67c2c4e36 added doublespinbox
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
10 * This program is distributed in the hope that it will be useful,
70c67c2c4e36 added doublespinbox
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
70c67c2c4e36 added doublespinbox
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
70c67c2c4e36 added doublespinbox
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
13 * GNU General Public License for more details.
70c67c2c4e36 added doublespinbox
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
14 *
70c67c2c4e36 added doublespinbox
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License
70c67c2c4e36 added doublespinbox
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
70c67c2c4e36 added doublespinbox
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
17 */
70c67c2c4e36 added doublespinbox
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
18
70c67c2c4e36 added doublespinbox
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
19 #pragma once
70c67c2c4e36 added doublespinbox
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
20 #include <QDoubleSpinBox>
70c67c2c4e36 added doublespinbox
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
21
70c67c2c4e36 added doublespinbox
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
22 /*
70c67c2c4e36 added doublespinbox
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
23 * A version of QDoubleSpinBox that consistently uses "." as the decimal separator
70c67c2c4e36 added doublespinbox
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
24 * and does not display trailing zeros.
70c67c2c4e36 added doublespinbox
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
25 */
70c67c2c4e36 added doublespinbox
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
26 class DoubleSpinBox : public QDoubleSpinBox
70c67c2c4e36 added doublespinbox
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
27 {
70c67c2c4e36 added doublespinbox
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
28 public:
70c67c2c4e36 added doublespinbox
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
29 DoubleSpinBox(QWidget* parent = nullptr);
70c67c2c4e36 added doublespinbox
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
30 protected:
70c67c2c4e36 added doublespinbox
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
31 QString textFromValue(double value) const override;
70c67c2c4e36 added doublespinbox
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
32 QValidator::State validate(QString& input, int& pos) const override;
70c67c2c4e36 added doublespinbox
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
33 };
70c67c2c4e36 added doublespinbox
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
34

mercurial