Compare commits

...

11 commits

Author SHA1 Message Date
xiaoyifang c0587e4e4d
Merge 4a0db3f7ee into 8d0859b932 2024-11-06 17:58:01 +08:00
YiFang Xiao 4a0db3f7ee 1 2024-11-04 21:52:53 +08:00
YiFang Xiao 94160f2d8a 1 2024-11-04 21:25:44 +08:00
xiaoyifang d8736af973 1: do not update name 2024-11-04 14:15:54 +08:00
xiaoyifang da99f9c330 1: do not update name 2024-11-04 14:05:02 +08:00
xiaoyifang 7784f8bb62 Revert "opt: update name should reflect the latest info"
This reverts commit 1272ea2d20a7908b9a69d6b551511916f97cc024.
2024-11-02 20:18:32 +08:00
xiaoyifang ac11ba7b51 opt: update name should reflect the latest info 2024-11-02 20:18:32 +08:00
autofix-ci[bot] 46b425a6f6 [autofix.ci] apply automated fixes 2024-11-02 20:18:32 +08:00
xiaoyifang 7b13b31ad5 opt: erase the need to removeTab 2024-11-02 20:18:32 +08:00
xiaoyifang 930e2f3531 opt: erase the need to removeTabs 2024-11-02 20:18:32 +08:00
xiaoyifang 2f443a712b opt: erase the need to removeTabs 2024-11-02 20:18:32 +08:00
6 changed files with 62 additions and 20 deletions

View file

@ -224,7 +224,7 @@ void loadDictionaries( QWidget * parent,
loadDicts.wait(); loadDicts.wait();
if ( loadDicts.getExceptionText().size() ) { if ( !loadDicts.getExceptionText().empty() ) {
QMessageBox::critical( parent, QMessageBox::critical( parent,
QCoreApplication::translate( "LoadDictionaries", "Error loading dictionaries" ), QCoreApplication::translate( "LoadDictionaries", "Error loading dictionaries" ),
QString::fromUtf8( loadDicts.getExceptionText().c_str() ) ); QString::fromUtf8( loadDicts.getExceptionText().c_str() ) );

View file

@ -200,32 +200,28 @@ void EditDictionaries::acceptChangedSources( bool rebuildGroups )
#ifndef NO_TTS_SUPPORT #ifndef NO_TTS_SUPPORT
cfg.voiceEngines = sources.getVoiceEngines(); cfg.voiceEngines = sources.getVoiceEngines();
#endif #endif
ui.tabs->setUpdatesEnabled( false ); setUpdatesEnabled( false );
// Those hold pointers to dictionaries, we need to free them. // Those hold pointers to dictionaries, we need to free them.
groupInstances.clear(); groupInstances.clear();
groups.clear(); // groups.clear();
orderAndProps.clear(); // orderAndProps.clear();
loadDictionaries( this, cfg, dictionaries, dictNetMgr ); loadDictionaries( this, cfg, dictionaries, dictNetMgr );
Instances::updateNames( savedGroups, dictionaries );
Instances::updateNames( savedOrder, dictionaries );
Instances::updateNames( savedInactive, dictionaries );
if ( rebuildGroups ) { if ( rebuildGroups ) {
ui.tabs->removeTab( 1 ); // ui.tabs->removeTab( 1 );
ui.tabs->removeTab( 1 ); // ui.tabs->removeTab( 1 );
orderAndProps = new OrderAndProps( this, savedOrder, savedInactive, dictionaries ); orderAndProps->rebuild( savedOrder, savedInactive, dictionaries );
groups = new Groups( this, dictionaries, savedGroups, orderAndProps->getCurrentDictionaryOrder() ); groups->rebuild( dictionaries, savedGroups, orderAndProps->getCurrentDictionaryOrder() );
ui.tabs->insertTab( 1, orderAndProps, QIcon( ":/icons/book.svg" ), tr( "&Dictionaries" ) ); // ui.tabs->insertTab( 1, orderAndProps, QIcon( ":/icons/book.svg" ), tr( "&Dictionaries" ) );
ui.tabs->insertTab( 2, groups, QIcon( ":/icons/bookcase.svg" ), tr( "&Groups" ) ); // ui.tabs->insertTab( 2, groups, QIcon( ":/icons/bookcase.svg" ), tr( "&Groups" ) );
connect( groups, &Groups::showDictionaryInfo, this, &EditDictionaries::showDictionaryInfo ); // connect( groups, &Groups::showDictionaryInfo, this, &EditDictionaries::showDictionaryInfo );
connect( orderAndProps, &OrderAndProps::showDictionaryHeadwords, this, &EditDictionaries::showDictionaryHeadwords ); // connect( orderAndProps, &OrderAndProps::showDictionaryHeadwords, this, &EditDictionaries::showDictionaryHeadwords );
} }
ui.tabs->setUpdatesEnabled( true ); setUpdatesEnabled( true );
} }
EditDictionaries::~EditDictionaries() EditDictionaries::~EditDictionaries()
{ {

View file

@ -64,6 +64,27 @@ Groups::Groups( QWidget * parent,
countChanged(); countChanged();
} }
void Groups::rebuild( vector< sptr< Dictionary::Class > > const & dicts_,
Config::Groups const & groups_,
Config::Group const & order )
{
this->setUpdatesEnabled( false );
dicts = dicts_;
groups = groups_;
ui.dictionaries->setAsSource();
ui.dictionaries->populate( Instances::Group( order, dicts, Config::Group() ).dictionaries, dicts );
ui.searchLine->applyTo( ui.dictionaries );
// Populate groups' widget
ui.groups->populate( groups, dicts, ui.dictionaries->getCurrentDictionaries() );
countChanged();
this->setUpdatesEnabled( true );
}
void Groups::editGroup( unsigned id ) void Groups::editGroup( unsigned id )
{ {
for ( int x = 0; x < groups.size(); ++x ) { for ( int x = 0; x < groups.size(); ++x ) {

View file

@ -19,7 +19,9 @@ public:
std::vector< sptr< Dictionary::Class > > const &, std::vector< sptr< Dictionary::Class > > const &,
Config::Groups const &, Config::Groups const &,
Config::Group const & order ); Config::Group const & order );
void rebuild( std::vector< sptr< Dictionary::Class > > const & dicts_,
Config::Groups const & groups_,
Config::Group const & order );
/// Instructs the dialog to position itself on editing the given group. /// Instructs the dialog to position itself on editing the given group.
void editGroup( unsigned id ); void editGroup( unsigned id );
@ -32,7 +34,7 @@ public:
private: private:
Ui::Groups ui; Ui::Groups ui;
std::vector< sptr< Dictionary::Class > > const & dicts; std::vector< sptr< Dictionary::Class > > dicts;
Config::Groups groups; Config::Groups groups;
QToolButton * groupsListButton; QToolButton * groupsListButton;

View file

@ -133,6 +133,27 @@ OrderAndProps::OrderAndProps( QWidget * parent,
showDictNumbers(); showDictNumbers();
} }
void OrderAndProps::rebuild( Config::Group const & dictionaryOrder,
Config::Group const & inactiveDictionaries,
std::vector< sptr< Dictionary::Class > > const & allDictionaries )
{
Instances::Group order( dictionaryOrder, allDictionaries, Config::Group() );
Instances::Group inactive( inactiveDictionaries, allDictionaries, Config::Group() );
Instances::complementDictionaryOrder( order, inactive, allDictionaries );
setUpdatesEnabled( false );
ui.dictionaryOrder->populate( order.dictionaries, allDictionaries );
ui.inactiveDictionaries->populate( inactive.dictionaries, allDictionaries );
ui.searchLine->applyTo( ui.dictionaryOrder );
disableDictionaryDescription();
showDictNumbers();
setUpdatesEnabled( true );
}
Config::Group OrderAndProps::getCurrentDictionaryOrder() const Config::Group OrderAndProps::getCurrentDictionaryOrder() const
{ {
Instances::Group g( "" ); Instances::Group g( "" );

View file

@ -18,7 +18,9 @@ public:
Config::Group const & dictionaryOrder, Config::Group const & dictionaryOrder,
Config::Group const & inactiveDictionaries, Config::Group const & inactiveDictionaries,
std::vector< sptr< Dictionary::Class > > const & allDictionaries ); std::vector< sptr< Dictionary::Class > > const & allDictionaries );
void rebuild( Config::Group const & dictionaryOrder,
Config::Group const & inactiveDictionaries,
std::vector< sptr< Dictionary::Class > > const & allDictionaries );
Config::Group getCurrentDictionaryOrder() const; Config::Group getCurrentDictionaryOrder() const;
Config::Group getCurrentInactiveDictionaries() const; Config::Group getCurrentInactiveDictionaries() const;