]> git.sesse.net Git - vlc/commitdiff
Add an "update button" to update the modules tree.
authorRémi Duraffort <ivoire@videolan.org>
Tue, 12 Feb 2008 10:30:41 +0000 (10:30 +0000)
committerRémi Duraffort <ivoire@videolan.org>
Tue, 12 Feb 2008 10:30:41 +0000 (10:30 +0000)
modules/gui/qt4/dialogs/messages.cpp
modules/gui/qt4/dialogs/messages.hpp

index 478fcaa799dba94d592fe0349b29f8d8402fb82b..ca3f1cbe2c2d08038e3ec52df24c74b83902dff7 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,10 +77,11 @@ 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..." ) );
 
     verbosityBox = new QSpinBox();
@@ -94,11 +96,11 @@ MessagesDialog::MessagesDialog( intf_thread_t *_p_intf)
     mainLayout->addWidget( verbosityLabel, 1, 0, 1, 1 );
     mainLayout->addWidget( verbosityBox, 1, 1 );
     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 +111,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();
     }
 }
@@ -221,6 +225,14 @@ void MessagesDialog::buildTree( QTreeWidgetItem *parentItem,
     vlc_object_release( p_obj );
 }
 
+void MessagesDialog::clearOrUpdate()
+{
+    if( mainTab->currentIndex() )
+        updateTree();
+    else
+        clear();
+}
+
 void MessagesDialog::updateTree()
 {
     modulesTree->clear();
index 008510d469c1bd4da235f2002c2ef0ad7f5f9a2f..4ca1b1744cef4b51a003fe9c4e546c38fb22df8b 100644 (file)
@@ -26,6 +26,7 @@
 
 #include "util/qvlcframe.hpp"
 
+class QTabWidget;
 class QPushButton;
 class QSpinBox;
 class QGridLayout;
@@ -55,19 +56,21 @@ public:
 private:
     MessagesDialog( intf_thread_t * );
     static MessagesDialog *instance;
+    QTabWidget *mainTab;
     QSpinBox *verbosityBox;
     QLabel *verbosityLabel;
     QTextEdit *messages;
     QTreeWidget *modulesTree;
-    QPushButton *clearButton;
+    QPushButton *clearUpdateButton;
     QPushButton *saveLogButton;
 
 private slots:
     void updateTab( int );
     void updateLog();
-    void clear();
+    void clearOrUpdate();
     bool save();
 private:
+    void clear();
     void updateTree();
     void buildTree( QTreeWidgetItem *, vlc_object_t * );
 };