1 // Copyright (C) 2012-2019 The VPaint Developers.
2 // See the COPYRIGHT file at the top-level directory of this distribution
3 // and at https://github.com/dalboris/vpaint/blob/master/COPYRIGHT
4 //
5 // Licensed under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 
17 #ifndef DEV_SETTINGS_H
18 #define DEV_SETTINGS_H
19 
20 // This class is intended for development only, to quickly try out
21 // different parameters and find out what are the best.
22 //
23 // For actual deployment, those dev settings should either be moved to
24 // "settings" (i.e., non-dev) and make it user-controlable, or be
25 // moved directly to global.
26 
27 #include <QWidget>
28 #include <QCheckBox>
29 #include <QSpinBox>
30 #include <QDoubleSpinBox>
31 #include <QGridLayout>
32 #include <QString>
33 #include <QMap>
34 
35 
36 class DevSettings : public QWidget
37 {
38     Q_OBJECT
39 
40 public:
41     DevSettings();
42     static bool getBool(const QString & name);
43     static int getInt(const QString & name);
44     static double getDouble(const QString & name);
instance()45     static DevSettings * instance()
46         {return s;}
47 
48 signals:
49     void changed();
50 
51 private:
52     static DevSettings *s;
53 
54     // bool values
55     QMap<QString,QCheckBox*> checkBoxes_;
56     QCheckBox * createCheckBox(const QString & string, bool checked);
57 
58     // int values
59     QMap<QString,QSpinBox*> spinBoxes_;
60     QSpinBox * createSpinBox(const QString & string, int min, int max, int value);
61 
62     // double values
63     QMap<QString,QDoubleSpinBox*> doubleSpinBoxes_;
64     QDoubleSpinBox * createDoubleSpinBox(const QString & string, double min, double max, double value);
65 
66     // layout
67     void addSection(const QString & string);
68     void addWidget(QWidget *widget, const QString & string);
69     QGridLayout *layout_;
70     int numWidgets_;
71 };
72 
73 #endif
74