mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-27 23:34:06 +00:00
*! Another fix to complete the previous commit.
This commit is contained in:
parent
2a81429d0a
commit
91c97256d3
|
@ -37,11 +37,11 @@ EditDictionaries::EditDictionaries( QWidget * parent, Config::Class & cfg_,
|
||||||
|
|
||||||
void EditDictionaries::accept()
|
void EditDictionaries::accept()
|
||||||
{
|
{
|
||||||
if ( isSourcesChanged() )
|
|
||||||
acceptChangedSources();
|
|
||||||
|
|
||||||
Config::Groups newGroups = groups->getGroups();
|
Config::Groups newGroups = groups->getGroups();
|
||||||
|
|
||||||
|
if ( isSourcesChanged() )
|
||||||
|
acceptChangedSources( false );
|
||||||
|
|
||||||
if ( origCfg.groups != newGroups )
|
if ( origCfg.groups != newGroups )
|
||||||
{
|
{
|
||||||
groupsChanged = true;
|
groupsChanged = true;
|
||||||
|
@ -77,11 +77,7 @@ void EditDictionaries::on_tabs_currentChanged( int index )
|
||||||
|
|
||||||
if ( question.clickedButton() == accept )
|
if ( question.clickedButton() == accept )
|
||||||
{
|
{
|
||||||
acceptChangedSources();
|
acceptChangedSources( true );
|
||||||
|
|
||||||
// Rebuild groups from scratch
|
|
||||||
|
|
||||||
rebuildGroups();
|
|
||||||
|
|
||||||
lastCurrentTab = index;
|
lastCurrentTab = index;
|
||||||
ui.tabs->setCurrentIndex( index );
|
ui.tabs->setCurrentIndex( index );
|
||||||
|
@ -100,8 +96,7 @@ void EditDictionaries::on_tabs_currentChanged( int index )
|
||||||
|
|
||||||
void EditDictionaries::rescanSources()
|
void EditDictionaries::rescanSources()
|
||||||
{
|
{
|
||||||
acceptChangedSources();
|
acceptChangedSources( true );
|
||||||
rebuildGroups();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EditDictionaries::isSourcesChanged() const
|
bool EditDictionaries::isSourcesChanged() const
|
||||||
|
@ -113,10 +108,12 @@ bool EditDictionaries::isSourcesChanged() const
|
||||||
sources.getMediaWikis() != cfg.mediawikis;
|
sources.getMediaWikis() != cfg.mediawikis;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditDictionaries::acceptChangedSources()
|
void EditDictionaries::acceptChangedSources( bool rebuildGroups )
|
||||||
{
|
{
|
||||||
dictionariesChanged = true;
|
dictionariesChanged = true;
|
||||||
|
|
||||||
|
Config::Groups savedGroups = groups->getGroups();
|
||||||
|
|
||||||
cfg.paths = sources.getPaths();
|
cfg.paths = sources.getPaths();
|
||||||
cfg.soundDirs = sources.getSoundDirs();
|
cfg.soundDirs = sources.getSoundDirs();
|
||||||
cfg.hunspell = sources.getHunspell();
|
cfg.hunspell = sources.getHunspell();
|
||||||
|
@ -126,17 +123,17 @@ void EditDictionaries::acceptChangedSources()
|
||||||
groupInstances.clear(); // Those hold pointers to dictionaries, we need to
|
groupInstances.clear(); // Those hold pointers to dictionaries, we need to
|
||||||
// free them.
|
// free them.
|
||||||
|
|
||||||
loadDictionaries( this, true, cfg, dictionaries, dictNetMgr );
|
|
||||||
}
|
|
||||||
|
|
||||||
void EditDictionaries::rebuildGroups()
|
|
||||||
{
|
|
||||||
Config::Groups savedGroups = groups->getGroups();
|
|
||||||
|
|
||||||
ui.tabs->setUpdatesEnabled( false );
|
ui.tabs->setUpdatesEnabled( false );
|
||||||
ui.tabs->removeTab( 1 );
|
ui.tabs->removeTab( 1 );
|
||||||
groups.reset();
|
groups.reset();
|
||||||
|
|
||||||
|
loadDictionaries( this, true, cfg, dictionaries, dictNetMgr );
|
||||||
|
|
||||||
|
if ( rebuildGroups )
|
||||||
|
{
|
||||||
groups = new Groups( this, dictionaries, savedGroups );
|
groups = new Groups( this, dictionaries, savedGroups );
|
||||||
ui.tabs->insertTab( 1, groups.get(), QIcon(":/icons/bookcase.png"), tr( "&Groups" ) );
|
ui.tabs->insertTab( 1, groups.get(), QIcon(":/icons/bookcase.png"), tr( "&Groups" ) );
|
||||||
ui.tabs->setUpdatesEnabled( true );
|
ui.tabs->setUpdatesEnabled( true );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,9 +45,7 @@ private:
|
||||||
|
|
||||||
bool isSourcesChanged() const;
|
bool isSourcesChanged() const;
|
||||||
|
|
||||||
void acceptChangedSources();
|
void acceptChangedSources( bool rebuildGroups );
|
||||||
|
|
||||||
void rebuildGroups();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue