diff --git a/hunspell.cc b/hunspell.cc index 8d41a14a..7d7a7113 100644 --- a/hunspell.cc +++ b/hunspell.cc @@ -19,6 +19,7 @@ #include #include "dprintf.hh" #include "fsencoding.hh" +#include namespace HunspellMorpho { @@ -70,9 +71,7 @@ public: protected: - virtual void loadIcon() throw() - { dictionaryIcon = dictionaryNativeIcon = QIcon(":/icons/icon32_hunspell.png"); - dictionaryIconLoaded = true; } + virtual void loadIcon() throw(); private: @@ -109,6 +108,23 @@ bool containsWhitespace( wstring const & str ) return false; } +void HunspellDictionary::loadIcon() throw() +{ + QString fileName = + QDir::fromNativeSeparators( FsEncoding::decode( getDictionaryFilenames()[ 0 ].c_str() ) ); + + // Remove the extension + fileName.chop( 3 ); + + if( !loadIconFromFile( fileName ) ) + { + // Load failed -- use default icons + dictionaryNativeIcon = dictionaryIcon = QIcon(":/icons/icon32_hunspell.png"); + } + + dictionaryIconLoaded = true; +} + /// HunspellDictionary::getArticle() class HunspellArticleRequest;