diff --git a/lsa.cc b/lsa.cc index 53d589a3..1c80cd92 100644 --- a/lsa.cc +++ b/lsa.cc @@ -21,6 +21,7 @@ #include #include +#include namespace Lsa { @@ -180,9 +181,7 @@ public: protected: - virtual void loadIcon() throw() - { dictionaryIcon = dictionaryNativeIcon = QIcon(":/icons/playsound.png"); - dictionaryIconLoaded = true; } + virtual void loadIcon() throw(); }; string LsaDictionary::getName() throw() @@ -483,6 +482,23 @@ sptr< Dictionary::DataRequest > LsaDictionary::getResource( string const & name return dr; } +void LsaDictionary::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/playsound.png"); + } + + dictionaryIconLoaded = true; +} + } vector< sptr< Dictionary::Class > > makeDictionaries( diff --git a/zipsounds.cc b/zipsounds.cc index acff0e12..7273137f 100644 --- a/zipsounds.cc +++ b/zipsounds.cc @@ -109,9 +109,7 @@ public: protected: - virtual void loadIcon() throw() - { dictionaryIcon = dictionaryNativeIcon = QIcon(":/icons/playsound.png"); - dictionaryIconLoaded = true; } + virtual void loadIcon() throw(); }; ZipSoundsDictionary::ZipSoundsDictionary( string const & id, @@ -273,6 +271,23 @@ sptr< Dictionary::DataRequest > ZipSoundsDictionary::getResource( string const & return new Dictionary::DataRequestInstant( false ); } +void ZipSoundsDictionary::loadIcon() throw() +{ + QString fileName = + QDir::fromNativeSeparators( FsEncoding::decode( getDictionaryFilenames()[ 0 ].c_str() ) ); + + // Remove the extension + fileName.chop( 4 ); + + if( !loadIconFromFile( fileName ) ) + { + // Load failed -- use default icons + dictionaryNativeIcon = dictionaryIcon = QIcon(":/icons/playsound.png"); + } + + dictionaryIconLoaded = true; +} + } vector< sptr< Dictionary::Class > > makeDictionaries(