1 | /* |
2 | SPDX-FileCopyrightText: 2002, 2003 Anders Lund <anders.lund@lund.tdcadsl.dk> |
3 | SPDX-FileCopyrightText: 2003 Christoph Cullmann <cullmann@kde.org> |
4 | SPDX-FileCopyrightText: 2001 Joseph Wenninger <jowenn@kde.org> |
5 | SPDX-FileCopyrightText: 2006-2016 Dominik Haumann <dhaumann@kde.org> |
6 | SPDX-FileCopyrightText: 2007 Mirko Stocker <me@misto.ch> |
7 | SPDX-FileCopyrightText: 2009 Michel Ludwig <michel.ludwig@kdemail.net> |
8 | SPDX-FileCopyrightText: 1999 Jochen Wilhelmy <digisnap@cs.tu-berlin.de> |
9 | |
10 | SPDX-License-Identifier: LGPL-2.0-or-later |
11 | */ |
12 | |
13 | #ifndef KATE_DIALOGS_H |
14 | #define KATE_DIALOGS_H |
15 | |
16 | #include "kateconfigpage.h" |
17 | #include "katehighlight.h" |
18 | #include "kateviewhelpers.h" |
19 | |
20 | #include <ktexteditor/attribute.h> |
21 | #include <ktexteditor/document.h> |
22 | |
23 | #include <sonnet/configwidget.h> |
24 | #include <sonnet/dictionarycombobox.h> |
25 | |
26 | #include <QColor> |
27 | #include <QDialog> |
28 | #include <QTabWidget> |
29 | #include <QTreeWidget> |
30 | |
31 | class ModeConfigPage; |
32 | namespace KTextEditor |
33 | { |
34 | class DocumentPrivate; |
35 | } |
36 | namespace KTextEditor |
37 | { |
38 | class ViewPrivate; |
39 | } |
40 | namespace KTextEditor |
41 | { |
42 | class Message; |
43 | } |
44 | |
45 | namespace KIO |
46 | { |
47 | class Job; |
48 | class TransferJob; |
49 | } |
50 | |
51 | class KShortcutsEditor; |
52 | class QSpinBox; |
53 | class KProcess; |
54 | |
55 | class QCheckBox; |
56 | class QLabel; |
57 | class QCheckBox; |
58 | class QKeyEvent; |
59 | class QTemporaryFile; |
60 | class QTableWidget; |
61 | |
62 | namespace Ui |
63 | { |
64 | class TextareaAppearanceConfigWidget; |
65 | class BordersAppearanceConfigWidget; |
66 | class NavigationConfigWidget; |
67 | class EditConfigWidget; |
68 | class IndentationConfigWidget; |
69 | class OpenSaveConfigWidget; |
70 | class OpenSaveConfigAdvWidget; |
71 | class CompletionConfigTab; |
72 | class SpellCheckConfigWidget; |
73 | class StatusbarConfigWidget; |
74 | } |
75 | |
76 | class KateGotoBar : public KateViewBarWidget |
77 | { |
78 | public: |
79 | explicit KateGotoBar(KTextEditor::View *view, QWidget *parent = nullptr); |
80 | |
81 | void closed() override; |
82 | |
83 | public: |
84 | void updateData(); |
85 | |
86 | protected: |
87 | void gotoLine(); |
88 | void gotoClipboard(); |
89 | |
90 | protected: |
91 | void keyPressEvent(QKeyEvent *event) override; |
92 | bool eventFilter(QObject *, QEvent *) override; |
93 | void showEvent(QShowEvent *event) override; |
94 | |
95 | private: |
96 | KTextEditor::View *const m_view; |
97 | QSpinBox *m_gotoRange = nullptr; |
98 | QToolButton *m_modifiedUp = nullptr; |
99 | QToolButton *m_modifiedDown = nullptr; |
100 | int m_wheelDelta = 0; // To accumulate "wheel-deltas" to become e.g. a touch-pad usable |
101 | }; |
102 | |
103 | class KateDictionaryBar : public KateViewBarWidget |
104 | { |
105 | public: |
106 | explicit KateDictionaryBar(KTextEditor::ViewPrivate *view, QWidget *parent = nullptr); |
107 | ~KateDictionaryBar() override; |
108 | |
109 | public: |
110 | void updateData(); |
111 | |
112 | protected: |
113 | void dictionaryChanged(const QString &dictionary); |
114 | |
115 | private: |
116 | KTextEditor::ViewPrivate *m_view; |
117 | Sonnet::DictionaryComboBox *m_dictionaryComboBox; |
118 | }; |
119 | |
120 | class KateIndentConfigTab : public KateConfigPage |
121 | { |
122 | public: |
123 | explicit KateIndentConfigTab(QWidget *parent); |
124 | ~KateIndentConfigTab() override; |
125 | QString name() const override; |
126 | |
127 | protected: |
128 | Ui::IndentationConfigWidget *ui; |
129 | |
130 | public: |
131 | void apply() override; |
132 | void reload() override; |
133 | void reset() override |
134 | { |
135 | } |
136 | void defaults() override |
137 | { |
138 | } |
139 | |
140 | private: |
141 | void slotChanged(); |
142 | void showWhatsThis(const QString &text); |
143 | }; |
144 | |
145 | class KateCompletionConfigTab : public KateConfigPage |
146 | { |
147 | public: |
148 | explicit KateCompletionConfigTab(QWidget *parent); |
149 | ~KateCompletionConfigTab() override; |
150 | QString name() const override; |
151 | |
152 | protected: |
153 | Ui::CompletionConfigTab *ui; |
154 | |
155 | public: |
156 | void apply() override; |
157 | void reload() override; |
158 | void reset() override |
159 | { |
160 | } |
161 | void defaults() override |
162 | { |
163 | } |
164 | |
165 | private: |
166 | void showWhatsThis(const QString &text); |
167 | }; |
168 | |
169 | class KateEditGeneralConfigTab : public KateConfigPage |
170 | { |
171 | public: |
172 | explicit KateEditGeneralConfigTab(QWidget *parent); |
173 | ~KateEditGeneralConfigTab() override; |
174 | QString name() const override; |
175 | |
176 | private: |
177 | Ui::EditConfigWidget *ui; |
178 | |
179 | enum SetOfCharsToEncloseSelection { |
180 | None, |
181 | MarkDown, |
182 | NonLetters, |
183 | MirrorChar, |
184 | UserData // Ensure to keep it at bottom of this list |
185 | }; |
186 | |
187 | public: |
188 | void apply() override; |
189 | void reload() override; |
190 | void reset() override |
191 | { |
192 | } |
193 | void defaults() override |
194 | { |
195 | } |
196 | }; |
197 | |
198 | class KateNavigationConfigTab : public KateConfigPage |
199 | { |
200 | public: |
201 | explicit KateNavigationConfigTab(QWidget *parent); |
202 | ~KateNavigationConfigTab() override; |
203 | QString name() const override; |
204 | |
205 | private: |
206 | Ui::NavigationConfigWidget *ui; |
207 | |
208 | void initMulticursorModifierComboBox(); |
209 | |
210 | public: |
211 | void apply() override; |
212 | void reload() override; |
213 | void reset() override |
214 | { |
215 | } |
216 | void defaults() override |
217 | { |
218 | } |
219 | }; |
220 | |
221 | class KateSpellCheckConfigTab : public KateConfigPage |
222 | { |
223 | public: |
224 | explicit KateSpellCheckConfigTab(QWidget *parent); |
225 | ~KateSpellCheckConfigTab() override; |
226 | QString name() const override; |
227 | |
228 | protected: |
229 | Ui::SpellCheckConfigWidget *ui; |
230 | Sonnet::ConfigWidget *m_sonnetConfigWidget; |
231 | |
232 | public: |
233 | void apply() override; |
234 | void reload() override; |
235 | void reset() override |
236 | { |
237 | } |
238 | void defaults() override |
239 | { |
240 | } |
241 | |
242 | private: |
243 | void showWhatsThis(const QString &text); |
244 | }; |
245 | |
246 | class KateEditConfigTab : public KateConfigPage |
247 | { |
248 | public: |
249 | explicit KateEditConfigTab(QWidget *parent); |
250 | ~KateEditConfigTab() override; |
251 | QString name() const override; |
252 | QString fullName() const override; |
253 | QIcon icon() const override; |
254 | |
255 | public: |
256 | void apply() override; |
257 | void reload() override; |
258 | void reset() override; |
259 | void defaults() override; |
260 | |
261 | private: |
262 | KateEditGeneralConfigTab *editConfigTab; |
263 | KateNavigationConfigTab *navigationConfigTab; |
264 | KateIndentConfigTab *indentConfigTab; |
265 | KateCompletionConfigTab *completionConfigTab; |
266 | KateSpellCheckConfigTab *spellCheckConfigTab; |
267 | std::vector<KateConfigPage *> m_inputModeConfigTabs; |
268 | }; |
269 | |
270 | class KateViewDefaultsConfig : public KateConfigPage |
271 | { |
272 | public: |
273 | explicit KateViewDefaultsConfig(QWidget *parent); |
274 | ~KateViewDefaultsConfig() override; |
275 | QString name() const override; |
276 | QString fullName() const override; |
277 | QIcon icon() const override; |
278 | |
279 | public: |
280 | void apply() override; |
281 | void reload() override; |
282 | void reset() override; |
283 | void defaults() override; |
284 | |
285 | private: |
286 | Ui::TextareaAppearanceConfigWidget *const textareaUi; |
287 | Ui::BordersAppearanceConfigWidget *const bordersUi; |
288 | Ui::StatusbarConfigWidget *const statusBarUi; |
289 | }; |
290 | |
291 | class KateSaveConfigTab : public KateConfigPage |
292 | { |
293 | public: |
294 | explicit KateSaveConfigTab(QWidget *parent); |
295 | ~KateSaveConfigTab() override; |
296 | QString name() const override; |
297 | QString fullName() const override; |
298 | QIcon icon() const override; |
299 | |
300 | public: |
301 | void apply() override; |
302 | void reload() override; |
303 | void reset() override; |
304 | void defaults() override; |
305 | void swapFileModeChanged(int); |
306 | |
307 | protected: |
308 | // why? |
309 | // KComboBox *m_encoding, *m_encodingDetection, *m_eol; |
310 | QCheckBox *cbLocalFiles, *cbRemoteFiles; |
311 | QCheckBox *replaceTabs, *removeSpaces, *allowEolDetection; |
312 | class QSpinBox *blockCount; |
313 | class QLabel *blockCountLabel; |
314 | |
315 | private: |
316 | Ui::OpenSaveConfigWidget *ui; |
317 | Ui::OpenSaveConfigAdvWidget *uiadv; |
318 | ModeConfigPage *modeConfigPage; |
319 | }; |
320 | |
321 | /** |
322 | * This dialog will prompt the user for what do with a file that is |
323 | * modified on disk. |
324 | * If the file wasn't deleted, it has a 'diff' button, which will create |
325 | * a diff file (using diff(1)) and launch that using OpenUrlJob. |
326 | */ |
327 | class KateModOnHdPrompt : public QObject |
328 | { |
329 | Q_OBJECT |
330 | public: |
331 | enum Status { |
332 | Reload = 1, // 0 is QDialog::Rejected |
333 | Save, |
334 | Overwrite, |
335 | Ignore, |
336 | Close |
337 | }; |
338 | KateModOnHdPrompt(KTextEditor::DocumentPrivate *doc, KTextEditor::Document::ModifiedOnDiskReason modtype, const QString &reason); |
339 | ~KateModOnHdPrompt() override; |
340 | |
341 | Q_SIGNALS: |
342 | void saveAsTriggered(); |
343 | void ignoreTriggered(); |
344 | void reloadTriggered(); |
345 | void autoReloadTriggered(); |
346 | void closeTriggered(); |
347 | |
348 | private Q_SLOTS: |
349 | /** |
350 | * Show a diff between the document text and the disk file. |
351 | */ |
352 | void slotDiff(); |
353 | |
354 | private Q_SLOTS: |
355 | void slotDataAvailable(); ///< read data from the process |
356 | void slotPDone(); ///< Runs the diff file when done |
357 | |
358 | private: |
359 | KTextEditor::DocumentPrivate *m_doc; |
360 | QPointer<KTextEditor::Message> m_message; |
361 | QString m_fullDiffPath; |
362 | KProcess *m_proc; |
363 | QTemporaryFile *m_diffFile; |
364 | QAction *m_diffAction; |
365 | }; |
366 | |
367 | #endif |
368 | |