Skip to content

Commit

Permalink
clean: simplify loadDictionaries & Initializing dialog's `showInitial…
Browse files Browse the repository at this point in the history
…y` parameter (#1833)
  • Loading branch information
shenlebantongying authored Oct 18, 2024
1 parent 8b8b83a commit 9f13188
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 18 deletions.
3 changes: 1 addition & 2 deletions src/dict/loaddictionaries.cc
Original file line number Diff line number Diff line change
Expand Up @@ -198,15 +198,14 @@ void LoadDictionaries::loadingDictionary( string const & dictionaryName ) noexce


void loadDictionaries( QWidget * parent,
bool showInitially,
Config::Class const & cfg,
std::vector< sptr< Dictionary::Class > > & dictionaries,
QNetworkAccessManager & dictNetMgr,
bool doDeferredInit_ )
{
dictionaries.clear();

::Initializing init( parent, showInitially );
::Initializing init( parent );

// Start a thread to load all the dictionaries

Expand Down
1 change: 0 additions & 1 deletion src/dict/loaddictionaries.hh
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ signals:
/// If doDeferredInit is true (default), doDeferredInit() is done on all
/// dictionaries at the end.
void loadDictionaries( QWidget * parent,
bool showInitially,
Config::Class const & cfg,
std::vector< sptr< Dictionary::Class > > &,
QNetworkAccessManager & dictNetMgr,
Expand Down
14 changes: 3 additions & 11 deletions src/initializing.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,17 @@
#include "initializing.hh"
#include <QCloseEvent>

Initializing::Initializing( QWidget * parent, bool showOnStartup ):
Initializing::Initializing( QWidget * parent ):
QDialog( parent )
{
ui.setupUi( this );

setWindowFlags( Qt::Dialog | Qt::FramelessWindowHint );

setWindowIcon( QIcon( ":/icons/programicon.png" ) );

if ( showOnStartup ) {
if ( parent->isVisible() ) {
ui.operation->setText( tr( "Please wait..." ) );
ui.dictionary->hide();
ui.progressBar->hide();
ui.dictionary->setText( "" );
show();
}
}
Expand All @@ -26,19 +24,13 @@ void Initializing::indexing( QString const & dictionaryName )
{
ui.operation->setText( tr( "Indexing..." ) );
ui.dictionary->setText( dictionaryName );
ui.dictionary->show();
ui.progressBar->show();
adjustSize();
show();
}

void Initializing::loading( QString const & dictionaryName )
{
ui.operation->setText( tr( "Loading..." ) );
ui.dictionary->setText( dictionaryName );
ui.dictionary->show();
ui.progressBar->show();
adjustSize();
show();
}

Expand Down
2 changes: 1 addition & 1 deletion src/initializing.hh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Initializing: public QDialog

public:

Initializing( QWidget * parent, bool showOnStartup );
Initializing( QWidget * parent );

public slots:

Expand Down
2 changes: 1 addition & 1 deletion src/ui/editdictionaries.cc
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ void EditDictionaries::acceptChangedSources( bool rebuildGroups )
groups.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
const bool noGroupEdits = ( origCfg.groups == savedGroups );
Expand Down
4 changes: 2 additions & 2 deletions src/ui/mainwindow.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1585,7 +1585,7 @@ void MainWindow::makeDictionaries()
ftsIndexing.stopIndexing();
ftsIndexing.clearDictionaries();

loadDictionaries( this, isVisible(), cfg, dictionaries, dictNetMgr, false );
loadDictionaries( this, cfg, dictionaries, dictNetMgr, false );

//create map
dictMap = Dictionary::dictToMap( dictionaries );
Expand Down Expand Up @@ -3478,7 +3478,7 @@ void MainWindow::on_rescanFiles_triggered()
dictionariesUnmuted.clear();
dictionaryBar.setDictionaries( dictionaries );

loadDictionaries( this, true, cfg, dictionaries, dictNetMgr );
loadDictionaries( this, cfg, dictionaries, dictNetMgr );
dictMap = Dictionary::dictToMap( dictionaries );

for ( const auto & dictionarie : dictionaries ) {
Expand Down

0 comments on commit 9f13188

Please sign in to comment.