1 | /* |
---|---|
2 | SPDX-FileCopyrightText: 2011-2018 Dominik Haumann <dhaumann@kde.org> |
3 | |
4 | SPDX-License-Identifier: LGPL-2.0-or-later |
5 | */ |
6 | |
7 | #ifndef VARIABLE_EDITOR_H |
8 | #define VARIABLE_EDITOR_H |
9 | |
10 | #include <QWidget> |
11 | |
12 | class KateHelpButton; |
13 | |
14 | class VariableBoolItem; |
15 | class VariableColorItem; |
16 | class VariableFontItem; |
17 | class VariableItem; |
18 | class VariableStringListItem; |
19 | class VariableIntItem; |
20 | class VariableStringItem; |
21 | class VariableSpellCheckItem; |
22 | class VariableRemoveSpacesItem; |
23 | |
24 | class KColorCombo; |
25 | class QFontComboBox; |
26 | class QCheckBox; |
27 | class QComboBox; |
28 | class QLabel; |
29 | class QLineEdit; |
30 | class QSpinBox; |
31 | |
32 | namespace Sonnet |
33 | { |
34 | class DictionaryComboBox; |
35 | } |
36 | |
37 | class VariableEditor : public QWidget |
38 | { |
39 | Q_OBJECT |
40 | |
41 | public: |
42 | explicit VariableEditor(VariableItem *item, QWidget *parent = nullptr); |
43 | |
44 | VariableItem *item() const; |
45 | |
46 | Q_SIGNALS: |
47 | void valueChanged(); |
48 | |
49 | protected Q_SLOTS: |
50 | void itemEnabled(bool enabled); |
51 | void activateItem(); |
52 | |
53 | protected: |
54 | void paintEvent(QPaintEvent *event) override; |
55 | void enterEvent(QEnterEvent *event) override; |
56 | void leaveEvent(QEvent *event) override; |
57 | |
58 | private: |
59 | VariableItem *m_item; |
60 | |
61 | QCheckBox *m_checkBox; |
62 | QLabel *m_variable; |
63 | QLabel *m_helpText; |
64 | KateHelpButton *m_btnHelp; |
65 | }; |
66 | |
67 | class VariableIntEditor : public VariableEditor |
68 | { |
69 | public: |
70 | VariableIntEditor(VariableIntItem *item, QWidget *parent); |
71 | |
72 | protected: |
73 | void setItemValue(int newValue); |
74 | |
75 | private: |
76 | QSpinBox *m_spinBox; |
77 | }; |
78 | |
79 | class VariableBoolEditor : public VariableEditor |
80 | { |
81 | public: |
82 | VariableBoolEditor(VariableBoolItem *item, QWidget *parent); |
83 | |
84 | protected: |
85 | void setItemValue(int enabled); |
86 | |
87 | private: |
88 | QComboBox *m_comboBox; |
89 | }; |
90 | |
91 | class VariableStringListEditor : public VariableEditor |
92 | { |
93 | public: |
94 | VariableStringListEditor(VariableStringListItem *item, QWidget *parent); |
95 | |
96 | protected: |
97 | void setItemValue(const QString &newValue); |
98 | |
99 | private: |
100 | QComboBox *m_comboBox; |
101 | }; |
102 | |
103 | class VariableColorEditor : public VariableEditor |
104 | { |
105 | public: |
106 | VariableColorEditor(VariableColorItem *item, QWidget *parent); |
107 | |
108 | protected: |
109 | void setItemValue(const QColor &newValue); |
110 | |
111 | private: |
112 | KColorCombo *m_comboBox; |
113 | }; |
114 | |
115 | class VariableFontEditor : public VariableEditor |
116 | { |
117 | public: |
118 | VariableFontEditor(VariableFontItem *item, QWidget *parent); |
119 | |
120 | protected: |
121 | void setItemValue(const QFont &newValue); |
122 | |
123 | private: |
124 | QFontComboBox *m_comboBox; |
125 | }; |
126 | |
127 | class VariableStringEditor : public VariableEditor |
128 | { |
129 | public: |
130 | VariableStringEditor(VariableStringItem *item, QWidget *parent); |
131 | |
132 | protected: |
133 | void setItemValue(const QString &newValue); |
134 | |
135 | private: |
136 | QLineEdit *m_lineEdit; |
137 | }; |
138 | |
139 | class VariableSpellCheckEditor : public VariableEditor |
140 | { |
141 | public: |
142 | VariableSpellCheckEditor(VariableSpellCheckItem *item, QWidget *parent); |
143 | |
144 | protected: |
145 | void setItemValue(const QString &newValue); |
146 | |
147 | private: |
148 | Sonnet::DictionaryComboBox *m_dictionaryCombo; |
149 | }; |
150 | |
151 | class VariableRemoveSpacesEditor : public VariableEditor |
152 | { |
153 | public: |
154 | VariableRemoveSpacesEditor(VariableRemoveSpacesItem *item, QWidget *parent); |
155 | |
156 | protected: |
157 | void setItemValue(int enabled); |
158 | |
159 | private: |
160 | QComboBox *m_comboBox; |
161 | }; |
162 | |
163 | #endif |
164 |