Custom icons for .zips and .lsa

This commit is contained in:
Abs62 2012-12-03 16:48:06 +04:00
parent dacc4779db
commit 7bbad3e829
2 changed files with 37 additions and 6 deletions

22
lsa.cc
View file

@ -21,6 +21,7 @@
#include <vorbis/vorbisfile.h>
#include <QUrl>
#include <QDir>
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(

View file

@ -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(