From afb4b66e155dd1eb5ed63df4af7f57174d645e5f Mon Sep 17 00:00:00 2001 From: Abs62 Date: Fri, 7 Dec 2012 16:01:39 +0400 Subject: [PATCH] Custom icons for morphology dictionaries --- hunspell.cc | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) 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;