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 ) ...@@ -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 ) if( p_access->info.i_size < p_access->info.i_pos )
{ {
msg_Err( p_access, "seeking too far" ); 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; p_access->info.i_pos = p_access->info.i_size;
} }
else if( p_access->info.i_pos < 0 ) else if( p_access->info.i_pos < 0 )
......
...@@ -34,16 +34,17 @@ ...@@ -34,16 +34,17 @@
#include <assert.h> #include <assert.h>
InteractionDialog::InteractionDialog( intf_thread_t *_p_intf, 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 ) p_intf( _p_intf), p_dialog( _p_dialog )
{ {
QVBoxLayout *layout = new QVBoxLayout( this ); QVBoxLayout *layout = NULL;
int i_ret = -1; int i_ret = -1;
panel = NULL; panel = NULL;
dialog = NULL;
if( p_dialog->i_flags & DIALOG_BLOCKING_ERROR ) 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 ), qfu( p_dialog->psz_description ),
QMessageBox::Ok, 0, 0 ); QMessageBox::Ok, 0, 0 );
} }
...@@ -64,7 +65,8 @@ InteractionDialog::InteractionDialog( intf_thread_t *_p_intf, ...@@ -64,7 +65,8 @@ InteractionDialog::InteractionDialog( intf_thread_t *_p_intf,
} }
else if( p_dialog->i_flags & DIALOG_YES_NO_CANCEL ) 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 ), qfu( p_dialog->psz_title), qfu( p_dialog->psz_description ),
p_dialog->psz_default_button ? p_dialog->psz_default_button ?
qfu( p_dialog->psz_default_button ) : QString::null, qfu( p_dialog->psz_default_button ) : QString::null,
...@@ -76,6 +78,8 @@ InteractionDialog::InteractionDialog( intf_thread_t *_p_intf, ...@@ -76,6 +78,8 @@ InteractionDialog::InteractionDialog( intf_thread_t *_p_intf,
} }
else if( p_dialog->i_flags & DIALOG_LOGIN_PW_OK_CANCEL ) 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 ); panel = new QWidget( 0 );
QGridLayout *grid = new QGridLayout; QGridLayout *grid = new QGridLayout;
...@@ -93,8 +97,11 @@ InteractionDialog::InteractionDialog( intf_thread_t *_p_intf, ...@@ -93,8 +97,11 @@ InteractionDialog::InteractionDialog( intf_thread_t *_p_intf,
panel->setLayout( grid ); panel->setLayout( grid );
layout->addWidget( panel ); 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 ) ); description = new QLabel( qfu( p_dialog->psz_description ) );
layout->addWidget( description ); layout->addWidget( description );
...@@ -106,6 +113,8 @@ InteractionDialog::InteractionDialog( intf_thread_t *_p_intf, ...@@ -106,6 +113,8 @@ InteractionDialog::InteractionDialog( intf_thread_t *_p_intf,
} }
else if( p_dialog->i_flags & DIALOG_PSZ_INPUT_OK_CANCEL ) 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 ) ); description = new QLabel( qfu( p_dialog->psz_description ) );
layout->addWidget( description ); layout->addWidget( description );
...@@ -113,7 +122,7 @@ InteractionDialog::InteractionDialog( intf_thread_t *_p_intf, ...@@ -113,7 +122,7 @@ InteractionDialog::InteractionDialog( intf_thread_t *_p_intf,
layout->addWidget( inputEdit ); layout->addWidget( inputEdit );
} }
else 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 */ /* We used a message box */
if( i_ret != -1 ) if( i_ret != -1 )
...@@ -125,33 +134,35 @@ InteractionDialog::InteractionDialog( intf_thread_t *_p_intf, ...@@ -125,33 +134,35 @@ InteractionDialog::InteractionDialog( intf_thread_t *_p_intf,
else else
/* Custom box, finish it */ /* Custom box, finish it */
{ {
QVLCFrame::doButtons( this, layout, QVLCFrame::doButtons( dialog, layout,
&defaultButton, p_dialog->psz_default_button, &defaultButton, p_dialog->psz_default_button,
&altButton, p_dialog->psz_alternate_button, &altButton, p_dialog->psz_alternate_button,
&otherButton, p_dialog->psz_other_button ); &otherButton, p_dialog->psz_other_button );
if( p_dialog->psz_default_button ) if( p_dialog->psz_default_button )
BUTTONACT( defaultButton, defaultB ); BUTTONACT( defaultButton, defaultB() );
if( p_dialog->psz_alternate_button ) if( p_dialog->psz_alternate_button )
BUTTONACT( altButton, altB ); BUTTONACT( altButton, altB() );
if( p_dialog->psz_other_button ) if( p_dialog->psz_other_button )
BUTTONACT( otherButton, otherB ); BUTTONACT( otherButton, otherB() );
setLayout( layout ); dialog->setLayout( layout );
setWindowTitle( qfu( p_dialog->psz_title ) ); dialog->setWindowTitle( qfu( p_dialog->psz_title ) );
} }
} }
void InteractionDialog::Update() void InteractionDialog::update()
{ {
if( p_dialog->i_flags & DIALOG_USER_PROGRESS ) if( p_dialog->i_flags & DIALOG_USER_PROGRESS )
{ {
assert( progressBar ); assert( progressBar );
progressBar->setValue( (int)(p_dialog->val.f_float*1000) ); progressBar->setValue( (int)(p_dialog->val.f_float*1000) );
fprintf (stderr, "Setting progress to %i\n", progressBar->value() );
} }
} }
InteractionDialog::~InteractionDialog() InteractionDialog::~InteractionDialog()
{ {
if( panel ) delete panel; // if( panel ) delete panel;
if( dialog ) delete dialog;
} }
void InteractionDialog::defaultB() void InteractionDialog::defaultB()
......
...@@ -32,17 +32,20 @@ class QLabel; ...@@ -32,17 +32,20 @@ class QLabel;
class QProgressBar; class QProgressBar;
class QLineEdit; class QLineEdit;
class InteractionDialog : public QWidget class InteractionDialog : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
InteractionDialog( intf_thread_t *, interaction_dialog_t * ); InteractionDialog( intf_thread_t *, interaction_dialog_t * );
virtual ~InteractionDialog(); virtual ~InteractionDialog();
void Update(); void update();
void show() { if( dialog ) dialog->show(); }
void hide() { if( dialog ) dialog->hide(); }
private: private:
QWidget *panel; QWidget *panel;
QWidget *dialog;
intf_thread_t *p_intf; intf_thread_t *p_intf;
interaction_dialog_t *p_dialog; interaction_dialog_t *p_dialog;
......
...@@ -123,7 +123,7 @@ void DialogsProvider::doInteraction( intf_dialog_args_t *p_arg ) ...@@ -123,7 +123,7 @@ void DialogsProvider::doInteraction( intf_dialog_args_t *p_arg )
case INTERACT_UPDATE: case INTERACT_UPDATE:
qdialog = (InteractionDialog*)(p_dialog->p_private); qdialog = (InteractionDialog*)(p_dialog->p_private);
if( qdialog) if( qdialog)
qdialog->Update(); qdialog->update();
break; break;
case INTERACT_HIDE: case INTERACT_HIDE:
qdialog = (InteractionDialog*)(p_dialog->p_private); qdialog = (InteractionDialog*)(p_dialog->p_private);
...@@ -133,6 +133,7 @@ void DialogsProvider::doInteraction( intf_dialog_args_t *p_arg ) ...@@ -133,6 +133,7 @@ void DialogsProvider::doInteraction( intf_dialog_args_t *p_arg )
break; break;
case INTERACT_DESTROY: case INTERACT_DESTROY:
qdialog = (InteractionDialog*)(p_dialog->p_private); qdialog = (InteractionDialog*)(p_dialog->p_private);
if( !p_dialog->i_flags & DIALOG_NONBLOCKING_ERROR )
delete qdialog; delete qdialog;
p_dialog->i_status = DESTROYED_DIALOG; p_dialog->i_status = DESTROYED_DIALOG;
break; break;
......
...@@ -65,6 +65,7 @@ public: ...@@ -65,6 +65,7 @@ public:
QPushButton **other, char *psz_other ) QPushButton **other, char *psz_other )
{ {
#ifdef QT42 #ifdef QT42
fprintf( stderr, "Gra\n" );
#else #else
QHBoxLayout *buttons_layout = new QHBoxLayout; QHBoxLayout *buttons_layout = new QHBoxLayout;
QSpacerItem *spacerItem = new QSpacerItem( 40, 20, QSpacerItem *spacerItem = new QSpacerItem( 40, 20,
...@@ -75,6 +76,7 @@ public: ...@@ -75,6 +76,7 @@ public:
{ {
fprintf( stderr, "Creating default button %s\n", psz_default ); fprintf( stderr, "Creating default button %s\n", psz_default );
*defaul = new QPushButton(0); *defaul = new QPushButton(0);
(*defaul)->setFocus();
buttons_layout->addWidget( *defaul ); buttons_layout->addWidget( *defaul );
(*defaul)->setText( qfu( psz_default ) ); (*defaul)->setText( qfu( psz_default ) );
} }
......
...@@ -367,16 +367,19 @@ int __intf_UserLoginPassword( vlc_object_t *p_this, ...@@ -367,16 +367,19 @@ int __intf_UserLoginPassword( vlc_object_t *p_this,
p_new->i_type = INTERACT_DIALOG_TWOWAY; p_new->i_type = INTERACT_DIALOG_TWOWAY;
p_new->psz_title = strdup( psz_title ); p_new->psz_title = strdup( psz_title );
p_new->psz_description = strdup( psz_description ); 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; p_new->i_flags = DIALOG_LOGIN_PW_OK_CANCEL;
i_ret = DialogSend( p_this, p_new ); 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 = p_new->psz_returned[0]?
*ppsz_login = strdup( p_new->psz_returned[0] ); strdup( p_new->psz_returned[0] ) : NULL;
*ppsz_password = strdup( p_new->psz_returned[1] ); *ppsz_password = p_new->psz_returned[1]?
strdup( p_new->psz_returned[1] ) : NULL;
} }
return i_ret; return i_ret;
} }
......
...@@ -211,6 +211,8 @@ static void DestroyInteraction( playlist_t *p_playlist ) ...@@ -211,6 +211,8 @@ static void DestroyInteraction( playlist_t *p_playlist )
if( p_playlist->p_interaction ) if( p_playlist->p_interaction )
{ {
intf_InteractionDestroy( 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