Changeset View
Changeset View
Standalone View
Standalone View
plugins/meson/settings/mesonoptionbaseview.h
- This file was added.
1 | /* This file is part of KDevelop | ||||
---|---|---|---|---|---|
2 | Copyright 2019 Daniel Mensinger <daniel@mensinger-ka.de> | ||||
3 | | ||||
4 | This library is free software; you can redistribute it and/or | ||||
5 | modify it under the terms of the GNU Library General Public | ||||
6 | License as published by the Free Software Foundation; either | ||||
7 | version 2 of the License, or (at your option) any later version. | ||||
8 | | ||||
9 | This library is distributed in the hope that it will be useful, | ||||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||||
12 | Library General Public License for more details. | ||||
13 | | ||||
14 | You should have received a copy of the GNU Library General Public License | ||||
15 | along with this library; see the file COPYING.LIB. If not, write to | ||||
16 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||||
17 | Boston, MA 02110-1301, USA. | ||||
18 | */ | ||||
19 | | ||||
20 | #pragma once | ||||
21 | | ||||
22 | #include "mesonoptions.h" | ||||
23 | #include <QWidget> | ||||
24 | | ||||
25 | namespace Ui | ||||
26 | { | ||||
27 | class MesonOptionBaseView; | ||||
28 | } | ||||
29 | | ||||
30 | class QCheckBox; | ||||
31 | class QComboBox; | ||||
32 | class QLineEdit; | ||||
33 | class QPushButton; | ||||
34 | class QSpinBox; | ||||
35 | | ||||
36 | class MesonOptionBaseView : public QWidget | ||||
37 | { | ||||
38 | Q_OBJECT | ||||
39 | | ||||
40 | public: | ||||
41 | explicit MesonOptionBaseView(OPT_PTR option, QWidget* parent); | ||||
42 | virtual ~MesonOptionBaseView(); | ||||
43 | | ||||
44 | int nameWidth(); | ||||
45 | void setMinNameWidth(int width); | ||||
46 | | ||||
47 | virtual MesonOptionBase* option() = 0; | ||||
48 | virtual void updateInput() = 0; | ||||
49 | | ||||
50 | void setInputWidget(QWidget* input); | ||||
51 | | ||||
52 | protected: | ||||
53 | void setChanged(bool changed); | ||||
54 | | ||||
55 | public Q_SLOTS: | ||||
56 | void reset(); | ||||
57 | | ||||
58 | Q_SIGNALS: | ||||
59 | void configChanged(); | ||||
60 | | ||||
61 | private: | ||||
62 | Ui::MesonOptionBaseView* m_ui = nullptr; | ||||
63 | }; | ||||
64 | | ||||
65 | class MesonOptionArrayView : public MesonOptionBaseView | ||||
66 | { | ||||
67 | Q_OBJECT | ||||
68 | | ||||
69 | public: | ||||
70 | MesonOptionArrayView(OPT_PTR option, QWidget* parent); | ||||
71 | | ||||
72 | MesonOptionBase* option() override; | ||||
73 | void updateInput() override; | ||||
74 | | ||||
75 | private: | ||||
76 | std::shared_ptr<MesonOptionArray> m_option; | ||||
77 | QPushButton* m_input = nullptr; | ||||
78 | }; | ||||
79 | | ||||
80 | class MesonOptionBoolView : public MesonOptionBaseView | ||||
81 | { | ||||
82 | Q_OBJECT | ||||
83 | | ||||
84 | public: | ||||
85 | MesonOptionBoolView(OPT_PTR option, QWidget* parent); | ||||
86 | | ||||
87 | MesonOptionBase* option() override; | ||||
88 | void updateInput() override; | ||||
89 | | ||||
90 | public Q_SLOTS: | ||||
91 | void updated(); | ||||
92 | | ||||
93 | private: | ||||
94 | std::shared_ptr<MesonOptionBool> m_option; | ||||
95 | QCheckBox* m_input = nullptr; | ||||
96 | }; | ||||
97 | | ||||
98 | class MesonOptionComboView : public MesonOptionBaseView | ||||
99 | { | ||||
100 | Q_OBJECT | ||||
101 | | ||||
102 | public: | ||||
103 | MesonOptionComboView(OPT_PTR option, QWidget* parent); | ||||
104 | | ||||
105 | MesonOptionBase* option() override; | ||||
106 | void updateInput() override; | ||||
107 | | ||||
108 | public Q_SLOTS: | ||||
109 | void updated(); | ||||
110 | | ||||
111 | private: | ||||
112 | std::shared_ptr<MesonOptionCombo> m_option; | ||||
113 | QComboBox* m_input = nullptr; | ||||
114 | }; | ||||
115 | | ||||
116 | class MesonOptionIntegerView : public MesonOptionBaseView | ||||
117 | { | ||||
118 | Q_OBJECT | ||||
119 | | ||||
120 | public: | ||||
121 | MesonOptionIntegerView(OPT_PTR option, QWidget* parent); | ||||
122 | | ||||
123 | MesonOptionBase* option() override; | ||||
124 | void updateInput() override; | ||||
125 | | ||||
126 | public Q_SLOTS: | ||||
127 | void updated(); | ||||
128 | | ||||
129 | private: | ||||
130 | std::shared_ptr<MesonOptionInteger> m_option; | ||||
131 | QSpinBox* m_input = nullptr; | ||||
132 | }; | ||||
133 | | ||||
134 | class MesonOptionStringView : public MesonOptionBaseView | ||||
135 | { | ||||
136 | Q_OBJECT | ||||
137 | | ||||
138 | public: | ||||
139 | MesonOptionStringView(OPT_PTR option, QWidget* parent); | ||||
140 | | ||||
141 | MesonOptionBase* option() override; | ||||
142 | void updateInput() override; | ||||
143 | | ||||
144 | public Q_SLOTS: | ||||
145 | void updated(); | ||||
146 | | ||||
147 | private: | ||||
148 | std::shared_ptr<MesonOptionString> m_option; | ||||
149 | QLineEdit* m_input = nullptr; | ||||
150 | }; |