mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-27 15:24:05 +00:00
opt: optimize loading splash dialog with loading/check information
[autofix.ci] apply automated fixes
This commit is contained in:
parent
ac707fb8e1
commit
fe1fd14e31
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -17,6 +17,7 @@ public:
|
|||
public slots:
|
||||
|
||||
void indexing( QString const & dictionaryName );
|
||||
void loading( const QString & dictionaryName );
|
||||
|
||||
private:
|
||||
|
||||
|
|
Loading…
Reference in a new issue