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 |
22 | * \inheaderfile Sonnet/DictionaryComboBox |
23 | * \inmodule SonnetUi |
24 | * |
25 | * \brief A combo box for selecting the dictionary used for spell checking. |
26 | * \since 4.2 |
27 | **/ |
28 | class SONNETUI_EXPORT DictionaryComboBox : public QComboBox |
29 | { |
30 | Q_OBJECT |
31 | public: |
32 | /*! |
33 | * Constructor |
34 | */ |
35 | explicit DictionaryComboBox(QWidget *parent = nullptr); |
36 | |
37 | ~DictionaryComboBox() override; |
38 | |
39 | /*! |
40 | * Clears the widget and reloads the dictionaries from Sonnet. |
41 | * Remember to set the dictionary you want selected after calling this function. |
42 | */ |
43 | void reloadCombo(); |
44 | |
45 | /*! |
46 | * Returns the current dictionary name, for example "German (Switzerland)" |
47 | */ |
48 | QString currentDictionaryName() const; |
49 | |
50 | /*! |
51 | * Returns the current dictionary, for example "de_CH" |
52 | */ |
53 | QString currentDictionary() const; |
54 | |
55 | /*! |
56 | * Sets the current dictionaryName to the given dictionaryName |
57 | */ |
58 | void setCurrentByDictionaryName(const QString &dictionaryName); |
59 | |
60 | // TODO merge with previous method in kf6 |
61 | /*! |
62 | * Sets the current dictionary to the given dictionary |
63 | * Return true if dictionary was found. |
64 | * \since 5.40 |
65 | */ |
66 | bool assignByDictionnary(const QString &dictionary); |
67 | |
68 | // TODO merge with previous method in kf6 |
69 | /*! |
70 | * Sets the current dictionaryName to the given dictionaryName |
71 | * Return true if dictionary was found. |
72 | * \since 5.40 |
73 | */ |
74 | bool assignDictionnaryName(const QString &name); |
75 | |
76 | /*! |
77 | * Sets the current dictionary to the given dictionary. |
78 | */ |
79 | void setCurrentByDictionary(const QString &dictionary); |
80 | |
81 | Q_SIGNALS: |
82 | /*! |
83 | * Emitted whenever the current dictionary changes. Either |
84 | * by user intervention or on setCurrentByDictionaryName() or on |
85 | * setCurrentByDictionary(). For example "de_CH". |
86 | */ |
87 | void dictionaryChanged(const QString &dictionary); |
88 | |
89 | /*! |
90 | * Emitted whenever the current dictionary changes. Either |
91 | * by user intervention or on setCurrentByDictionaryName() or on |
92 | * setCurrentByDictionary(). For example "German (Switzerland)". |
93 | */ |
94 | void dictionaryNameChanged(const QString &dictionaryName); |
95 | |
96 | private: |
97 | std::unique_ptr<DictionaryComboBoxPrivate> const d; |
98 | Q_PRIVATE_SLOT(d, void slotDictionaryChanged(int)) |
99 | }; |
100 | } |
101 | |
102 | #endif |
103 | |