Changeset View
Changeset View
Standalone View
Standalone View
src/core/loader.cpp
Show All 24 Lines | |||||
25 | 25 | | |||
26 | #include <QHash> | 26 | #include <QHash> | ||
27 | #include <QMap> | 27 | #include <QMap> | ||
28 | #include <QLocale> | 28 | #include <QLocale> | ||
29 | #include <QCoreApplication> | 29 | #include <QCoreApplication> | ||
30 | #include <QPluginLoader> | 30 | #include <QPluginLoader> | ||
31 | #include "core_debug.h" | 31 | #include "core_debug.h" | ||
32 | #include <QDir> | 32 | #include <QDir> | ||
33 | #include <QMessageBox> | ||||
33 | 34 | | |||
34 | #include <algorithm> | 35 | #include <algorithm> | ||
35 | 36 | | |||
36 | #ifdef SONNET_STATIC | 37 | #ifdef SONNET_STATIC | ||
37 | #include "../plugins/hunspell/hunspellclient.h" | 38 | #include "../plugins/hunspell/hunspellclient.h" | ||
38 | #ifdef Q_OS_MACOS | 39 | #ifdef Q_OS_MACOS | ||
39 | #include "../plugins/nsspellchecker/nsspellcheckerclient.h" | 40 | #include "../plugins/nsspellchecker/nsspellcheckerclient.h" | ||
40 | #endif | 41 | #endif | ||
Show All 40 Lines | 78 | { | |||
81 | delete d; | 82 | delete d; | ||
82 | } | 83 | } | ||
83 | 84 | | |||
84 | SpellerPlugin *Loader::createSpeller(const QString &language, const QString &clientName) const | 85 | SpellerPlugin *Loader::createSpeller(const QString &language, const QString &clientName) const | ||
85 | { | 86 | { | ||
86 | QString backend = clientName; | 87 | QString backend = clientName; | ||
87 | QString plang = language; | 88 | QString plang = language; | ||
88 | 89 | | |||
90 | const QString &defaultLang = d->settings->defaultLanguage(); | ||||
89 | if (plang.isEmpty()) { | 91 | if (plang.isEmpty()) { | ||
90 | plang = d->settings->defaultLanguage(); | 92 | plang = defaultLang; | ||
91 | } | 93 | } | ||
92 | const QVector<Client *> lClients = d->languageClients[plang]; | 94 | const QVector<Client *> lClients = d->languageClients[plang]; | ||
93 | 95 | | |||
94 | if (lClients.isEmpty()) { | 96 | if (lClients.isEmpty()) { | ||
95 | qCWarning(SONNET_LOG_CORE) << "No language dictionaries for the language:" << plang; | 97 | if (plang == defaultLang) { | ||
98 | const QString localeLang = QLocale::system().name(); | ||||
99 | if (d->settings->setDefaultLanguage(localeLang)) { | ||||
100 | d->settings->save(); | ||||
101 | QMessageBox::information(nullptr, | ||||
102 | tr("Spell Checker"), | ||||
103 | tr("No dictionaries for language: \"%1\" could be loaded.\n" | ||||
104 | "The default dictionary has been reset to the system locale: \"%2\"").arg(plang).arg(localeLang)); | ||||
105 | } else { | ||||
106 | qCWarning(SONNET_LOG_CORE) << "No language dictionaries for language:" << plang << "or locale language:" << localeLang; | ||||
96 | return nullptr; | 107 | return nullptr; | ||
97 | } | 108 | } | ||
109 | } else { | ||||
110 | qCWarning(SONNET_LOG_CORE) << "No language dictionaries for language:" << plang; | ||||
111 | return nullptr; | ||||
112 | } | ||||
113 | } | ||||
98 | 114 | | |||
99 | if (backend.isEmpty()) { | 115 | if (backend.isEmpty()) { | ||
100 | backend = d->settings->defaultClient(); | 116 | backend = d->settings->defaultClient(); | ||
101 | if (!backend.isEmpty()) { | 117 | if (!backend.isEmpty()) { | ||
102 | // check if the default client supports the requested language; | 118 | // check if the default client supports the requested language; | ||
103 | // if it does it will be an element of lClients. | 119 | // if it does it will be an element of lClients. | ||
104 | bool unknown = !std::any_of(lClients.constBegin(), lClients.constEnd(), [backend] (const Client *client) { | 120 | bool unknown = !std::any_of(lClients.constBegin(), lClients.constEnd(), [backend] (const Client *client) { | ||
105 | return client->name() == backend; }); | 121 | return client->name() == backend; }); | ||
▲ Show 20 Lines • Show All 255 Lines • Show Last 20 Lines |