Commit 928454fa authored by Clément Stenac's avatar Clément Stenac

Fix a number of problems with interaction dialogs

Remove the "seeking too far" error, as it happens for broken AVI and is quite confusing
parent 6cdb3e28
......@@ -516,10 +516,6 @@ static int Seek( access_t *p_access, int64_t i_pos )
if( p_access->info.i_size < p_access->info.i_pos )
{
msg_Err( p_access, "seeking too far" );
intf_UserFatal( p_access, VLC_FALSE, _("File reading failed"),
_("VLC seeked in the file too far. This usually means "
"that your file is broken and therefore cannot be "
"played." ) );
p_access->info.i_pos = p_access->info.i_size;
}
else if( p_access->info.i_pos < 0 )
......
......@@ -285,7 +285,7 @@ connect:
int i_ret;
msg_Dbg( p_access, "authentication failed" );
i_ret = intf_UserLoginPassword( p_access, _("HTTP authentication"),
_("Please enter a valid login name and a password."),
_("Please enter a valid login name and a password."),
&psz_login, &psz_password );
if( i_ret == DIALOG_OK_YES )
{
......
......@@ -34,16 +34,17 @@
#include <assert.h>
InteractionDialog::InteractionDialog( intf_thread_t *_p_intf,
interaction_dialog_t *_p_dialog ) : QWidget( 0 ),
interaction_dialog_t *_p_dialog ) : QObject( 0 ),
p_intf( _p_intf), p_dialog( _p_dialog )
{
QVBoxLayout *layout = new QVBoxLayout( this );
QVBoxLayout *layout = NULL;
int i_ret = -1;
panel = NULL;
dialog = NULL;
if( p_dialog->i_flags & DIALOG_BLOCKING_ERROR )
{
i_ret = QMessageBox::critical( this, qfu( p_dialog->psz_title ),
i_ret = QMessageBox::critical( NULL, qfu( p_dialog->psz_title ),
qfu( p_dialog->psz_description ),
QMessageBox::Ok, 0, 0 );
}
......@@ -64,7 +65,8 @@ InteractionDialog::InteractionDialog( intf_thread_t *_p_intf,
}
else if( p_dialog->i_flags & DIALOG_YES_NO_CANCEL )
{
i_ret = QMessageBox::question( this,
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,
......@@ -76,6 +78,8 @@ InteractionDialog::InteractionDialog( intf_thread_t *_p_intf,
}
else if( p_dialog->i_flags & DIALOG_LOGIN_PW_OK_CANCEL )
{
dialog = new QWidget( 0 ); layout = new QVBoxLayout( dialog );
layout->setMargin( 2 );
panel = new QWidget( 0 );
QGridLayout *grid = new QGridLayout;
......@@ -93,8 +97,11 @@ InteractionDialog::InteractionDialog( intf_thread_t *_p_intf,
panel->setLayout( grid );
layout->addWidget( panel );
}
else if( p_dialog->i_flags & DIALOG_USER_PROGRESS )
else if( p_dialog->i_flags & DIALOG_USER_PROGRESS ||
/* TEMPORARY ! */ p_dialog->i_flags & DIALOG_INTF_PROGRESS )
{
dialog = new QWidget( 0 );layout = new QVBoxLayout( dialog );
layout->setMargin( 2 );
description = new QLabel( qfu( p_dialog->psz_description ) );
layout->addWidget( description );
......@@ -106,6 +113,8 @@ InteractionDialog::InteractionDialog( intf_thread_t *_p_intf,
}
else if( p_dialog->i_flags & DIALOG_PSZ_INPUT_OK_CANCEL )
{
dialog = new QWidget( 0 );layout = new QVBoxLayout( dialog );
layout->setMargin( 2 );
description = new QLabel( qfu( p_dialog->psz_description ) );
layout->addWidget( description );
......@@ -113,7 +122,7 @@ InteractionDialog::InteractionDialog( intf_thread_t *_p_intf,
layout->addWidget( inputEdit );
}
else
msg_Err( p_intf, "unknown dialog type" );
msg_Err( p_intf, "unknown dialog type %i", p_dialog->i_flags );
/* We used a message box */
if( i_ret != -1 )
......@@ -125,33 +134,35 @@ InteractionDialog::InteractionDialog( intf_thread_t *_p_intf,
else
/* Custom box, finish it */
{
QVLCFrame::doButtons( this, layout,
QVLCFrame::doButtons( dialog, layout,
&defaultButton, p_dialog->psz_default_button,
&altButton, p_dialog->psz_alternate_button,
&otherButton, p_dialog->psz_other_button );
if( p_dialog->psz_default_button )
BUTTONACT( defaultButton, defaultB );
BUTTONACT( defaultButton, defaultB() );
if( p_dialog->psz_alternate_button )
BUTTONACT( altButton, altB );
BUTTONACT( altButton, altB() );
if( p_dialog->psz_other_button )
BUTTONACT( otherButton, otherB );
setLayout( layout );
setWindowTitle( qfu( p_dialog->psz_title ) );
BUTTONACT( otherButton, otherB() );
dialog->setLayout( layout );
dialog->setWindowTitle( qfu( p_dialog->psz_title ) );
}
}
void InteractionDialog::Update()
void InteractionDialog::update()
{
if( p_dialog->i_flags & DIALOG_USER_PROGRESS )
{
assert( progressBar );
progressBar->setValue( (int)(p_dialog->val.f_float*1000) );
fprintf (stderr, "Setting progress to %i\n", progressBar->value() );
}
}
InteractionDialog::~InteractionDialog()
{
if( panel ) delete panel;
// if( panel ) delete panel;
if( dialog ) delete dialog;
}
void InteractionDialog::defaultB()
......
......@@ -32,17 +32,20 @@ class QLabel;
class QProgressBar;
class QLineEdit;
class InteractionDialog : public QWidget
class InteractionDialog : public QObject
{
Q_OBJECT
public:
InteractionDialog( intf_thread_t *, interaction_dialog_t * );
virtual ~InteractionDialog();
void Update();
void update();
void show() { if( dialog ) dialog->show(); }
void hide() { if( dialog ) dialog->hide(); }
private:
QWidget *panel;
QWidget *dialog;
intf_thread_t *p_intf;
interaction_dialog_t *p_dialog;
......
......@@ -123,7 +123,7 @@ void DialogsProvider::doInteraction( intf_dialog_args_t *p_arg )
case INTERACT_UPDATE:
qdialog = (InteractionDialog*)(p_dialog->p_private);
if( qdialog)
qdialog->Update();
qdialog->update();
break;
case INTERACT_HIDE:
qdialog = (InteractionDialog*)(p_dialog->p_private);
......@@ -133,7 +133,8 @@ void DialogsProvider::doInteraction( intf_dialog_args_t *p_arg )
break;
case INTERACT_DESTROY:
qdialog = (InteractionDialog*)(p_dialog->p_private);
delete qdialog;
if( !p_dialog->i_flags & DIALOG_NONBLOCKING_ERROR )
delete qdialog;
p_dialog->i_status = DESTROYED_DIALOG;
break;
}
......
......@@ -65,6 +65,7 @@ public:
QPushButton **other, char *psz_other )
{
#ifdef QT42
fprintf( stderr, "Gra\n" );
#else
QHBoxLayout *buttons_layout = new QHBoxLayout;
QSpacerItem *spacerItem = new QSpacerItem( 40, 20,
......@@ -75,6 +76,7 @@ public:
{
fprintf( stderr, "Creating default button %s\n", psz_default );
*defaul = new QPushButton(0);
(*defaul)->setFocus();
buttons_layout->addWidget( *defaul );
(*defaul)->setText( qfu( psz_default ) );
}
......
......@@ -367,16 +367,19 @@ int __intf_UserLoginPassword( vlc_object_t *p_this,
p_new->i_type = INTERACT_DIALOG_TWOWAY;
p_new->psz_title = strdup( psz_title );
p_new->psz_description = strdup( psz_description );
p_new->psz_default_button = strdup( _("Ok" ) );
p_new->psz_alternate_button = strdup( _("Cancel" ) );
p_new->i_flags = DIALOG_LOGIN_PW_OK_CANCEL;
i_ret = DialogSend( p_this, p_new );
if( i_ret != DIALOG_CANCELLED )
if( i_ret != DIALOG_CANCELLED && i_ret != VLC_EGENERIC )
{
assert( p_new->psz_returned[0] && p_new->psz_returned[1] );
*ppsz_login = strdup( p_new->psz_returned[0] );
*ppsz_password = strdup( p_new->psz_returned[1] );
*ppsz_login = p_new->psz_returned[0]?
strdup( p_new->psz_returned[0] ) : NULL;
*ppsz_password = p_new->psz_returned[1]?
strdup( p_new->psz_returned[1] ) : NULL;
}
return i_ret;
}
......
......@@ -211,6 +211,8 @@ static void DestroyInteraction( playlist_t *p_playlist )
if( p_playlist->p_interaction )
{
intf_InteractionDestroy( p_playlist->p_interaction );
fprintf( stderr, "NOW NULL ****\n" );
p_playlist->p_interaction = NULL;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment