diff -r c499df2dbb33 -r 2c833fc9e98f ui/commandhandlers/commoncommandhandlers/src/glxcommondialogs.cpp --- a/ui/commandhandlers/commoncommandhandlers/src/glxcommondialogs.cpp Mon May 03 12:31:32 2010 +0300 +++ b/ui/commandhandlers/commoncommandhandlers/src/glxcommondialogs.cpp Fri May 14 15:52:22 2010 +0300 @@ -18,56 +18,71 @@ #include #include +#include -GlxTextInputDialog::GlxTextInputDialog() - { - } +GlxTextInputDialog::GlxTextInputDialog() + : mDialog ( NULL ), + mEventLoop ( 0 ), + mResult ( false ) +{ +} GlxTextInputDialog::~GlxTextInputDialog() - { - } +{ +} QString GlxTextInputDialog::getText(const QString &label, const QString &text, bool *ok) - { +{ + QEventLoop eventLoop; + mEventLoop = &eventLoop; + mDialog = new HbInputDialog(); mDialog->setPromptText(label); mDialog->setInputMode(HbInputDialog::TextInput); mDialog->setValue(text); connect(mDialog->lineEdit(0), SIGNAL( textChanged (const QString &) ), this, SLOT( textChanged (const QString &))); - HbAction* action = mDialog->exec(); + + mDialog->open( this, SLOT( dialogClosed( HbAction* ) ) ); + eventLoop.exec( ); + mEventLoop = 0 ; + + if ( ok ) { + *ok = mResult ; + } QString retText = NULL; - if (action == mDialog->secondaryAction()) - { //Cancel was pressed - if (ok) - { - *ok = false; - } - } - else - { //OK was pressed - if (ok) - { - *ok = true; - } + if ( mResult ) { retText = mDialog->value().toString().trimmed(); - } + } + disconnect(mDialog->lineEdit(0), SIGNAL( textChanged (const QString &) ), - this, SLOT( textChanged (const QString &))); + this, SLOT( textChanged (const QString &))); delete mDialog; mDialog = NULL; return retText; - } +} void GlxTextInputDialog::textChanged(const QString &text) - { - if (text.trimmed().isEmpty()) - { - mDialog->primaryAction()->setEnabled(false); - } - else - { - mDialog->primaryAction()->setEnabled(true); - } +{ + if (text.trimmed().isEmpty()) { + mDialog->actions().first()->setEnabled(false); + } + else { + mDialog->actions().first()->setEnabled(true); } +} + +void GlxTextInputDialog::dialogClosed(HbAction *action) +{ + HbInputDialog *dlg = static_cast(sender()); + if( action == dlg->actions().first() ) { + mResult = true ; + } + else { + mResult = false ; + } + if ( mEventLoop && mEventLoop->isRunning( ) ) { + mEventLoop->exit( 0 ); + } +}