Sonnet

dialog.h
1 /*
2  * dialog.h
3  *
4  * SPDX-FileCopyrightText: 2003 Zack Rusin <[email protected]>
5  * SPDX-FileCopyrightText: 2009-2010 Michel Ludwig <[email protected]>
6  *
7  * SPDX-License-Identifier: LGPL-2.1-or-later
8  */
9 #ifndef SONNET_DIALOG_H
10 #define SONNET_DIALOG_H
11 
12 #include "sonnetui_export.h"
13 #include <QDialog>
14 
15 class QModelIndex;
16 
17 namespace Sonnet
18 {
19 class BackgroundChecker;
20 class DialogPrivate;
21 /**
22  * @class Sonnet::Dialog dialog.h <Sonnet/Dialog>
23  *
24  * @short Spellcheck dialog
25  *
26  * \code
27  * Sonnet::Dialog dlg = new Sonnet::Dialog(
28  * new Sonnet::BackgroundChecker(this), this);
29  * //connect signals
30  * ...
31  * dlg->setBuffer( someText );
32  * dlg->show();
33  * \endcode
34  *
35  * You can change buffer inside a slot connected to done() signal
36  * and spellcheck will continue with new data automatically.
37  */
38 class SONNETUI_EXPORT Dialog : public QDialog
39 {
40  Q_OBJECT
41 public:
42  Dialog(BackgroundChecker *checker, QWidget *parent);
43  ~Dialog() override;
44 
45  QString originalBuffer() const;
46  QString buffer() const;
47 
48  void show();
49  void activeAutoCorrect(bool _active);
50 
51  // Hide warning about done(), which is a slot in QDialog and a signal here.
52  using QDialog::done;
53 
54  /**
55  * Controls whether an (indefinite) progress dialog is shown when the spell
56  * checking takes longer than the given time to complete. By default no
57  * progress dialog is shown. If the progress dialog is set to be shown, no
58  * time consuming operation (for example, showing a notification message) should
59  * be performed in a slot connected to the 'done' signal as this might trigger
60  * the progress dialog unnecessarily.
61  *
62  * @param timeout time after which the progress dialog should appear; a negative
63  * value can be used to hide it
64  * @since 4.4
65  */
66  void showProgressDialog(int timeout = 500);
67 
68  /**
69  * Controls whether a message box indicating the completion of the spell checking
70  * is shown or not. By default it is not shown.
71  *
72  * @since 4.4
73  */
74  void showSpellCheckCompletionMessage(bool b = true);
75 
76  /**
77  * Controls whether the spell checking is continued after the replacement of a
78  * misspelled word has been performed. By default it is continued.
79  *
80  * @since 4.4
81  */
82  void setSpellCheckContinuedAfterReplacement(bool b);
83 
84 public Q_SLOTS:
85  void setBuffer(const QString &);
86 
87 Q_SIGNALS:
88 #if SONNETUI_ENABLE_DEPRECATED_SINCE(5, 65)
89  /**
90  * The dialog won't be closed if you setBuffer() in slot connected to this signal
91  * Also emitted after stop() signal
92  * @deprecated Since 5.65, use spellCheckDone
93  */
94  SONNETUI_DEPRECATED_VERSION(5, 65, "Use Dialog::spellCheckDone()")
95  void done(const QString &newBuffer); // clazy:exclude=overloaded-signal
96 #endif
97  /**
98  * The dialog won't be closed if you setBuffer() in slot connected to this signal
99  * Also emitted after stop() signal
100  * @Since 5.65
101  */
102  void spellCheckDone(const QString &newBuffer);
103  void misspelling(const QString &word, int start);
104  void replace(const QString &oldWord, int start, const QString &newWord);
105 
106  void stop();
107  void cancel();
108  void autoCorrect(const QString &currentWord, const QString &replaceWord);
109 
110  /**
111  * Signal sends when spell checking is finished/stopped/completed
112  * @since 4.1
113  */
114  void spellCheckStatus(const QString &);
115 
116  /**
117  * Emitted when the user changes the language used for spellchecking,
118  * which is shown in a combobox of this dialog.
119  *
120  * @param dictionary the new language the user selected
121  * @since 4.1
122  */
123  void languageChanged(const QString &language);
124 
125 private Q_SLOTS:
126  void slotMisspelling(const QString &word, int start);
127  void slotDone();
128 
129  void slotFinished();
130  void slotCancel();
131 
132  void slotAddWord();
133  void slotReplaceWord();
134  void slotReplaceAll();
135  void slotSkip();
136  void slotSkipAll();
137  void slotSuggest();
138  void slotChangeLanguage(const QString &);
139  void slotSelectionChanged(const QModelIndex &);
140  void slotAutocorrect();
141 
142  void setGuiEnabled(bool b);
143  void setProgressDialogVisible(bool b);
144 
145 private:
146  void updateDialog(const QString &word);
147  void fillDictionaryComboBox();
148  void updateDictionaryComboBox();
149  void fillSuggestions(const QStringList &suggs);
150  void initConnections();
151  void initGui();
152  void continueChecking();
153 
154 private:
155  DialogPrivate *const d;
156  Q_DISABLE_COPY(Dialog)
157 };
158 }
159 
160 #endif
class used for spell checking in the background
void stop(Ekos::AlignState mode)
Q_SCRIPTABLE Q_NOREPLY void start()
virtual void done(int r)
The sonnet namespace.
Spellcheck dialog.
Definition: dialog.h:38
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Wed Sep 28 2022 04:06:04 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.