mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-27 15:24:05 +00:00
+ Show the 'wait' message when loading dictionaries and the main window is
shown. + Propagate and display any exception happened while loading dictionaries.
This commit is contained in:
parent
66fb8b51c1
commit
9ae4e57bb8
|
@ -4,19 +4,29 @@
|
|||
#include "initializing.hh"
|
||||
#include <QCloseEvent>
|
||||
|
||||
Initializing::Initializing( QWidget * parent ): QDialog( parent )
|
||||
Initializing::Initializing( QWidget * parent, bool showOnStartup ): QDialog( parent )
|
||||
{
|
||||
ui.setupUi( this );
|
||||
setWindowFlags( Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint |
|
||||
Qt::WindowMinimizeButtonHint );
|
||||
|
||||
setWindowIcon( QIcon( ":/icons/programicon.png" ) );
|
||||
|
||||
if ( showOnStartup )
|
||||
{
|
||||
ui.operation->setText( tr( "Please wait..." ) );
|
||||
ui.dictionary->hide();
|
||||
ui.progressBar->hide();
|
||||
show();
|
||||
}
|
||||
}
|
||||
|
||||
void Initializing::indexing( QString const & dictionaryName )
|
||||
{
|
||||
ui.operation->setText( tr( "Please wait while indexing dictionary" ) );
|
||||
ui.dictionary->setText( dictionaryName );
|
||||
ui.dictionary->show();
|
||||
ui.progressBar->show();
|
||||
show();
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ class Initializing: public QDialog
|
|||
|
||||
public:
|
||||
|
||||
Initializing( QWidget * parent );
|
||||
Initializing( QWidget * parent, bool showOnStartup );
|
||||
|
||||
void indexing( QString const & dictionaryName );
|
||||
|
||||
|
|
|
@ -162,8 +162,15 @@ LoadDictionaries::LoadDictionaries( Config::Paths const & paths_ ):
|
|||
|
||||
void LoadDictionaries::run()
|
||||
{
|
||||
for( Config::Paths::const_iterator i = paths.begin(); i != paths.end(); ++i )
|
||||
handlePath( *i );
|
||||
try
|
||||
{
|
||||
for( Config::Paths::const_iterator i = paths.begin(); i != paths.end(); ++i )
|
||||
handlePath( *i );
|
||||
}
|
||||
catch( std::exception & e )
|
||||
{
|
||||
exceptionText = e.what();
|
||||
}
|
||||
}
|
||||
|
||||
void LoadDictionaries::handlePath( Config::Path const & path )
|
||||
|
@ -274,7 +281,7 @@ void MainWindow::makeDictionaries()
|
|||
|
||||
dictionaries.clear();
|
||||
|
||||
::Initializing init( this );
|
||||
::Initializing init( this, isVisible() );
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -298,6 +305,16 @@ void MainWindow::makeDictionaries()
|
|||
|
||||
loadDicts.wait();
|
||||
|
||||
if ( loadDicts.getExceptionText().size() )
|
||||
{
|
||||
initializing = 0;
|
||||
|
||||
QMessageBox::critical( this, tr( "Error loading dictionaries" ),
|
||||
QString::fromUtf8( loadDicts.getExceptionText().c_str() ) );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
dictionaries = loadDicts.getDictionaries();
|
||||
|
||||
///// We create MediaWiki dicts syncronously, since they use netmgr
|
||||
|
|
|
@ -30,6 +30,7 @@ class LoadDictionaries: public QThread, public Dictionary::Initializing
|
|||
|
||||
Config::Paths const & paths;
|
||||
vector< sptr< Dictionary::Class > > dictionaries;
|
||||
string exceptionText;
|
||||
|
||||
public:
|
||||
|
||||
|
@ -40,6 +41,10 @@ public:
|
|||
vector< sptr< Dictionary::Class > > const & getDictionaries() const
|
||||
{ return dictionaries; }
|
||||
|
||||
/// Empty string means to exception occured
|
||||
string const & getExceptionText() const
|
||||
{ return exceptionText; }
|
||||
|
||||
signals:
|
||||
|
||||
void indexingDictionarySignal( QString dictionaryName );
|
||||
|
|
Loading…
Reference in a new issue