mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-27 15:24:05 +00:00
Add option to enable/disable search via synonyms
This commit is contained in:
parent
a6df1cfb51
commit
fa9d1aecd9
3
bgl.cc
3
bgl.cc
|
@ -596,7 +596,8 @@ sptr< Dictionary::WordSearchRequest >
|
|||
BglDictionary::findHeadwordsForSynonym( wstring const & word )
|
||||
throw( std::exception )
|
||||
{
|
||||
return new BglHeadwordsRequest( word, *this );
|
||||
return synonymSearchEnabled ? new BglHeadwordsRequest( word, *this ) :
|
||||
Class::findHeadwordsForSynonym( word );
|
||||
}
|
||||
|
||||
// Converts a $1$-like postfix to a <sup>1</sup> one
|
||||
|
|
|
@ -135,6 +135,7 @@ Preferences::Preferences():
|
|||
#ifndef Q_WS_X11
|
||||
, trackClipboardChanges( false )
|
||||
#endif
|
||||
, synonymSearchEnabled( true )
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -833,6 +834,9 @@ Class load() throw( exError )
|
|||
c.preferences.trackClipboardChanges = ( preferences.namedItem( "trackClipboardChanges" ).toElement().text() == "1" );
|
||||
#endif
|
||||
|
||||
if ( !preferences.namedItem( "synonymSearchEnabled" ).isNull() )
|
||||
c.preferences.synonymSearchEnabled = ( preferences.namedItem( "synonymSearchEnabled" ).toElement().text() == "1" );
|
||||
|
||||
QDomNode fts = preferences.namedItem( "fullTextSearch" );
|
||||
|
||||
if ( !fts.isNull() )
|
||||
|
@ -1736,6 +1740,11 @@ void save( Class const & c ) throw( exError )
|
|||
opt.appendChild( dd.createTextNode( c.preferences.trackClipboardChanges ? "1" : "0" ) );
|
||||
preferences.appendChild( opt );
|
||||
#endif
|
||||
|
||||
opt = dd.createElement( "synonymSearchEnabled" );
|
||||
opt.appendChild( dd.createTextNode( c.preferences.synonymSearchEnabled ? "1" : "0" ) );
|
||||
preferences.appendChild( opt );
|
||||
|
||||
{
|
||||
QDomNode hd = dd.createElement( "fullTextSearch" );
|
||||
preferences.appendChild( hd );
|
||||
|
|
|
@ -244,6 +244,8 @@ struct Preferences
|
|||
bool trackClipboardChanges;
|
||||
#endif
|
||||
|
||||
bool synonymSearchEnabled;
|
||||
|
||||
QString addonStyle;
|
||||
|
||||
FullTextSearch fts;
|
||||
|
|
|
@ -266,6 +266,7 @@ protected:
|
|||
bool dictionaryIconLoaded;
|
||||
bool can_FTS;
|
||||
QAtomicInt FTS_index_completed;
|
||||
bool synonymSearchEnabled;
|
||||
|
||||
// Load user icon if it exist
|
||||
// By default set icon to empty
|
||||
|
@ -433,6 +434,10 @@ public:
|
|||
virtual bool getHeadwords( QStringList & )
|
||||
{ return false; }
|
||||
|
||||
/// Enable/disable search via synonyms
|
||||
void setSynonymSearchEnabled( bool enabled )
|
||||
{ synonymSearchEnabled = enabled; }
|
||||
|
||||
virtual ~Class()
|
||||
{}
|
||||
};
|
||||
|
|
3
gls.cc
3
gls.cc
|
@ -976,7 +976,8 @@ sptr< Dictionary::WordSearchRequest >
|
|||
GlsDictionary::findHeadwordsForSynonym( wstring const & word )
|
||||
throw( std::exception )
|
||||
{
|
||||
return new GlsHeadwordsRequest( word, *this );
|
||||
return synonymSearchEnabled ? new GlsHeadwordsRequest( word, *this ) :
|
||||
Class::findHeadwordsForSynonym( word );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1209,7 +1209,10 @@ void MainWindow::makeDictionaries()
|
|||
loadDictionaries( this, isVisible(), cfg, dictionaries, dictNetMgr, false );
|
||||
|
||||
for( unsigned x = 0; x < dictionaries.size(); x++ )
|
||||
{
|
||||
dictionaries[ x ]->setFTSParameters( cfg.preferences.fts );
|
||||
dictionaries[ x ]->setSynonymSearchEnabled( cfg.preferences.synonymSearchEnabled );
|
||||
}
|
||||
|
||||
ftsIndexing.setDictionaries( dictionaries );
|
||||
ftsIndexing.doIndexing();
|
||||
|
@ -1906,7 +1909,10 @@ void MainWindow::editDictionaries( unsigned editDictionaryGroup )
|
|||
installHotKeys();
|
||||
|
||||
for( unsigned x = 0; x < dictionaries.size(); x++ )
|
||||
{
|
||||
dictionaries[ x ]->setFTSParameters( cfg.preferences.fts );
|
||||
dictionaries[ x ]->setSynonymSearchEnabled( cfg.preferences.synonymSearchEnabled );
|
||||
}
|
||||
|
||||
ftsIndexing.setDictionaries( dictionaries );
|
||||
ftsIndexing.doIndexing();
|
||||
|
@ -2025,7 +2031,10 @@ void MainWindow::editPreferences()
|
|||
ui.historyPaneWidget->updateHistoryCounts();
|
||||
|
||||
for( unsigned x = 0; x < dictionaries.size(); x++ )
|
||||
{
|
||||
dictionaries[ x ]->setFTSParameters( cfg.preferences.fts );
|
||||
dictionaries[ x ]->setSynonymSearchEnabled( cfg.preferences.synonymSearchEnabled );
|
||||
}
|
||||
|
||||
ui.fullTextSearchAction->setEnabled( cfg.preferences.fts.enabled );
|
||||
|
||||
|
@ -3390,7 +3399,10 @@ void MainWindow::on_rescanFiles_triggered()
|
|||
loadDictionaries( this, true, cfg, dictionaries, dictNetMgr );
|
||||
|
||||
for( unsigned x = 0; x < dictionaries.size(); x++ )
|
||||
{
|
||||
dictionaries[ x ]->setFTSParameters( cfg.preferences.fts );
|
||||
dictionaries[ x ]->setSynonymSearchEnabled( cfg.preferences.synonymSearchEnabled );
|
||||
}
|
||||
|
||||
ftsIndexing.setDictionaries( dictionaries );
|
||||
ftsIndexing.doIndexing();
|
||||
|
|
|
@ -197,6 +197,8 @@ Preferences::Preferences( QWidget * parent, Config::Class & cfg_ ):
|
|||
ui.collapseBigArticles->setChecked( p.collapseBigArticles );
|
||||
ui.articleSizeLimit->setValue( p.articleSizeLimit );
|
||||
|
||||
ui.synonymSearchEnabled->setChecked( p.synonymSearchEnabled );
|
||||
|
||||
ui.maxDictsInContextMenu->setValue( p.maxDictionaryRefsInContextMenu );
|
||||
|
||||
// Different platforms have different keys available
|
||||
|
@ -373,6 +375,8 @@ Config::Preferences Preferences::getPreferences()
|
|||
p.collapseBigArticles = ui.collapseBigArticles->isChecked();
|
||||
p.articleSizeLimit = ui.articleSizeLimit->text().toInt();
|
||||
|
||||
p.synonymSearchEnabled = ui.synonymSearchEnabled->isChecked();
|
||||
|
||||
p.maxDictionaryRefsInContextMenu = ui.maxDictsInContextMenu->text().toInt();
|
||||
|
||||
p.pronounceOnLoadMain = ui.pronounceOnLoadMain->isChecked();
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>636</width>
|
||||
<height>403</height>
|
||||
<height>427</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
@ -1285,7 +1285,7 @@ download page.</string>
|
|||
<item row="5" column="1">
|
||||
<widget class="QCheckBox" name="allowGls">
|
||||
<property name="text">
|
||||
<string notr="true">Gls</string>
|
||||
<string notr="true">GLS</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -1580,6 +1580,17 @@ It is not needed to select this option if you don't use such programs.</string>
|
|||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="synonymSearchEnabled">
|
||||
<property name="toolTip">
|
||||
<string>Turn this option on to enable extra articles search via synonym lists
|
||||
from Stardict, Babylon and GLS dictionaries</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Extra search via synonyms</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_17">
|
||||
<property name="orientation">
|
||||
|
|
|
@ -1106,7 +1106,8 @@ sptr< Dictionary::WordSearchRequest >
|
|||
StardictDictionary::findHeadwordsForSynonym( wstring const & word )
|
||||
throw( std::exception )
|
||||
{
|
||||
return new StardictHeadwordsRequest( word, *this );
|
||||
return synonymSearchEnabled ? new StardictHeadwordsRequest( word, *this ) :
|
||||
Class::findHeadwordsForSynonym( word );
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue