Sonnet

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

KDE's Doxygen guidelines are available online.