opt: optimize loading splash dialog with loading/check information

[autofix.ci] apply automated fixes
This commit is contained in:
YiFang Xiao 2023-07-29 21:35:26 +08:00
parent ac707fb8e1
commit fe1fd14e31
8 changed files with 26 additions and 2 deletions

View file

@ -747,7 +747,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & f
{
vector< sptr< Dictionary::Class > > dictionaries;
for ( vector< string >::const_iterator i = fileNames.begin(); i != fileNames.end(); ++i ) {
for ( auto i = fileNames.begin(); i != fileNames.end(); ++i ) {
// Skip files with the extensions different to .aar to speed up the
// scanning
if ( i->size() < 4 || strcasecmp( i->c_str() + ( i->size() - 4 ), ".aar" ) != 0 )
@ -756,7 +756,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & f
// Got the file -- check if we need to rebuid the index
vector< string > dictFiles( 1, *i );
initializing.loadingDictionary( *i );
string dictId = Dictionary::makeDictionaryId( dictFiles );
string indexFile = indicesDir + dictId;

View file

@ -548,6 +548,7 @@ public:
/// is useful to show in some kind of a splash screen.
/// The dictionaryName is in utf8.
virtual void indexingDictionary( string const & dictionaryName ) noexcept = 0;
virtual void loadingDictionary( string const & dictionaryName ) noexcept = 0;
virtual ~Initializing() = default;
};

View file

@ -1746,6 +1746,8 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & f
|| File::tryPossibleName( baseName + "_ABRV.DSL.dz", abrvFileName ) )
dictFiles.push_back( abrvFileName );
initializing.loadingDictionary( fileName );
string dictId = Dictionary::makeDictionaryId( dictFiles );
// See if there's a zip file with resources present. If so, include it.

View file

@ -190,6 +190,11 @@ void LoadDictionaries::indexingDictionary( string const & dictionaryName ) noexc
emit indexingDictionarySignal( QString::fromUtf8( dictionaryName.c_str() ) );
}
void LoadDictionaries::loadingDictionary( string const & dictionaryName ) noexcept
{
emit loadingDictionarySignal( QString::fromUtf8( dictionaryName.c_str() ) );
}
void loadDictionaries( QWidget * parent,
bool showInitially,
@ -207,6 +212,7 @@ void loadDictionaries( QWidget * parent,
LoadDictionaries loadDicts( cfg );
QObject::connect( &loadDicts, &LoadDictionaries::indexingDictionarySignal, &init, &Initializing::indexing );
QObject::connect( &loadDicts, &LoadDictionaries::loadingDictionarySignal, &init, &Initializing::loading );
QEventLoop localLoop;

View file

@ -48,6 +48,7 @@ public:
public:
virtual void indexingDictionary( std::string const & dictionaryName ) noexcept;
virtual void loadingDictionary( std::string const & dictionaryName ) noexcept;
private:
@ -58,6 +59,7 @@ private:
signals:
void indexingDictionarySignal( QString const & dictionaryName );
void loadingDictionarySignal( QString const & dictionaryName );
};
/// Loads all dictionaries mentioned in the configuration passed, into the

View file

@ -1294,6 +1294,8 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & f
vector< string > dictFiles( 1, fileName );
findResourceFiles( fileName, dictFiles );
initializing.loadingDictionary( fileName );
string dictId = Dictionary::makeDictionaryId( dictFiles );
string indexFile = indicesDir + dictId;

View file

@ -32,6 +32,16 @@ void Initializing::indexing( QString const & dictionaryName )
show();
}
void Initializing::loading( QString const & dictionaryName )
{
ui.operation->setText( tr( "Loading..." ) );
ui.dictionary->setText( dictionaryName );
ui.dictionary->show();
ui.progressBar->show();
adjustSize();
show();
}
void Initializing::closeEvent( QCloseEvent * ev )
{
ev->ignore();

View file

@ -17,6 +17,7 @@ public:
public slots:
void indexing( QString const & dictionaryName );
void loading( const QString & dictionaryName );
private: