]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/components/complete_preferences.cpp
Qt: preferences, show correctly the column items
[vlc] / modules / gui / qt4 / components / complete_preferences.cpp
index cc85b9c6c2f6eb660af5488dc5990019803223d9..9a9202a2c884ce3029643b393fc6ecddfb626994 100644 (file)
 #include <QGroupBox>
 #include <QScrollArea>
 #include <QVBoxLayout>
-#include <QHBoxLayout>
 #include <QGridLayout>
 #include <QHeaderView>
-#include <QPalette>
-#include <QColor>
 
 #include "components/complete_preferences.hpp"
 #include "components/preferences_widgets.hpp"
@@ -56,33 +53,32 @@ PrefsTree::PrefsTree( intf_thread_t *_p_intf, QWidget *_parent ) :
                             QTreeWidget( _parent ), p_intf( _p_intf )
 {
     /* General Qt options */
-    setColumnCount( 1 );
     setAlternatingRowColors( true );
-    header()->hide();
+    setHeaderHidden( true );
 
     setIconSize( QSize( ITEM_HEIGHT,ITEM_HEIGHT ) );
     setTextElideMode( Qt::ElideNone );
 
     /* Nice icons */
-#define BI( a,b) QIcon a##_icon = QIcon( QPixmap( b ))
-    BI( audio, ":/advprefs_audio" );
-    BI( video, ":/advprefs_video" );
-    BI( input, ":/advprefs_codec" );
-    BI( sout, ":/advprefs_sout" );
-    BI( advanced, ":/advprefs_extended" );
-    BI( playlist, ":/advprefs_playlist" );
-    BI( interface, ":/advprefs_intf" );
+#define BI( a,b) QIcon a##_icon = QIcon( )
+    BI( audio, ":/prefsmenu/advanced/audio" );
+    BI( video, ":/prefsmenu/advanced/video" );
+    BI( input, ":/prefsmenu/advanced/codec" );
+    BI( sout, ":/prefsmenu/advanced/sout" );
+    BI( advanced, ":/prefsmenu/advanced/extended" );
+    BI( playlist, ":/prefsmenu/advanced/playlist" );
+    BI( interface, ":/prefsmenu/advanced/intf" );
 #undef BI
 
     /* Build the tree for the main module */
-    module_t *p_module = module_GetMainModule( p_intf );
+    module_t *p_module = module_get_main();
 
     /* Initialisation and get the confsize */
     PrefsItemData *data = NULL;
     PrefsItemData *data_sub = NULL;
     QTreeWidgetItem *current_item = NULL;
     unsigned confsize;
-    module_config_t *const p_config = module_GetConfig (p_module, &confsize);
+    module_config_t *const p_config = module_config_get (p_module, &confsize);
 
     /* Go through the list of conf */
     for( size_t i = 0; i < confsize; i++ )
@@ -128,7 +124,7 @@ PrefsTree::PrefsTree( intf_thread_t *_p_intf, QWidget *_parent ) :
             current_item = new QTreeWidgetItem();
             current_item->setText( 0, data->name );
             current_item->setIcon( 0 , icon );
-            current_item->setSizeHint( 0, QSize( -1, ITEM_HEIGHT ) );
+            //current_item->setSizeHint( 0, QSize( -1, ITEM_HEIGHT ) );
             current_item->setData( 0, Qt::UserRole,
                                    qVariantFromValue( data ) );
             addTopLevelItem( current_item );
@@ -178,11 +174,9 @@ PrefsTree::PrefsTree( intf_thread_t *_p_intf, QWidget *_parent ) :
             /* Create a new TreeWidget */
             QTreeWidgetItem *subcat_item = new QTreeWidgetItem();
             subcat_item->setText( 0, data_sub->name );
-            /* TODO : Choose the image */
-            //subcat_item->setIcon( 0 , XXX );
             subcat_item->setData( 0, Qt::UserRole,
                                   qVariantFromValue( data_sub ) );
-            subcat_item->setSizeHint( 0, QSize( -1, ITEM_HEIGHT ) );
+            //subcat_item->setSizeHint( 0, QSize( -1, ITEM_HEIGHT ) );
 
             /* Add it to the parent */
             assert( current_item );
@@ -192,24 +186,22 @@ PrefsTree::PrefsTree( intf_thread_t *_p_intf, QWidget *_parent ) :
         /* Other items don't need yet a place on the tree */
         }
     }
-    module_PutConfig( p_config );
-    vlc_object_release( (vlc_object_t*)p_module );
+    module_config_free( p_config );
+    module_release( p_module );
 
 
-    vlc_list_t *p_list = vlc_list_find( p_intf, VLC_OBJECT_MODULE,
-                                        FIND_ANYWHERE );
+    module_t **p_list = module_list_get( NULL );
     /* Build the tree of plugins */
-    for( int i_index = 0; i_index < p_list->i_count; i_index++ )
+    for( size_t i = 0; (p_module = p_list[i]) != NULL; i++ )
     {
-        /* Take every module */
-        p_module = (module_t *)p_list->p_values[i_index].p_object;
-
         // Main module excluded
-        if( module_IsMainModule( p_module) ) continue;
+        if( module_is_main( p_module) ) continue;
+
+        unsigned  confsize;
+        int i_subcategory = 0, i_category = 0;
 
-        unsigned i_subcategory = 0, i_category = 0, confsize;
         bool b_options = false;
-        module_config_t *const p_config = module_GetConfig (p_module, &confsize);
+        module_config_t *const p_config = module_config_get (p_module, &confsize);
 
         /* Loop through the configurations items */
         for (size_t i = 0; i < confsize; i++)
@@ -227,7 +219,7 @@ PrefsTree::PrefsTree( intf_thread_t *_p_intf, QWidget *_parent ) :
             if( b_options && i_category && i_subcategory )
                 break;
         }
-        module_PutConfig (p_config);
+        module_config_free (p_config);
 
         /* Dummy item, please proceed */
         if( !b_options || i_category == 0 || i_subcategory == 0 ) continue;
@@ -272,22 +264,21 @@ PrefsTree::PrefsTree( intf_thread_t *_p_intf, QWidget *_parent ) :
 
         PrefsItemData *module_data = new PrefsItemData();
         module_data->i_type = TYPE_MODULE;
-        module_data->psz_name = strdup( module_GetObjName( p_module ) );
+        module_data->psz_name = strdup( module_get_object( p_module ) );
         module_data->help.clear();
-        // TODO image
         QTreeWidgetItem *module_item = new QTreeWidgetItem();
-        module_item->setText( 0, qtr( module_GetName( p_module, false ) ) );
-        //item->setIcon( 0 , XXX );
+        module_item->setText( 0, qtr( module_get_name( p_module, false ) ) );
         module_item->setData( 0, Qt::UserRole,
                               QVariant::fromValue( module_data) );
-        module_item->setSizeHint( 0, QSize( -1, ITEM_HEIGHT ) );
+        //module_item->setSizeHint( 0, QSize( -1, ITEM_HEIGHT ) );
         subcat_item->addChild( module_item );
     }
 
     /* We got everything, just sort a bit */
     sortItems( 0, Qt::AscendingOrder );
 
-    vlc_list_release( p_list );
+    module_list_free( p_list );
+    resizeColumnToContents( 0 );
 }
 
 PrefsTree::~PrefsTree() {}
@@ -362,15 +353,15 @@ AdvPrefsPanel::AdvPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
     if( data->i_type == TYPE_CATEGORY )
         return;
     else if( data->i_type == TYPE_MODULE )
-        p_module = module_Find( p_intf, data->psz_name );
+        p_module = module_find( data->psz_name );
     else
     {
-        p_module = module_GetMainModule( p_intf );
+        p_module = module_get_main();
         assert( p_module );
     }
 
     unsigned confsize;
-    module_config_t *const p_config = module_GetConfig (p_module, &confsize),
+    module_config_t *const p_config = module_config_get (p_module, &confsize),
                     *p_item = p_config,
                     *p_end = p_config + confsize;
 
@@ -378,11 +369,11 @@ AdvPrefsPanel::AdvPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
     {
         while (p_item < p_end)
         {
-            if( p_item->i_type == CONFIG_SUBCATEGORY &&
-                            ( data->i_type == TYPE_SUBCATEGORY &&
+            if(  p_item->i_type == CONFIG_SUBCATEGORY &&
+                            ( data->i_type == TYPE_SUBCATEGORY &&
                               p_item->value.i == data->i_object_id ) ||
                             ( data->i_type == TYPE_CATSUBCAT &&
-                              p_item->value.i == data->i_subcat_id ) )
+                              p_item->value.i == data->i_subcat_id ) ) )
                 break;
             p_item++;
         }
@@ -403,7 +394,7 @@ AdvPrefsPanel::AdvPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
     }
     else
     {
-        const char *psz_help = module_GetHelp (p_module);
+        const char *psz_help = module_get_help (p_module);
         head = QString( qtr( module_GetLongName( p_module ) ) );
         if( psz_help )
         {
@@ -415,7 +406,6 @@ AdvPrefsPanel::AdvPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
     QLabel *titleLabel = new QLabel( head );
     QFont titleFont = QApplication::font( static_cast<QWidget*>(0) );
     titleFont.setPointSize( titleFont.pointSize() + 6 );
-    titleFont.setFamily( "Verdana" );
     titleLabel->setFont( titleFont );
 
     // Title <hr>
@@ -461,7 +451,7 @@ AdvPrefsPanel::AdvPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
                 layout->addWidget( box, i_line, 0, 1, -1 );
                 i_line++;
             }
-            box = new QGroupBox( qtr( p_item->psz_text ) );
+            box = new QGroupBox( qtr( p_item->psz_text ), this );
             box->hide();
             boxlayout = new QGridLayout();
         }
@@ -476,10 +466,10 @@ AdvPrefsPanel::AdvPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
         ConfigControl *control;
         if( ! box )
             control = ConfigControl::createControl( VLC_OBJECT( p_intf ),
-                                        p_item, NULL, layout, i_line );
+                                        p_item, this, layout, i_line );
         else
             control = ConfigControl::createControl( VLC_OBJECT( p_intf ),
-                                    p_item, NULL, boxlayout, i_boxline );
+                                    p_item, this, boxlayout, i_boxline );
         if( !control )
             continue;
 
@@ -500,7 +490,7 @@ AdvPrefsPanel::AdvPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
         layout->addWidget( box, i_line, 0, 1, -1 );
     }
 
-    module_Put( p_module );
+    module_release (p_module);
 
     scrolled_area->setSizePolicy( QSizePolicy::Preferred,QSizePolicy::Fixed );
     scrolled_area->setLayout( layout );