]> git.sesse.net Git - vlc/commitdiff
Fix a number of problems with interaction dialogs
authorClément Stenac <zorglub@videolan.org>
Thu, 14 Sep 2006 21:19:34 +0000 (21:19 +0000)
committerClément Stenac <zorglub@videolan.org>
Thu, 14 Sep 2006 21:19:34 +0000 (21:19 +0000)
Remove the "seeking too far" error, as it happens for broken AVI and is quite confusing

modules/access/file.c
modules/access/http.c
modules/gui/qt4/dialogs/interaction.cpp
modules/gui/qt4/dialogs/interaction.hpp
modules/gui/qt4/dialogs_provider.cpp
modules/gui/qt4/util/qvlcframe.hpp
src/interface/interaction.c
src/playlist/thread.c

index 0c876749e1a103b8c6f43e2827113f96e409353b..50e0c322819c09c55096024b5d86f0ff70462a84 100644 (file)
@@ -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 )
index 82d9fefd6bb92ed53e3aa287303d6668022b694d..5558dd962b978391ed24302d5c2f3c7ea43dbd7b 100644 (file)
@@ -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 )
         {
index 8960afbfe67171fb2f618ec3ba1cf2a6a9c54062..2859a56ab30095f70c078886b48cf943d7f8f26a 100644 (file)
 #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()
index 9cf828a8e199b2730264e1f507f52080c94ed859..40a750376d2f08a9dbc4f5b4ea92794e5823aaa7 100644 (file)
@@ -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;
 
index 7cd53e1b6694f9d4774b3a193717bce2b5ccccb2..b4b414ed30eebc429022321c16deed7ac8a8fc21 100644 (file)
@@ -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;
     }
index 36a368fb0185ac2b77fb73704b95a06844a2a9df..f35fc97beadd6cf915c044d949276b48fcb0b696 100644 (file)
@@ -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 ) );
         }
index 395ecebf8a296cca63045f5eb0bdab164e10a3fe..09cbd2437cd9268fc021abf424789b1825a0aee8 100644 (file)
@@ -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;
 }
index 5bf33e45bd98feb9684cf6754690f7857ba8c283..34d127b2f6dbae375ad3ad6551abe7d5e24aa7b5 100644 (file)
@@ -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;
     }
 }