From df168920e57a46fb347abde3095590dcf5d0421c Mon Sep 17 00:00:00 2001 From: Montel Laurent Date: Mon, 30 Oct 2017 13:57:30 +0100 Subject: [PATCH] Inform when we can"t set dictionary --- src/editor/kmcomposerwin.cpp | 9 ++++++++- .../incorrectidentityfolderwarning.cpp | 13 +++++++++++++ .../warningwidgets/incorrectidentityfolderwarning.h | 2 ++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/editor/kmcomposerwin.cpp b/src/editor/kmcomposerwin.cpp index 533d8dfd6..209787b6f 100644 --- a/src/editor/kmcomposerwin.cpp +++ b/src/editor/kmcomposerwin.cpp @@ -71,6 +71,7 @@ #include "kmcomposerglobalaction.h" #include "widgets/kactionmenutransport.h" #include "pimcommon/kactionmenuchangecase.h" +#include "sonnet_version.h" #include #include @@ -1606,7 +1607,13 @@ void KMComposerWin::setMessage(const KMime::Message::Ptr &newMsg, bool lastSignS if (auto hdr = mMsg->headerByType("X-KMail-Dictionary")) { const QString dictionary = hdr->asUnicodeString(); if (!dictionary.isEmpty()) { - mComposerBase->dictionary()->setCurrentByDictionary(dictionary); + if (SONNET_VERSION_MINOR >= 40) { + if (!mComposerBase->dictionary()->assignDictionnaryName(dictionary)) { + mIncorrectIdentityFolderWarning->dictionaryInvalid(); + } + } else { + mComposerBase->dictionary()->setCurrentByDictionary(dictionary); + } } } else { mComposerBase->dictionary()->setCurrentByDictionaryName(ident.dictionary()); diff --git a/src/editor/warningwidgets/incorrectidentityfolderwarning.cpp b/src/editor/warningwidgets/incorrectidentityfolderwarning.cpp index 3c500175d..a41d9e977 100644 --- a/src/editor/warningwidgets/incorrectidentityfolderwarning.cpp +++ b/src/editor/warningwidgets/incorrectidentityfolderwarning.cpp @@ -52,6 +52,12 @@ void IncorrectIdentityFolderWarning::identityInvalid() updateText(); } +void IncorrectIdentityFolderWarning::dictionaryInvalid() +{ + mDictionaryIsInvalid = true; + updateText(); +} + void IncorrectIdentityFolderWarning::updateText() { QString text; @@ -70,6 +76,12 @@ void IncorrectIdentityFolderWarning::updateText() } text += i18n("Identity was not found. Please verify that you will use a correct identity."); } + if (mDictionaryIsInvalid) { + if (!text.isEmpty()) { + text += QLatin1Char('\n'); + } + text += i18n("Dictionary was not found. Please verify that you will use a correct dictionnary."); + } setText(text); animatedShow(); } @@ -79,4 +91,5 @@ void IncorrectIdentityFolderWarning::slotHideAnnimationFinished() mMailTransportIsInvalid = false; mFccIsInvalid = false; mIdentityIsInvalid = false; + mDictionaryIsInvalid = false; } diff --git a/src/editor/warningwidgets/incorrectidentityfolderwarning.h b/src/editor/warningwidgets/incorrectidentityfolderwarning.h index 9f6f2b0de..ee279f8e7 100644 --- a/src/editor/warningwidgets/incorrectidentityfolderwarning.h +++ b/src/editor/warningwidgets/incorrectidentityfolderwarning.h @@ -32,6 +32,7 @@ public: void mailTransportIsInvalid(); void fccIsInvalid(); void identityInvalid(); + void dictionaryInvalid(); private: void updateText(); @@ -39,6 +40,7 @@ private: bool mMailTransportIsInvalid = false; bool mFccIsInvalid = false; bool mIdentityIsInvalid = false; + bool mDictionaryIsInvalid = false; }; #endif // INCORRECTIDENTITYFOLDERWARNING_H