]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/dialogs/messages.cpp
Merge branch 'df-for-upstream' of git://repo.or.cz/vlc/davidf-public
[vlc] / modules / gui / qt4 / dialogs / messages.cpp
index 478fcaa799dba94d592fe0349b29f8d8402fb82b..59e8fbad0c530a0528120325fa7fa81af175b0be 100644 (file)
@@ -49,9 +49,10 @@ MessagesDialog::MessagesDialog( intf_thread_t *_p_intf)
 
     /* General widgets */
     QGridLayout *mainLayout = new QGridLayout( this );
-    QTabWidget  *mainTab = new QTabWidget( this );
+    mainTab = new QTabWidget( this );
     mainTab->setTabPosition( QTabWidget::North );
 
+
     /* Messages */
     QWidget     *msgWidget = new QWidget;
     QGridLayout *msgLayout = new QGridLayout( msgWidget );
@@ -76,11 +77,13 @@ MessagesDialog::MessagesDialog( intf_thread_t *_p_intf)
     treeLayout->addWidget( modulesTree, 0, 0, 1, 0 );
     mainTab->addTab( treeWidget, qtr( "Modules tree" ) );
 
+
     /* Buttons and general layout */
     QPushButton *closeButton = new QPushButton( qtr( "&Close" ) );
     closeButton->setDefault( true );
-    clearButton = new QPushButton( qtr( "&Clear" ) );
+    clearUpdateButton = new QPushButton( qtr( "&Clear" ) );
     saveLogButton = new QPushButton( qtr( "&Save as..." ) );
+    saveLogButton->setToolTip( qtr( "Save all the displayed logs to a file" ) );
 
     verbosityBox = new QSpinBox();
     verbosityBox->setRange( 0, 2 );
@@ -93,12 +96,13 @@ MessagesDialog::MessagesDialog( intf_thread_t *_p_intf)
     mainLayout->addWidget( mainTab, 0, 0, 1, 0 );
     mainLayout->addWidget( verbosityLabel, 1, 0, 1, 1 );
     mainLayout->addWidget( verbosityBox, 1, 1 );
+    mainLayout->setColumnStretch( 2, 10 );
     mainLayout->addWidget( saveLogButton, 1, 3 );
-    mainLayout->addWidget( clearButton, 1, 4 );
+    mainLayout->addWidget( clearUpdateButton, 1, 4 );
     mainLayout->addWidget( closeButton, 1, 5 );
 
     BUTTONACT( closeButton, hide() );
-    BUTTONACT( clearButton, clear() );
+    BUTTONACT( clearUpdateButton, clearOrUpdate() );
     BUTTONACT( saveLogButton, save() );
     CONNECT( mainTab, currentChanged( int ),
              this, updateTab( int ) );
@@ -109,19 +113,21 @@ MessagesDialog::MessagesDialog( intf_thread_t *_p_intf)
 
 void MessagesDialog::updateTab( int index )
 {
+    /* Second tab : modules tree */
     if( index == 1 )
     {
         verbosityLabel->hide();
         verbosityBox->hide();
-        clearButton->hide();
+        clearUpdateButton->setText( qtr( "&Update" ) );
         saveLogButton->hide();
         updateTree();
     }
+    /* First tab : messages */
     else
     {
         verbosityLabel->show();
         verbosityBox->show();
-        clearButton->show();
+        clearUpdateButton->setText( qtr( "&Clear" ) );
         saveLogButton->show();
     }
 }
@@ -195,7 +201,6 @@ void MessagesDialog::updateLog()
 void MessagesDialog::buildTree( QTreeWidgetItem *parentItem,
                                 vlc_object_t *p_obj )
 {
-    vlc_object_yield( p_obj );
     QTreeWidgetItem *item;
 
     if( parentItem )
@@ -213,18 +218,23 @@ void MessagesDialog::buildTree( QTreeWidgetItem *parentItem,
 
     item->setExpanded( true );
 
-    for( int i=0; i < p_obj->i_children; i++ )
-    {
-        buildTree( item, p_obj->pp_children[i]);
-    }
+    vlc_list_t *l = vlc_list_children( p_obj );
+    for( int i=0; i < l->i_count; i++ )
+        buildTree( item, l->p_values[i].p_object );
+    vlc_list_release( l );
+}
 
-    vlc_object_release( p_obj );
+void MessagesDialog::clearOrUpdate()
+{
+    if( mainTab->currentIndex() )
+        updateTree();
+    else
+        clear();
 }
 
 void MessagesDialog::updateTree()
 {
     modulesTree->clear();
-
     buildTree( NULL, VLC_OBJECT( p_intf->p_libvlc ) );
 }
 
@@ -236,8 +246,8 @@ void MessagesDialog::clear()
 bool MessagesDialog::save()
 {
     QString saveLogFileName = QFileDialog::getSaveFileName(
-            this, qtr( "Choose a filename to save the logs under..." ),
-            qfu( p_intf->p_libvlc->psz_homedir ),
+            this, qtr( "Select a name for the logs file" ),
+            qfu( config_GetHomeDir() ),
             qtr( "Texts / Logs (*.log *.txt);; All (*.*) ") );
 
     if( !saveLogFileName.isNull() )