Changeset View
Changeset View
Standalone View
Standalone View
src/ui/dictionarycombobox.cpp
Show All 13 Lines | |||||
14 | * | 14 | * | ||
15 | * You should have received a copy of the GNU Lesser General Public | 15 | * You should have received a copy of the GNU Lesser General Public | ||
16 | * License along with this library; if not, write to the Free Software | 16 | * License along with this library; if not, write to the Free Software | ||
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | ||
18 | * 02110-1301 USA | 18 | * 02110-1301 USA | ||
19 | */ | 19 | */ | ||
20 | 20 | | |||
21 | #include "dictionarycombobox.h" | 21 | #include "dictionarycombobox.h" | ||
22 | #include "loader_p.h" | ||||
23 | | ||||
24 | #include <QMessageBox> | ||||
22 | 25 | | |||
23 | #include <speller.h> | 26 | #include <speller.h> | ||
24 | #include "ui_debug.h" | 27 | #include "ui_debug.h" | ||
25 | 28 | | |||
26 | namespace Sonnet { | 29 | namespace Sonnet { | ||
27 | //@cond PRIVATE | 30 | //@cond PRIVATE | ||
28 | class DictionaryComboBoxPrivate | 31 | class DictionaryComboBoxPrivate | ||
29 | { | 32 | { | ||
30 | public: | 33 | public: | ||
31 | explicit DictionaryComboBoxPrivate(DictionaryComboBox *combo) : q(combo) | 34 | explicit DictionaryComboBoxPrivate(DictionaryComboBox *combo) : q(combo) | ||
32 | { | 35 | { | ||
33 | } | 36 | } | ||
34 | 37 | | |||
35 | DictionaryComboBox *q; | 38 | DictionaryComboBox *q; | ||
36 | void slotDictionaryChanged(int idx); | 39 | void slotDictionaryChanged(int idx); | ||
40 | bool dictionaryErrorShown = false; | ||||
37 | }; | 41 | }; | ||
38 | 42 | | |||
39 | void DictionaryComboBoxPrivate::slotDictionaryChanged(int idx) | 43 | void DictionaryComboBoxPrivate::slotDictionaryChanged(int idx) | ||
40 | { | 44 | { | ||
41 | emit q->dictionaryChanged(q->itemData(idx).toString()); | 45 | emit q->dictionaryChanged(q->itemData(idx).toString()); | ||
42 | emit q->dictionaryNameChanged(q->itemText(idx)); | 46 | emit q->dictionaryNameChanged(q->itemText(idx)); | ||
43 | } | 47 | } | ||
44 | 48 | | |||
45 | //@endcon | 49 | //@endcon | ||
46 | 50 | | |||
47 | DictionaryComboBox::DictionaryComboBox(QWidget *parent) | 51 | DictionaryComboBox::DictionaryComboBox(QWidget *parent) | ||
48 | : QComboBox(parent) | 52 | : QComboBox(parent) | ||
49 | , d(new DictionaryComboBoxPrivate(this)) | 53 | , d(new DictionaryComboBoxPrivate(this)) | ||
50 | { | 54 | { | ||
55 | connect(Loader::openLoader(), &Loader::loadingDictionaryFailed, | ||||
56 | this, &DictionaryComboBox::slotLoadingDictionaryFailed); | ||||
51 | reloadCombo(); | 57 | reloadCombo(); | ||
52 | connect(this, SIGNAL(activated(int)), | 58 | connect(this, SIGNAL(activated(int)), | ||
53 | SLOT(slotDictionaryChanged(int))); | 59 | SLOT(slotDictionaryChanged(int))); | ||
54 | } | 60 | } | ||
55 | 61 | | |||
56 | DictionaryComboBox::~DictionaryComboBox() | 62 | DictionaryComboBox::~DictionaryComboBox() | ||
57 | { | 63 | { | ||
58 | delete d; | 64 | delete d; | ||
▲ Show 20 Lines • Show All 76 Lines • ▼ Show 20 Line(s) | 140 | while (i.hasNext()) { | |||
135 | i.next(); | 141 | i.next(); | ||
136 | if (preferredDictionaries.contains(i.key())) { | 142 | if (preferredDictionaries.contains(i.key())) { | ||
137 | continue; | 143 | continue; | ||
138 | } | 144 | } | ||
139 | addItem(i.key(), i.value()); | 145 | addItem(i.key(), i.value()); | ||
140 | } | 146 | } | ||
141 | } | 147 | } | ||
142 | 148 | | |||
149 | void DictionaryComboBox::slotLoadingDictionaryFailed(const QString &lang) | ||||
150 | { | ||||
151 | if (!d->dictionaryErrorShown) { | ||||
152 | QMessageBox::warning(nullptr, | ||||
153 | tr("Spell Checker"), | ||||
154 | tr("No dictionaries for language: \"%1\" could be loaded.\n" | ||||
155 | "Please check the spell checker configuration.\n").arg(lang)); | ||||
156 | d->dictionaryErrorShown = true; | ||||
157 | } | ||||
158 | } | ||||
159 | | ||||
143 | } // namespace Sonnet | 160 | } // namespace Sonnet | ||
144 | 161 | | |||
145 | #include "moc_dictionarycombobox.cpp" | 162 | #include "moc_dictionarycombobox.cpp" |