clean: simplify loadDictionaries & Initializing dialog's showInitialy parameter (#1833)

This commit is contained in:
shenleban tongying 2024-10-17 23:08:20 -04:00 committed by GitHub
parent 8b8b83ab04
commit 9f13188973
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 8 additions and 18 deletions

View file

@ -198,7 +198,6 @@ void LoadDictionaries::loadingDictionary( string const & dictionaryName ) noexce
void loadDictionaries( QWidget * parent, void loadDictionaries( QWidget * parent,
bool showInitially,
Config::Class const & cfg, Config::Class const & cfg,
std::vector< sptr< Dictionary::Class > > & dictionaries, std::vector< sptr< Dictionary::Class > > & dictionaries,
QNetworkAccessManager & dictNetMgr, QNetworkAccessManager & dictNetMgr,
@ -206,7 +205,7 @@ void loadDictionaries( QWidget * parent,
{ {
dictionaries.clear(); dictionaries.clear();
::Initializing init( parent, showInitially ); ::Initializing init( parent );
// Start a thread to load all the dictionaries // Start a thread to load all the dictionaries

View file

@ -67,7 +67,6 @@ signals:
/// If doDeferredInit is true (default), doDeferredInit() is done on all /// If doDeferredInit is true (default), doDeferredInit() is done on all
/// dictionaries at the end. /// dictionaries at the end.
void loadDictionaries( QWidget * parent, void loadDictionaries( QWidget * parent,
bool showInitially,
Config::Class const & cfg, Config::Class const & cfg,
std::vector< sptr< Dictionary::Class > > &, std::vector< sptr< Dictionary::Class > > &,
QNetworkAccessManager & dictNetMgr, QNetworkAccessManager & dictNetMgr,

View file

@ -5,19 +5,17 @@
#include "initializing.hh" #include "initializing.hh"
#include <QCloseEvent> #include <QCloseEvent>
Initializing::Initializing( QWidget * parent, bool showOnStartup ): Initializing::Initializing( QWidget * parent ):
QDialog( parent ) QDialog( parent )
{ {
ui.setupUi( this ); ui.setupUi( this );
setWindowFlags( Qt::Dialog | Qt::FramelessWindowHint ); setWindowFlags( Qt::Dialog | Qt::FramelessWindowHint );
setWindowIcon( QIcon( ":/icons/programicon.png" ) ); setWindowIcon( QIcon( ":/icons/programicon.png" ) );
if ( showOnStartup ) { if ( parent->isVisible() ) {
ui.operation->setText( tr( "Please wait..." ) ); ui.operation->setText( tr( "Please wait..." ) );
ui.dictionary->hide(); ui.dictionary->setText( "" );
ui.progressBar->hide();
show(); show();
} }
} }
@ -26,9 +24,6 @@ void Initializing::indexing( QString const & dictionaryName )
{ {
ui.operation->setText( tr( "Indexing..." ) ); ui.operation->setText( tr( "Indexing..." ) );
ui.dictionary->setText( dictionaryName ); ui.dictionary->setText( dictionaryName );
ui.dictionary->show();
ui.progressBar->show();
adjustSize();
show(); show();
} }
@ -36,9 +31,6 @@ void Initializing::loading( QString const & dictionaryName )
{ {
ui.operation->setText( tr( "Loading..." ) ); ui.operation->setText( tr( "Loading..." ) );
ui.dictionary->setText( dictionaryName ); ui.dictionary->setText( dictionaryName );
ui.dictionary->show();
ui.progressBar->show();
adjustSize();
show(); show();
} }

View file

@ -12,7 +12,7 @@ class Initializing: public QDialog
public: public:
Initializing( QWidget * parent, bool showOnStartup ); Initializing( QWidget * parent );
public slots: public slots:

View file

@ -208,7 +208,7 @@ void EditDictionaries::acceptChangedSources( bool rebuildGroups )
groups.clear(); groups.clear();
orderAndProps.clear(); orderAndProps.clear();
loadDictionaries( this, true, cfg, dictionaries, dictNetMgr ); loadDictionaries( this, cfg, dictionaries, dictNetMgr );
// If no changes to groups were made, update the original data // If no changes to groups were made, update the original data
const bool noGroupEdits = ( origCfg.groups == savedGroups ); const bool noGroupEdits = ( origCfg.groups == savedGroups );

View file

@ -1585,7 +1585,7 @@ void MainWindow::makeDictionaries()
ftsIndexing.stopIndexing(); ftsIndexing.stopIndexing();
ftsIndexing.clearDictionaries(); ftsIndexing.clearDictionaries();
loadDictionaries( this, isVisible(), cfg, dictionaries, dictNetMgr, false ); loadDictionaries( this, cfg, dictionaries, dictNetMgr, false );
//create map //create map
dictMap = Dictionary::dictToMap( dictionaries ); dictMap = Dictionary::dictToMap( dictionaries );
@ -3478,7 +3478,7 @@ void MainWindow::on_rescanFiles_triggered()
dictionariesUnmuted.clear(); dictionariesUnmuted.clear();
dictionaryBar.setDictionaries( dictionaries ); dictionaryBar.setDictionaries( dictionaries );
loadDictionaries( this, true, cfg, dictionaries, dictNetMgr ); loadDictionaries( this, cfg, dictionaries, dictNetMgr );
dictMap = Dictionary::dictToMap( dictionaries ); dictMap = Dictionary::dictToMap( dictionaries );
for ( const auto & dictionarie : dictionaries ) { for ( const auto & dictionarie : dictionaries ) {