+ 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:
Konstantin Isakov 2009-03-29 13:34:39 +00:00
parent 66fb8b51c1
commit 9ae4e57bb8
4 changed files with 37 additions and 5 deletions

View file

@ -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();
}

View file

@ -13,7 +13,7 @@ class Initializing: public QDialog
public:
Initializing( QWidget * parent );
Initializing( QWidget * parent, bool showOnStartup );
void indexing( QString const & dictionaryName );

View file

@ -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

View file

@ -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 );