]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/dialogs/interaction.cpp
Hide interaction object layout
[vlc] / modules / gui / qt4 / dialogs / interaction.cpp
index 0cf4149906b04fd8adf9306289ecb377bb6b16c0..030c63965b5a05d4afea3cbd0b78399a4009d0cf 100644 (file)
  * along with this program; if not, write to the Free Software
  * 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"
-#include "main_interface.hpp"
 
 #include <QLabel>
 #include <QLineEdit>
@@ -42,9 +42,11 @@ InteractionDialog::InteractionDialog( intf_thread_t *_p_intf,
                           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 )
     {
@@ -58,7 +60,6 @@ InteractionDialog::InteractionDialog( intf_thread_t *_p_intf,
             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 )
     {
@@ -102,7 +103,8 @@ 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_INTF_PROGRESS ) ||
+             ( p_dialog->i_flags & DIALOG_USER_PROGRESS ) )
     {
         dialog = new QWidget( 0 );layout = new QVBoxLayout( dialog );
         layout->setMargin( 2 );
@@ -115,11 +117,6 @@ InteractionDialog::InteractionDialog( intf_thread_t *_p_intf,
         progressBar->setOrientation( Qt::Horizontal );
         layout->addWidget( progressBar );
     }
-    else if( p_dialog->i_flags & DIALOG_INTF_PROGRESS )
-    {
-        progressBar = p_intf->p_sys->p_mi->pgBar;
-        progressBar->show();
-    }
     else if( p_dialog->i_flags & DIALOG_PSZ_INPUT_OK_CANCEL )
     {
         dialog = new QWidget( 0 );layout = new QVBoxLayout( dialog );
@@ -131,18 +128,24 @@ InteractionDialog::InteractionDialog( intf_thread_t *_p_intf,
         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 */
     if( i_ret != -1 )
     {
         if( i_ret == 0 ) Finish( DIALOG_OK_YES );
         else if ( i_ret == 1 ) Finish( DIALOG_NO );
+        else if ( i_ret == 2 ) return ;
         else Finish( DIALOG_CANCELLED );
     }
     else
     /* Custom box, finish it */
     {
+        assert( dialog );
+        /* Start the DialogButtonBox config */
         QDialogButtonBox *buttonBox = new QDialogButtonBox;
 
         if( p_dialog->psz_default_button )
@@ -165,12 +168,17 @@ InteractionDialog::InteractionDialog( intf_thread_t *_p_intf,
             buttonBox->addButton( otherButton, QDialogButtonBox::ActionRole );
         }
         layout->addWidget( buttonBox );
+        /* 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 ) );
     }
@@ -183,19 +191,30 @@ void InteractionDialog::update()
     {
         assert( progressBar );
         progressBar->setValue( (int)( p_dialog->val.f_float * 10 ) );
-        description->setText( qfu( p_dialog->psz_description ) );
-        msg_Dbg( p_intf, "Setting progress to %i", progressBar->value() );
+        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 panel;
+    delete dialog;
 }
 
 void InteractionDialog::defaultB()
@@ -213,7 +232,7 @@ void InteractionDialog::otherB()
 
 void InteractionDialog::Finish( int i_ret )
 {
-    vlc_mutex_lock( &p_dialog->p_interaction->object_lock );
+    vlc_object_lock( (vlc_object_t *)(p_dialog->p_interaction) );
 
     if( p_dialog->i_flags & DIALOG_LOGIN_PW_OK_CANCEL )
     {
@@ -233,7 +252,6 @@ void InteractionDialog::Finish( int i_ret )
         p_dialog->b_cancelled = true;
 
     hide();
-    vlc_mutex_unlock( &p_dialog->p_interaction->object_lock );
-    playlist_Signal( THEPL );
+    vlc_object_unlock( (vlc_object_t *)(p_dialog->p_interaction) );
 }