* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
#include "dialogs/errors.hpp"
#include "dialogs/interaction.hpp"
p_intf( _p_intf), p_dialog( _p_dialog )
{
QVBoxLayout *layout = NULL;
+ description = NULL;
int i_ret = -1;
panel = NULL;
dialog = NULL;
+ altButton = NULL;
if( p_dialog->i_flags & DIALOG_BLOCKING_ERROR )
{
i_ret = QMessageBox::critical( NULL, qfu( p_dialog->psz_title ),
qfu( p_dialog->psz_description ),
- QMessageBox::Ok, 0, 0 );
+ QMessageBox::Ok, QMessageBox::Ok );
}
else if( p_dialog->i_flags & DIALOG_NONBLOCKING_ERROR )
{
if( config_GetInt( p_intf, "qt-error-dialogs" ) != 0 )
ErrorsDialog::getInstance( p_intf )->addError(
qfu( p_dialog->psz_title ), qfu( p_dialog->psz_description ) );
- i_ret = 0;
- // QApplication::style()->standardPixmap(QStyle::SP_MessageBoxCritical)
- }
- else if( p_dialog->i_flags & DIALOG_WARNING )
- {
- if( config_GetInt( p_intf, "qt-error-dialogs" ) != 0 )
- ErrorsDialog::getInstance( p_intf )->addWarning(
- qfu( p_dialog->psz_title ),qfu( p_dialog->psz_description ) );
- i_ret = 0;
+ i_ret = QMessageBox::AcceptRole;
}
else if( p_dialog->i_flags & DIALOG_YES_NO_CANCEL )
{
p_dialog->i_status = SENT_DIALOG;
- i_ret = QMessageBox::question( NULL,
- qfu( p_dialog->psz_title), qfu( p_dialog->psz_description ),
- p_dialog->psz_default_button ?
- qfu( p_dialog->psz_default_button ) : QString::null,
- p_dialog->psz_alternate_button ?
- qfu( p_dialog->psz_alternate_button ) : QString::null,
- p_dialog->psz_other_button ?
- qfu( p_dialog->psz_other_button ) : QString::null, 0,
- p_dialog->psz_other_button ? 2 : -1 );
+
+ QMessageBox cancelBox;
+
+ cancelBox.setWindowTitle( qfu( p_dialog->psz_title) );
+ cancelBox.setText( qfu( p_dialog->psz_description ) );
+
+ if( p_dialog->psz_default_button )
+ cancelBox.addButton( "&" + qfu( p_dialog->psz_default_button ),
+ QMessageBox::AcceptRole );
+
+ if( p_dialog->psz_alternate_button )
+ cancelBox.addButton( "&" + qfu( p_dialog->psz_alternate_button ),
+ QMessageBox::RejectRole );
+
+ if( p_dialog->psz_other_button )
+ cancelBox.addButton( "&" + qfu( p_dialog->psz_other_button ),
+ QMessageBox::ActionRole );
+
+ i_ret = cancelBox.exec();
+ msg_Dbg( p_intf, "Warning %i %i", i_ret, cancelBox.result() );
}
else if( p_dialog->i_flags & DIALOG_LOGIN_PW_OK_CANCEL )
{
- dialog = new QWidget( 0 ); layout = new QVBoxLayout( dialog );
+ dialog = new QWidget; layout = new QVBoxLayout( dialog );
layout->setMargin( 2 );
- panel = new QWidget( 0 );
+ panel = new QWidget( dialog );
QGridLayout *grid = new QGridLayout;
description = new QLabel( qfu( p_dialog->psz_description ) );
panel->setLayout( grid );
layout->addWidget( panel );
}
- else if( p_dialog->i_flags & DIALOG_USER_PROGRESS ||
- /* TEMPORARY ! */ p_dialog->i_flags & DIALOG_INTF_PROGRESS )
+ else if( (p_dialog->i_flags & DIALOG_INTF_PROGRESS ) ||
+ ( p_dialog->i_flags & DIALOG_USER_PROGRESS ) )
{
- dialog = new QWidget( 0 );layout = new QVBoxLayout( dialog );
+ dialog = new QWidget; layout = new QVBoxLayout( dialog );
layout->setMargin( 2 );
description = new QLabel( qfu( p_dialog->psz_description ) );
layout->addWidget( description );
}
else if( p_dialog->i_flags & DIALOG_PSZ_INPUT_OK_CANCEL )
{
- dialog = new QWidget( 0 );layout = new QVBoxLayout( dialog );
+ dialog = new QWidget; layout = new QVBoxLayout( dialog );
layout->setMargin( 2 );
description = new QLabel( qfu( p_dialog->psz_description ) );
layout->addWidget( description );
layout->addWidget( inputEdit );
}
else
- msg_Err( p_intf, "unknown dialog type %i", p_dialog->i_flags );
+ {
+ msg_Err( p_intf, "Unknown dialog type %i", p_dialog->i_flags );
+ return;
+ }
- /* We used a message box */
+ msg_Dbg( p_intf, "Warning %i", i_ret );
+ /* We used a QMessageBox */
if( i_ret != -1 )
{
- if( i_ret == 0 ) Finish( DIALOG_OK_YES );
- else if ( i_ret == 1 ) Finish( DIALOG_NO );
+ if( i_ret == QMessageBox::AcceptRole || i_ret == QMessageBox::Ok )
+ Finish( DIALOG_OK_YES );
+ else if ( i_ret == QMessageBox::RejectRole ) Finish( DIALOG_NO );
else Finish( DIALOG_CANCELLED );
}
else
- /* Custom box, finish it */
+ /* Custom dialog, finish it */
{
+ assert( dialog );
+ /* Start the DialogButtonBox config */
QDialogButtonBox *buttonBox = new QDialogButtonBox;
if( p_dialog->psz_default_button )
{
defaultButton = new QPushButton;
defaultButton->setFocus();
- defaultButton->setText( qfu( p_dialog->psz_default_button ) );
+ defaultButton->setText( "&" + qfu( p_dialog->psz_default_button ) );
buttonBox->addButton( defaultButton, QDialogButtonBox::AcceptRole );
}
if( p_dialog->psz_alternate_button )
{
altButton = new QPushButton;
- altButton->setText( qfu( p_dialog->psz_alternate_button ) );
+ altButton->setText( "&" + qfu( p_dialog->psz_alternate_button ) );
buttonBox->addButton( altButton, QDialogButtonBox::RejectRole );
}
if( p_dialog->psz_other_button )
{
otherButton = new QPushButton;
- otherButton->setText( qfu( p_dialog->psz_other_button ) );
+ otherButton->setText( "&" + qfu( p_dialog->psz_other_button ) );
buttonBox->addButton( otherButton, QDialogButtonBox::ActionRole );
}
layout->addWidget( buttonBox );
- if( p_dialog->psz_default_button )
- BUTTONACT( defaultButton, defaultB() );
- if( p_dialog->psz_alternate_button )
- BUTTONACT( altButton, altB() );
- if( p_dialog->psz_other_button )
- BUTTONACT( otherButton, otherB() );
+ /* End the DialogButtonBox */
+
+ /* CONNECTs */
+ if( p_dialog->psz_default_button ) BUTTONACT( defaultButton, defaultB() );
+ if( p_dialog->psz_alternate_button ) BUTTONACT( altButton, altB() );
+ if( p_dialog->psz_other_button ) BUTTONACT( otherButton, otherB() );
+
+ /* set the layouts and thte title */
dialog->setLayout( layout );
dialog->setWindowTitle( qfu( p_dialog->psz_title ) );
}
void InteractionDialog::update()
{
- if( p_dialog->i_flags & DIALOG_USER_PROGRESS )
+ if( p_dialog->i_flags & DIALOG_USER_PROGRESS ||
+ p_dialog->i_flags & DIALOG_INTF_PROGRESS )
{
assert( progressBar );
- progressBar->setValue( (int)(p_dialog->val.f_float*1000) );
- msg_Dbg( p_intf, "Setting progress to %i", progressBar->value() );
+ progressBar->setValue( (int)( p_dialog->val.f_float * 10 ) );
+ if( description )
+ description->setText( qfu( p_dialog->psz_description ) );
+ }
+ else return;
+
+ if( ( p_dialog->i_flags & DIALOG_INTF_PROGRESS ) &&
+ ( p_dialog->val.f_float >= 100.0 ) )
+ {
+ progressBar->hide();
+ msg_Dbg( p_intf, "Progress Done" );
+ }
+
+ if( ( p_dialog->i_flags & DIALOG_USER_PROGRESS ) &&
+ ( p_dialog->val.f_float >= 100.0 ) )
+ {
+ assert( altButton );
+ altButton->setText( qtr( "&Close" ) );
}
}
InteractionDialog::~InteractionDialog()
{
-// if( panel ) delete panel;
- if( dialog ) delete dialog;
+ delete dialog;
}
void InteractionDialog::defaultB()
void InteractionDialog::Finish( int i_ret )
{
- vlc_mutex_lock( &p_dialog->p_interaction->object_lock );
+ vlc_mutex_lock( p_dialog->p_lock );
+ /* Special cases when we have to return psz to the core */
if( p_dialog->i_flags & DIALOG_LOGIN_PW_OK_CANCEL )
{
p_dialog->psz_returned[0] = strdup( qtu( loginEdit->text() ) );
{
p_dialog->psz_returned[0] = strdup( qtu( inputEdit->text() ) );
}
+
+ /* We finished the dialog, answer it */
p_dialog->i_status = ANSWERED_DIALOG;
p_dialog->i_return = i_ret;
+
+ /* Alert the Dialog_*_Progress that the user had clicked on "cancel" */
+ if( p_dialog->i_flags & DIALOG_USER_PROGRESS ||
+ p_dialog->i_flags & DIALOG_INTF_PROGRESS )
+ p_dialog->b_cancelled = true;
+
+ vlc_mutex_unlock( p_dialog->p_lock );
+
hide();
- vlc_mutex_unlock( &p_dialog->p_interaction->object_lock );
- playlist_Signal( THEPL );
}
+