1 | /* |
2 | * SPDX-FileCopyrightText: 2003 Ingo Kloecker <kloecker@kde.org> |
3 | * SPDX-FileCopyrightText: 2008 Tom Albers <tomalbers@kde.nl> |
4 | * |
5 | * SPDX-License-Identifier: LGPL-2.1-or-later |
6 | */ |
7 | |
8 | #ifndef SONNET_DICTIONARYCOMBOBOX_H |
9 | #define SONNET_DICTIONARYCOMBOBOX_H |
10 | |
11 | #include "sonnetui_export.h" |
12 | |
13 | #include <QComboBox> |
14 | |
15 | #include <memory> |
16 | |
17 | namespace Sonnet |
18 | { |
19 | class DictionaryComboBoxPrivate; |
20 | /** |
21 | * @class Sonnet::DictionaryComboBox dictionarycombobox.h <Sonnet/DictionaryComboBox> |
22 | * |
23 | * @short A combo box for selecting the dictionary used for spell checking. |
24 | * @author Ingo Kloecker <kloecker@kde.org> |
25 | * @author Tom Albers <tomalbers@kde.nl> |
26 | * @since 4.2 |
27 | **/ |
28 | |
29 | class SONNETUI_EXPORT DictionaryComboBox : public QComboBox |
30 | { |
31 | Q_OBJECT |
32 | public: |
33 | /** |
34 | * Constructor |
35 | */ |
36 | explicit DictionaryComboBox(QWidget *parent = nullptr); |
37 | |
38 | /** |
39 | * Destructor |
40 | */ |
41 | ~DictionaryComboBox() override; |
42 | |
43 | /** |
44 | * Clears the widget and reloads the dictionaries from Sonnet. |
45 | * Remember to set the dictionary you want selected after calling this function. |
46 | */ |
47 | void reloadCombo(); |
48 | |
49 | /** |
50 | * Returns the current dictionary name, for example "German (Switzerland)" |
51 | */ |
52 | QString currentDictionaryName() const; |
53 | |
54 | /** |
55 | * Returns the current dictionary, for example "de_CH" |
56 | */ |
57 | QString currentDictionary() const; |
58 | |
59 | /** |
60 | * Sets the current dictionaryName to the given dictionaryName |
61 | */ |
62 | void setCurrentByDictionaryName(const QString &dictionaryName); |
63 | |
64 | /** |
65 | * Sets the current dictionary to the given dictionary |
66 | * Return true if dictionary was found. |
67 | * @since 5.40 |
68 | * TODO merge with previous method in kf6 |
69 | */ |
70 | bool assignByDictionnary(const QString &dictionary); |
71 | |
72 | /** |
73 | * Sets the current dictionaryName to the given dictionaryName |
74 | * Return true if dictionary was found. |
75 | * @since 5.40 |
76 | * TODO merge with previous method in kf6 |
77 | */ |
78 | bool assignDictionnaryName(const QString &name); |
79 | |
80 | /** |
81 | * Sets the current dictionary to the given dictionary. |
82 | */ |
83 | void setCurrentByDictionary(const QString &dictionary); |
84 | |
85 | Q_SIGNALS: |
86 | /** |
87 | * @em Emitted whenever the current dictionary changes. Either |
88 | * by user intervention or on setCurrentByDictionaryName() or on |
89 | * setCurrentByDictionary(). For example "de_CH". |
90 | */ |
91 | void dictionaryChanged(const QString &dictionary); |
92 | |
93 | /** |
94 | * @em Emitted whenever the current dictionary changes. Either |
95 | * by user intervention or on setCurrentByDictionaryName() or on |
96 | * setCurrentByDictionary(). For example "German (Switzerland)". |
97 | */ |
98 | void dictionaryNameChanged(const QString &dictionaryName); |
99 | |
100 | private: |
101 | std::unique_ptr<DictionaryComboBoxPrivate> const d; |
102 | Q_PRIVATE_SLOT(d, void slotDictionaryChanged(int)) |
103 | }; |
104 | } |
105 | |
106 | #endif |
107 | |