mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-23 20:14:05 +00:00
Add SLOB dictionaries support
This commit is contained in:
parent
8075fd04b2
commit
0912df7cb5
|
@ -37,7 +37,7 @@ Alternatively, you might want to load `goldendict.pro` file from within Qt Creat
|
|||
|
||||
### Building with Zim dictionaries support
|
||||
|
||||
To add Zim format support you need at first install lzma-dev package:
|
||||
To add Zim and Slob formats support you need at first install lzma-dev package:
|
||||
|
||||
sudo apt-get liblzma-dev
|
||||
|
||||
|
|
|
@ -82,7 +82,8 @@ int res;
|
|||
|
||||
#define BUFSIZE 0xFFFF
|
||||
|
||||
string decompressLzma2( const char * bufptr, unsigned length )
|
||||
string decompressLzma2( const char * bufptr, unsigned length,
|
||||
bool raw_decoder )
|
||||
{
|
||||
string str;
|
||||
lzma_ret res;
|
||||
|
@ -92,9 +93,25 @@ char buf[BUFSIZE];
|
|||
strm.next_in = reinterpret_cast< const uint8_t * >( bufptr );
|
||||
strm.avail_in = length;
|
||||
|
||||
lzma_options_lzma opt;
|
||||
lzma_filter filters[ 2 ];
|
||||
|
||||
if( raw_decoder )
|
||||
{
|
||||
lzma_lzma_preset(&opt, LZMA_PRESET_DEFAULT);
|
||||
|
||||
filters[ 0 ].id = LZMA_FILTER_LZMA2;
|
||||
filters[ 0 ].options = &opt;
|
||||
filters[ 1 ].id = LZMA_VLI_UNKNOWN;
|
||||
}
|
||||
|
||||
while( 1 )
|
||||
{
|
||||
res = lzma_stream_decoder( &strm, UINT64_MAX, 0 );
|
||||
if( raw_decoder )
|
||||
res = lzma_raw_decoder( &strm, filters );
|
||||
else
|
||||
res = lzma_stream_decoder( &strm, UINT64_MAX, 0 );
|
||||
|
||||
if( res != LZMA_OK )
|
||||
break;
|
||||
|
||||
|
|
|
@ -14,7 +14,8 @@ string decompressBzip2( const char * bufptr, unsigned length );
|
|||
|
||||
#ifdef MAKE_ZIM_SUPPORT
|
||||
|
||||
string decompressLzma2( const char * bufptr, unsigned length );
|
||||
string decompressLzma2( const char * bufptr, unsigned length,
|
||||
bool raw_decoder = false );
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -293,7 +293,8 @@ HEADERS += folding.hh \
|
|||
fulltextsearch.hh \
|
||||
ftshelpers.hh \
|
||||
dictserver.hh \
|
||||
helpwindow.hh
|
||||
helpwindow.hh \
|
||||
slob.hh
|
||||
|
||||
FORMS += groups.ui \
|
||||
dictgroupwidget.ui \
|
||||
|
@ -311,6 +312,7 @@ FORMS += groups.ui \
|
|||
dictheadwords.ui \
|
||||
authentication.ui \
|
||||
fulltextsearch.ui
|
||||
|
||||
SOURCES += folding.cc \
|
||||
main.cc \
|
||||
dictionary.cc \
|
||||
|
@ -414,7 +416,8 @@ SOURCES += folding.cc \
|
|||
fulltextsearch.cc \
|
||||
ftshelpers.cc \
|
||||
dictserver.cc \
|
||||
helpwindow.cc
|
||||
helpwindow.cc \
|
||||
slob.cc
|
||||
|
||||
win32 {
|
||||
FORMS += texttospeechsource.ui
|
||||
|
|
Binary file not shown.
Binary file not shown.
BIN
icons/icon32_slob.png
Normal file
BIN
icons/icon32_slob.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.6 KiB |
|
@ -29,6 +29,7 @@
|
|||
#include "mdx.hh"
|
||||
#include "zim.hh"
|
||||
#include "dictserver.hh"
|
||||
#include "slob.hh"
|
||||
|
||||
#ifndef NO_EPWING_SUPPORT
|
||||
#include "epwing.hh"
|
||||
|
@ -58,7 +59,7 @@ LoadDictionaries::LoadDictionaries( Config::Class const & cfg ):
|
|||
<< "*.xdxf.dz" << "*.dct" << "*.aar" << "*.zips"
|
||||
<< "*.mdx"
|
||||
#ifdef MAKE_ZIM_SUPPORT
|
||||
<< "*.zim" << "*.zimaa"
|
||||
<< "*.zim" << "*.zimaa" << "*.slob"
|
||||
#endif
|
||||
#ifndef NO_EPWING_SUPPORT
|
||||
<< "*catalogs"
|
||||
|
@ -207,6 +208,13 @@ void LoadDictionaries::handlePath( Config::Path const & path )
|
|||
dictionaries.insert( dictionaries.end(), zimDictionaries.begin(),
|
||||
zimDictionaries.end() );
|
||||
}
|
||||
{
|
||||
vector< sptr< Dictionary::Class > > slobDictionaries =
|
||||
Slob::makeDictionaries( allFiles, FsEncoding::encode( Config::getIndexDir() ), *this );
|
||||
|
||||
dictionaries.insert( dictionaries.end(), slobDictionaries.begin(),
|
||||
slobDictionaries.end() );
|
||||
}
|
||||
#endif
|
||||
#ifndef NO_EPWING_SUPPORT
|
||||
{
|
||||
|
|
|
@ -294,12 +294,14 @@ Preferences::Preferences( QWidget * parent, Config::Class & cfg_ ):
|
|||
ui.allowDSL->setChecked( !p.fts.disabledTypes.contains( "DSL", Qt::CaseInsensitive ) );
|
||||
ui.allowMDict->setChecked( !p.fts.disabledTypes.contains( "MDICT", Qt::CaseInsensitive ) );
|
||||
ui.allowSDict->setChecked( !p.fts.disabledTypes.contains( "SDICT", Qt::CaseInsensitive ) );
|
||||
ui.allowSlob->setChecked( !p.fts.disabledTypes.contains( "SLOB", Qt::CaseInsensitive ) );
|
||||
ui.allowStardict->setChecked( !p.fts.disabledTypes.contains( "STARDICT", Qt::CaseInsensitive ) );
|
||||
ui.allowXDXF->setChecked( !p.fts.disabledTypes.contains( "XDXF", Qt::CaseInsensitive ) );
|
||||
ui.allowZim->setChecked( !p.fts.disabledTypes.contains( "ZIM", Qt::CaseInsensitive ) );
|
||||
ui.allowEpwing->setChecked( !p.fts.disabledTypes.contains( "EPWING", Qt::CaseInsensitive ) );
|
||||
#ifndef MAKE_ZIM_SUPPORT
|
||||
ui.allowZim->hide();
|
||||
ui.allowSlob->hide();
|
||||
#endif
|
||||
#ifdef NO_EPWING_SUPPORT
|
||||
ui.allowEpwing->hide();
|
||||
|
@ -441,6 +443,13 @@ Config::Preferences Preferences::getPreferences()
|
|||
p.fts.disabledTypes += "SDICT";
|
||||
}
|
||||
|
||||
if( !ui.allowSlob->isChecked() )
|
||||
{
|
||||
if( !p.fts.disabledTypes.isEmpty() )
|
||||
p.fts.disabledTypes += ',';
|
||||
p.fts.disabledTypes += "SLOB";
|
||||
}
|
||||
|
||||
if( !ui.allowStardict->isChecked() )
|
||||
{
|
||||
if( !p.fts.disabledTypes.isEmpty() )
|
||||
|
|
|
@ -1240,13 +1240,20 @@ download page.</string>
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<item row="5" column="0">
|
||||
<widget class="QCheckBox" name="allowSDict">
|
||||
<property name="text">
|
||||
<string notr="true">SDict</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QCheckBox" name="allowSlob">
|
||||
<property name="text">
|
||||
<string notr="true">Slob</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QCheckBox" name="allowStardict">
|
||||
<property name="text">
|
||||
|
@ -1268,7 +1275,7 @@ download page.</string>
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0" colspan="2">
|
||||
<item row="6" column="0" colspan="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_14">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_14">
|
||||
|
|
|
@ -78,5 +78,6 @@
|
|||
<file>icons/playsound_full.png</file>
|
||||
<file>icons/icon32_zim.png</file>
|
||||
<file>icons/icon32_epwing.png</file>
|
||||
<file>icons/icon32_slob.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
24
slob.hh
Normal file
24
slob.hh
Normal file
|
@ -0,0 +1,24 @@
|
|||
#ifndef __SLOB_HH_INCLUDED__
|
||||
#define __SLOB_HH_INCLUDED__
|
||||
|
||||
#ifdef MAKE_ZIM_SUPPORT
|
||||
|
||||
#include "dictionary.hh"
|
||||
|
||||
/// Support for the Slob dictionaries.
|
||||
namespace Slob {
|
||||
|
||||
using std::vector;
|
||||
using std::string;
|
||||
|
||||
vector< sptr< Dictionary::Class > > makeDictionaries(
|
||||
vector< string > const & fileNames,
|
||||
string const & indicesDir,
|
||||
Dictionary::Initializing & )
|
||||
throw( std::exception );
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif // __SLOB_HH_INCLUDED__
|
Loading…
Reference in a new issue