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
31class ModeConfigPage;
32namespace KTextEditor
33{
34class DocumentPrivate;
35}
36namespace KTextEditor
37{
38class ViewPrivate;
39}
40namespace KTextEditor
41{
42class Message;
43}
44
45namespace KIO
46{
47class Job;
48class TransferJob;
49}
50
51class KShortcutsEditor;
52class QSpinBox;
53class KProcess;
54
55class QCheckBox;
56class QLabel;
57class QCheckBox;
58class QKeyEvent;
59class QTemporaryFile;
60class QTableWidget;
61
62namespace Ui
63{
64class TextareaAppearanceConfigWidget;
65class BordersAppearanceConfigWidget;
66class NavigationConfigWidget;
67class EditConfigWidget;
68class IndentationConfigWidget;
69class OpenSaveConfigWidget;
70class OpenSaveConfigAdvWidget;
71class CompletionConfigTab;
72class SpellCheckConfigWidget;
73class StatusbarConfigWidget;
74}
75
76class KateGotoBar : public KateViewBarWidget
77{
78public:
79 explicit KateGotoBar(KTextEditor::View *view, QWidget *parent = nullptr);
80
81 void closed() override;
82
83public:
84 void updateData();
85
86protected:
87 void gotoLine();
88 void gotoClipboard();
89
90protected:
91 void keyPressEvent(QKeyEvent *event) override;
92 bool eventFilter(QObject *, QEvent *) override;
93 void showEvent(QShowEvent *event) override;
94
95private:
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
103class KateDictionaryBar : public KateViewBarWidget
104{
105public:
106 explicit KateDictionaryBar(KTextEditor::ViewPrivate *view, QWidget *parent = nullptr);
107 ~KateDictionaryBar() override;
108
109public:
110 void updateData();
111
112protected:
113 void dictionaryChanged(const QString &dictionary);
114
115private:
116 KTextEditor::ViewPrivate *m_view;
117 Sonnet::DictionaryComboBox *m_dictionaryComboBox;
118};
119
120class KateIndentConfigTab : public KateConfigPage
121{
122public:
123 explicit KateIndentConfigTab(QWidget *parent);
124 ~KateIndentConfigTab() override;
125 QString name() const override;
126
127protected:
128 Ui::IndentationConfigWidget *ui;
129
130public:
131 void apply() override;
132 void reload() override;
133 void reset() override
134 {
135 }
136 void defaults() override
137 {
138 }
139
140private:
141 void slotChanged();
142 void showWhatsThis(const QString &text);
143};
144
145class KateCompletionConfigTab : public KateConfigPage
146{
147public:
148 explicit KateCompletionConfigTab(QWidget *parent);
149 ~KateCompletionConfigTab() override;
150 QString name() const override;
151
152protected:
153 Ui::CompletionConfigTab *ui;
154
155public:
156 void apply() override;
157 void reload() override;
158 void reset() override
159 {
160 }
161 void defaults() override
162 {
163 }
164
165private:
166 void showWhatsThis(const QString &text);
167};
168
169class KateEditGeneralConfigTab : public KateConfigPage
170{
171public:
172 explicit KateEditGeneralConfigTab(QWidget *parent);
173 ~KateEditGeneralConfigTab() override;
174 QString name() const override;
175
176private:
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
187public:
188 void apply() override;
189 void reload() override;
190 void reset() override
191 {
192 }
193 void defaults() override
194 {
195 }
196};
197
198class KateNavigationConfigTab : public KateConfigPage
199{
200public:
201 explicit KateNavigationConfigTab(QWidget *parent);
202 ~KateNavigationConfigTab() override;
203 QString name() const override;
204
205private:
206 Ui::NavigationConfigWidget *ui;
207
208 void initMulticursorModifierComboBox();
209
210public:
211 void apply() override;
212 void reload() override;
213 void reset() override
214 {
215 }
216 void defaults() override
217 {
218 }
219};
220
221class KateSpellCheckConfigTab : public KateConfigPage
222{
223public:
224 explicit KateSpellCheckConfigTab(QWidget *parent);
225 ~KateSpellCheckConfigTab() override;
226 QString name() const override;
227
228protected:
229 Ui::SpellCheckConfigWidget *ui;
230 Sonnet::ConfigWidget *m_sonnetConfigWidget;
231
232public:
233 void apply() override;
234 void reload() override;
235 void reset() override
236 {
237 }
238 void defaults() override
239 {
240 }
241
242private:
243 void showWhatsThis(const QString &text);
244};
245
246class KateEditConfigTab : public KateConfigPage
247{
248public:
249 explicit KateEditConfigTab(QWidget *parent);
250 ~KateEditConfigTab() override;
251 QString name() const override;
252 QString fullName() const override;
253 QIcon icon() const override;
254
255public:
256 void apply() override;
257 void reload() override;
258 void reset() override;
259 void defaults() override;
260
261private:
262 KateEditGeneralConfigTab *editConfigTab;
263 KateNavigationConfigTab *navigationConfigTab;
264 KateIndentConfigTab *indentConfigTab;
265 KateCompletionConfigTab *completionConfigTab;
266 KateSpellCheckConfigTab *spellCheckConfigTab;
267 std::vector<KateConfigPage *> m_inputModeConfigTabs;
268};
269
270class KateViewDefaultsConfig : public KateConfigPage
271{
272public:
273 explicit KateViewDefaultsConfig(QWidget *parent);
274 ~KateViewDefaultsConfig() override;
275 QString name() const override;
276 QString fullName() const override;
277 QIcon icon() const override;
278
279public:
280 void apply() override;
281 void reload() override;
282 void reset() override;
283 void defaults() override;
284
285private:
286 Ui::TextareaAppearanceConfigWidget *const textareaUi;
287 Ui::BordersAppearanceConfigWidget *const bordersUi;
288 Ui::StatusbarConfigWidget *const statusBarUi;
289};
290
291class KateSaveConfigTab : public KateConfigPage
292{
293public:
294 explicit KateSaveConfigTab(QWidget *parent);
295 ~KateSaveConfigTab() override;
296 QString name() const override;
297 QString fullName() const override;
298 QIcon icon() const override;
299
300public:
301 void apply() override;
302 void reload() override;
303 void reset() override;
304 void defaults() override;
305 void swapFileModeChanged(int);
306
307protected:
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
315private:
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 */
327class KateModOnHdPrompt : public QObject
328{
329 Q_OBJECT
330public:
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
341Q_SIGNALS:
342 void saveAsTriggered();
343 void ignoreTriggered();
344 void reloadTriggered();
345 void autoReloadTriggered();
346 void closeTriggered();
347
348private Q_SLOTS:
349 /**
350 * Show a diff between the document text and the disk file.
351 */
352 void slotDiff();
353
354private Q_SLOTS:
355 void slotDataAvailable(); ///< read data from the process
356 void slotPDone(); ///< Runs the diff file when done
357
358private:
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

source code of ktexteditor/src/dialogs/katedialogs.h