]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/dialogs/interaction.cpp
Qt4 - Strings changes by tonsofpcs.
[vlc] / modules / gui / qt4 / dialogs / interaction.cpp
index 7e59a052b08b8a511f969a3b89809dd03f916d08..2ee8f3f0c82fa34a0e4a3b0213c041a67f986bdc 100644 (file)
@@ -18,7 +18,8 @@
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
 
 #include "qt4.hpp"
 #include "dialogs/errors.hpp"
 #include <QPushButton>
 #include <QProgressBar>
 #include <QMessageBox>
+#include <QDialogButtonBox>
 
 #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 +67,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 +80,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;
 
@@ -88,13 +94,17 @@ InteractionDialog::InteractionDialog( intf_thread_t *_p_intf,
 
         grid->addWidget( new QLabel( qtr("Password") ), 2, 0);
         passwordEdit = new QLineEdit;
+        passwordEdit->setEchoMode( QLineEdit::Password );
         grid->addWidget( passwordEdit, 2, 1 );
 
         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 +116,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 +125,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,34 +137,53 @@ InteractionDialog::InteractionDialog( intf_thread_t *_p_intf,
     else
     /* Custom box, finish it */
     {
-        QVLCFrame::doButtons( this, layout,
-                              &defaultButton, p_dialog->psz_default_button,
-                              &altButton, p_dialog->psz_alternate_button,
-                              &otherButton, p_dialog->psz_other_button );
+        QDialogButtonBox *buttonBox = new QDialogButtonBox;
+
+        if( p_dialog->psz_default_button )
+        {
+            defaultButton = new QPushButton;
+            defaultButton->setFocus();
+            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 ) );
+            buttonBox->addButton( altButton, QDialogButtonBox::RejectRole );
+        }
+        if( p_dialog->psz_other_button )
+        {
+            otherButton = new QPushButton;
+            otherButton->setText( qfu( p_dialog->psz_other_button ) );
+            buttonBox->addButton( otherButton, QDialogButtonBox::ActionRole );
+        }
+        layout->addWidget( buttonBox );
         if( p_dialog->psz_default_button )
-            connect( defaultButton, SIGNAL( clicked() ),
-                     this, SLOT( defaultB() ) );
+            BUTTONACT( defaultButton, defaultB() );
         if( p_dialog->psz_alternate_button )
-            connect( altButton, SIGNAL( clicked() ), this, SLOT( altB() ) );
+            BUTTONACT( altButton, altB() );
         if( p_dialog->psz_other_button )
-            connect( otherButton, SIGNAL( clicked() ), this, SLOT( 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) );
+        msg_Err( p_intf, "Setting progress to %i\n", progressBar->value() );
     }
 }
 
 InteractionDialog::~InteractionDialog()
 {
-    if( panel ) delete panel;
+//    if( panel ) delete panel;
+    if( dialog ) delete dialog;
 }
 
 void InteractionDialog::defaultB()
@@ -185,4 +216,5 @@ void InteractionDialog::Finish( int i_ret )
     p_dialog->i_return = i_ret;
     hide();
     vlc_mutex_unlock( &p_dialog->p_interaction->object_lock );
+    playlist_Signal( THEPL );
 }