[vlc-commits] [Git][videolan/vlc][master] 7 commits: config: fix incorrect header guard name

Hugo Beauzée-Luyssen (@chouquette) gitlab at videolan.org
Wed Dec 15 11:43:22 UTC 2021



Hugo Beauzée-Luyssen pushed to branch master at VideoLAN / VLC


Commits:
74046ea9 by Lyndon Brown at 2021-12-15T11:26:43+00:00
config: fix incorrect header guard name

this stuff is used by prefs, and is not even used by help currently.

- - - - -
0db30968 by Lyndon Brown at 2021-12-15T11:26:43+00:00
config: move struct to where it belongs

it is used only to define the structure of `categories_array` which
lives in `vlc_config_cat.h`; it belongs next to that.

- - - - -
e9edfd60 by Lyndon Brown at 2021-12-15T11:26:43+00:00
config: split the cat/subcat table and name/help getters

...to prepare for divergence in the data held for categories vs.
subcategories.

we replace here the generic helpers:
 - `config_CategoryNameGet()`
 - `config_CategoryHelpGet()`

with:
 - `vlc_config_cat_GetName()`
 - `vlc_config_cat_GetHelp()`
 - `vlc_config_subcat_GetName()`
 - `vlc_config_subcat_GetHelp()`

the new names conform to the format requested for the
`vlc_config_subcat_IsGeneral()` function added in MR 313.

opportunity was taken to remove the old style prefixes from the attributes
of `config_category_t`, affecting a few additional lines, avoiding
introducing inconsistency or new instances of the old style with the
addition of `config_subcategory_t`.

- - - - -
5569648c by Lyndon Brown at 2021-12-15T11:26:43+00:00
config: add and use index-of helpers for cat/subcat array iteration

these 'index-of' helpers find the index for the given cat/subcat. this
allows us to de-duplicate the code from the other helper functions (both
for those that already exist and ones to be added in further commits).
they loop based upon array length rather than looking out for some
particular condition of varying properties in an end marker record,
allowing us to also drop those.

i used an index-of design here rather than have functions that return
pointers because there will be a secondary use for index-of helpers in
later commits.

- - - - -
b12d45d1 by Lyndon Brown at 2021-12-15T11:26:43+00:00
qt: clarify prefs tree construction documentation

with respect to plugin vs. module.

before we adjust it in the next commit.

- - - - -
e967f81f by Lyndon Brown at 2021-12-15T11:26:43+00:00
config: lookup cat from subcat

having `set_category()` + `set_subcategory()` pairs of calls to setup the
location in the preferences tree where a plugin node needs to be attached
to, with corresponding pairs of option records in the plugin option sets,
is silly, inefficient and bug prone. all we need is the subcat records
and we can look up the corresponding cat from the data table when it
comes to time to build the tree.

here we take a step forward to address this, adding cat data to the subcat
data table, and a lookup function making use of it.

note, qt and macos tree construction are done a little differently from
each other, so while the change here is entirely sufficient to rid the core
option set of category hints as far as the macos code is concerned, more
work in a subsequent commit will be needed for qt. thus the purge of
`set_category()` must be postponed for a later commit and so for now we
must just ignore those records.

a subcat table entry was added for `SUBCAT_HIDDEN` since for now the qt
code could potentially look this up and we should preserve the existing
behaviour for it for now.

- - - - -
68039794 by Lyndon Brown at 2021-12-15T11:26:43+00:00
qt: build the prefs tree without needing cat hints

...and indeed ignoring them.

as per the previous commit, we want to get rid of cat hints from option
sets, instead looking up cats from subcats. we have already implemented in
the previous commit the lookup mechanism, and started ignoring cat hints
from plugins, but still relied upon them from the core set for constructing
the base tree (and reacted to them in building core panels).

here we adjust the base tree construction code to completely remove our
reliance upon cat hints. we also now completely ignore them when building
core panels (no difference results from this).

we are now in a position to purge the cat items themselves from the entire
infrastructure along with all remaining artefacts, though that will be done
separately later.

note that the macos code needed no such change here, it was taken care of
completely in the previous commit.

- - - - -


5 changed files:

- include/vlc_config_cat.h
- include/vlc_configuration.h
- modules/gui/macosx/preferences/prefs.m
- modules/gui/qt/dialogs/preferences/complete_preferences.cpp
- modules/gui/qt/dialogs/preferences/complete_preferences.hpp


Changes:

=====================================
include/vlc_config_cat.h
=====================================
@@ -21,8 +21,9 @@
  * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
-#ifndef VLC_HELP_H
-#define VLC_HELP_H 1
+#ifndef VLC_CONFIG_CAT_H
+#define VLC_CONFIG_CAT_H
+
 # include <vlc_plugin.h>
 
 /*
@@ -191,87 +192,147 @@
 #define ANETWORK_TITLE N_( "Network" )
 #define ANETWORK_HELP N_( "Advanced network settings." )
 
+struct config_category_t
+{
+    int         id;
+    const char *name;
+    const char *help;
+};
+
+struct config_subcategory_t
+{
+    int         id;
+    int         cat;
+    const char *name;
+    const char *help;
+};
+
 static const struct config_category_t categories_array[] =
 {
-    /* Interface */
-    { CAT_INTERFACE, INTF_TITLE, INTF_HELP },
-    { SUBCAT_INTERFACE_GENERAL, INTF_TITLE, INTF_GENERAL_HELP },
-    { SUBCAT_INTERFACE_MAIN, INTF_MAIN_TITLE, INTF_MAIN_HELP },
-    { SUBCAT_INTERFACE_CONTROL, INTF_CONTROL_TITLE, INTF_CONTROL_HELP },
-    { SUBCAT_INTERFACE_HOTKEYS, INTF_HOTKEYS_TITLE, INTF_HOTKEYS_HELP },
-
-    { CAT_AUDIO, AUDIO_TITLE, AUDIO_HELP },
-    { SUBCAT_AUDIO_GENERAL, AUDIO_TITLE, AUDIO_GENERAL_HELP },
-    { SUBCAT_AUDIO_AOUT, AOUT_TITLE, AOUT_HELP },
-    { SUBCAT_AUDIO_AFILTER, AFILTER_TITLE, AFILTER_HELP },
-    { SUBCAT_AUDIO_RESAMPLER, ARESAMPLER_TITLE, AFILTER_HELP },
-    { SUBCAT_AUDIO_VISUAL, AVISUAL_TITLE, AVISUAL_HELP },
-
-    { CAT_VIDEO, VIDEO_TITLE, VIDEO_HELP },
-    { SUBCAT_VIDEO_GENERAL, VIDEO_TITLE, VIDEO_GENERAL_HELP },
-    { SUBCAT_VIDEO_VOUT, _VOUT_TITLE, VOUT_HELP },
-    { SUBCAT_VIDEO_VFILTER, VFILTER_TITLE, VFILTER_HELP },
-    { SUBCAT_VIDEO_SUBPIC, SUBPIC_TITLE, SUBPIC_HELP },
-    { SUBCAT_VIDEO_SPLITTER, SPLITTER_TITLE, SPLITTER_HELP },
-
-    { CAT_INPUT, INPUT_TITLE, INPUT_HELP },
-    { SUBCAT_INPUT_GENERAL, INPUT_TITLE, INPUT_HELP },
-    { SUBCAT_INPUT_ACCESS, ACCESS_TITLE, ACCESS_HELP },
-    { SUBCAT_INPUT_DEMUX, DEMUX_TITLE, DEMUX_HELP },
-    { SUBCAT_INPUT_VCODEC, VDEC_TITLE, VDEC_HELP },
-    { SUBCAT_INPUT_ACODEC, ADEC_TITLE, ADEC_HELP },
-    { SUBCAT_INPUT_SCODEC, SDEC_TITLE, SDEC_HELP },
-    { SUBCAT_INPUT_STREAM_FILTER, STREAM_FILTER_TITLE, STREAM_FILTER_HELP },
-
-    { CAT_SOUT, SOUT_TITLE, SOUT_HELP },
-    { SUBCAT_SOUT_GENERAL, SOUT_TITLE, SOUT_GENERAL_HELP },
-    { SUBCAT_SOUT_STREAM, SOUT_STREAM_TITLE, SOUT_STREAM_HELP },
-    { SUBCAT_SOUT_MUX, SOUT_MUX_TITLE, SOUT_MUX_HELP },
-    { SUBCAT_SOUT_ACO, SOUT_ACO_TITLE, SOUT_ACO_HELP },
-    { SUBCAT_SOUT_PACKETIZER, SOUT_PACKET_TITLE, SOUT_PACKET_HELP },
-    { SUBCAT_SOUT_RENDERER, SOUT_RENDER_TITLE, SOUT_RENDER_HELP },
-    { SUBCAT_SOUT_VOD, SOUT_VOD_TITLE, SOUT_VOD_HELP },
-
-    { CAT_PLAYLIST, PLAYLIST_TITLE , PLAYLIST_HELP },
-    { SUBCAT_PLAYLIST_GENERAL, PLAYLIST_TITLE, PGENERAL_HELP },
-    { SUBCAT_PLAYLIST_EXPORT, PEXPORT_TITLE, PEXPORT_HELP },
-    { SUBCAT_PLAYLIST_SD, SD_TITLE, SD_HELP },
-
-    { CAT_ADVANCED, AADVANCED_TITLE, AADVANCED_HELP },
-    { SUBCAT_ADVANCED_MISC, MISC_TITLE, AADVANCED_HELP },
-    { SUBCAT_ADVANCED_NETWORK, ANETWORK_TITLE, ANETWORK_HELP },
-
-    { -1, NULL, NULL }
+    { CAT_INTERFACE,  INTF_TITLE,       INTF_HELP      },
+    { CAT_AUDIO,      AUDIO_TITLE,      AUDIO_HELP     },
+    { CAT_VIDEO,      VIDEO_TITLE,      VIDEO_HELP     },
+    { CAT_INPUT,      INPUT_TITLE,      INPUT_HELP     },
+    { CAT_SOUT,       SOUT_TITLE,       SOUT_HELP      },
+    { CAT_PLAYLIST,   PLAYLIST_TITLE,   PLAYLIST_HELP  },
+    { CAT_ADVANCED,   AADVANCED_TITLE,  AADVANCED_HELP },
 };
 
+static const struct config_subcategory_t subcategories_array[] =
+{
+    { SUBCAT_INTERFACE_GENERAL,    CAT_INTERFACE,  INTF_TITLE,           INTF_GENERAL_HELP  },
+    { SUBCAT_INTERFACE_MAIN,       CAT_INTERFACE,  INTF_MAIN_TITLE,      INTF_MAIN_HELP     },
+    { SUBCAT_INTERFACE_CONTROL,    CAT_INTERFACE,  INTF_CONTROL_TITLE,   INTF_CONTROL_HELP  },
+    { SUBCAT_INTERFACE_HOTKEYS,    CAT_INTERFACE,  INTF_HOTKEYS_TITLE,   INTF_HOTKEYS_HELP  },
+
+    { SUBCAT_AUDIO_GENERAL,        CAT_AUDIO,      AUDIO_TITLE,          AUDIO_GENERAL_HELP },
+    { SUBCAT_AUDIO_AOUT,           CAT_AUDIO,      AOUT_TITLE,           AOUT_HELP          },
+    { SUBCAT_AUDIO_AFILTER,        CAT_AUDIO,      AFILTER_TITLE,        AFILTER_HELP       },
+    { SUBCAT_AUDIO_RESAMPLER,      CAT_AUDIO,      ARESAMPLER_TITLE,     AFILTER_HELP       },
+    { SUBCAT_AUDIO_VISUAL,         CAT_AUDIO,      AVISUAL_TITLE,        AVISUAL_HELP       },
+
+    { SUBCAT_VIDEO_GENERAL,        CAT_VIDEO,      VIDEO_TITLE,          VIDEO_GENERAL_HELP },
+    { SUBCAT_VIDEO_VOUT,           CAT_VIDEO,      _VOUT_TITLE,          VOUT_HELP          },
+    { SUBCAT_VIDEO_VFILTER,        CAT_VIDEO,      VFILTER_TITLE,        VFILTER_HELP       },
+    { SUBCAT_VIDEO_SUBPIC,         CAT_VIDEO,      SUBPIC_TITLE,         SUBPIC_HELP        },
+    { SUBCAT_VIDEO_SPLITTER,       CAT_VIDEO,      SPLITTER_TITLE,       SPLITTER_HELP      },
+
+    { SUBCAT_INPUT_GENERAL,        CAT_INPUT,      INPUT_TITLE,          INPUT_HELP         },
+    { SUBCAT_INPUT_ACCESS,         CAT_INPUT,      ACCESS_TITLE,         ACCESS_HELP        },
+    { SUBCAT_INPUT_DEMUX,          CAT_INPUT,      DEMUX_TITLE,          DEMUX_HELP         },
+    { SUBCAT_INPUT_VCODEC,         CAT_INPUT,      VDEC_TITLE,           VDEC_HELP          },
+    { SUBCAT_INPUT_ACODEC,         CAT_INPUT,      ADEC_TITLE,           ADEC_HELP          },
+    { SUBCAT_INPUT_SCODEC,         CAT_INPUT,      SDEC_TITLE,           SDEC_HELP          },
+    { SUBCAT_INPUT_STREAM_FILTER,  CAT_INPUT,      STREAM_FILTER_TITLE,  STREAM_FILTER_HELP },
+
+    { SUBCAT_SOUT_GENERAL,         CAT_SOUT,       SOUT_TITLE,           SOUT_GENERAL_HELP  },
+    { SUBCAT_SOUT_STREAM,          CAT_SOUT,       SOUT_STREAM_TITLE,    SOUT_STREAM_HELP   },
+    { SUBCAT_SOUT_MUX,             CAT_SOUT,       SOUT_MUX_TITLE,       SOUT_MUX_HELP      },
+    { SUBCAT_SOUT_ACO,             CAT_SOUT,       SOUT_ACO_TITLE,       SOUT_ACO_HELP      },
+    { SUBCAT_SOUT_PACKETIZER,      CAT_SOUT,       SOUT_PACKET_TITLE,    SOUT_PACKET_HELP   },
+    { SUBCAT_SOUT_RENDERER,        CAT_SOUT,       SOUT_RENDER_TITLE,    SOUT_RENDER_HELP   },
+    { SUBCAT_SOUT_VOD,             CAT_SOUT,       SOUT_VOD_TITLE,       SOUT_VOD_HELP      },
+
+    { SUBCAT_PLAYLIST_GENERAL,     CAT_PLAYLIST,   PLAYLIST_TITLE,       PGENERAL_HELP      },
+    { SUBCAT_PLAYLIST_EXPORT,      CAT_PLAYLIST,   PEXPORT_TITLE,        PEXPORT_HELP       },
+    { SUBCAT_PLAYLIST_SD,          CAT_PLAYLIST,   SD_TITLE,             SD_HELP            },
+
+    { SUBCAT_ADVANCED_MISC,        CAT_ADVANCED,   MISC_TITLE,           AADVANCED_HELP     },
+    { SUBCAT_ADVANCED_NETWORK,     CAT_ADVANCED,   ANETWORK_TITLE,       ANETWORK_HELP      },
+
+    { SUBCAT_HIDDEN,               CAT_HIDDEN,     NULL,                 NULL               },
+};
+
+/** Get the table index for the given category entry. */
 VLC_USED
-static inline const char *config_CategoryNameGet( int i_value )
+static inline int vlc_config_cat_IndexOf( int cat )
 {
-    int i = 0;
-    while( categories_array[i].psz_name != NULL )
+    int index = -1;
+    for( unsigned i = 0; i < ARRAY_SIZE(categories_array); i++ )
     {
-        if( categories_array[i].i_id == i_value )
+        if( categories_array[i].id == cat )
         {
-            return vlc_gettext(categories_array[i].psz_name);
+            index = i;
+            break;
         }
-        i++;
     }
-    return NULL;
+    return index;
 }
 
+/** Get the table index for the given subcategory entry. */
 VLC_USED
-static inline const char *config_CategoryHelpGet( int i_value )
+static inline int vlc_config_subcat_IndexOf( int subcat )
 {
-    int i = 0;
-    while( categories_array[i].psz_help != NULL )
+    int index = -1;
+    for( unsigned i = 0; i < ARRAY_SIZE(subcategories_array); i++ )
     {
-        if( categories_array[i].i_id == i_value )
+        if( subcategories_array[i].id == subcat )
         {
-            return vlc_gettext(categories_array[i].psz_help);
+            index = i;
+            break;
         }
-        i++;
     }
-    return NULL;
+    return index;
+}
+
+/** Get the name for a category. */
+VLC_USED
+static inline const char *vlc_config_cat_GetName( int cat )
+{
+    int i = vlc_config_cat_IndexOf( cat );
+    return (i != -1) ? vlc_gettext(categories_array[i].name) : NULL;
+}
+
+/** Get the help text for a category. */
+VLC_USED
+static inline const char *vlc_config_cat_GetHelp( int cat )
+{
+    int i = vlc_config_cat_IndexOf( cat );
+    return (i != -1) ? vlc_gettext(categories_array[i].help) : NULL;
+}
+
+/** Get the name for a subcategory. */
+VLC_USED
+static inline const char *vlc_config_subcat_GetName( int subcat )
+{
+    int i = vlc_config_subcat_IndexOf( subcat );
+    return (i != -1) ? vlc_gettext(subcategories_array[i].name) : NULL;
+}
+
+/** Get the help text for a subcategory. */
+VLC_USED
+static inline const char *vlc_config_subcat_GetHelp( int subcat )
+{
+    int i = vlc_config_subcat_IndexOf( subcat );
+    return (i != -1) ? vlc_gettext(subcategories_array[i].help) : NULL;
+}
+
+/** Get the parent category for the given subcategory. */
+VLC_USED
+static inline int vlc_config_cat_FromSubcat( int subcat )
+{
+    int i = vlc_config_subcat_IndexOf( subcat );
+    return (i != -1) ? subcategories_array[i].cat : CAT_UNKNOWN;
 }
 
 /** Check if the given subcategory is a "general" one.
@@ -307,4 +368,4 @@ static inline bool vlc_config_subcat_IsGeneral( int subcat )
     }
 }
 
-#endif /* VLC_HELP_H */
+#endif /* VLC_CONFIG_CAT_H */


=====================================
include/vlc_configuration.h
=====================================
@@ -49,13 +49,6 @@
 extern "C" {
 # endif
 
-struct config_category_t
-{
-    int         i_id;
-    const char *psz_name;
-    const char *psz_help;
-};
-
 typedef union
 {
     char       *psz;


=====================================
modules/gui/macosx/preferences/prefs.m
=====================================
@@ -475,6 +475,7 @@
         VLCTreeSubCategoryItem * subCategoryItem = nil;
         VLCTreePluginItem * pluginItem = nil;
         module_config_t *p_configs = NULL;
+        int lastcat = CAT_UNKNOWN;
         int lastsubcat = SUBCAT_UNKNOWN;
         unsigned int confsize;
 
@@ -496,26 +497,25 @@
         for (unsigned int j = 0; j < confsize; j++) {
             int configType = p_configs[j].i_type;
 
-            if (configType == CONFIG_CATEGORY) {
-                if( p_configs[j].value.i == CAT_HIDDEN ) {
+            if (configType == CONFIG_CATEGORY)
+                continue; /* ignore */
+
+            if (configType == CONFIG_SUBCATEGORY) {
+                lastsubcat = (int)p_configs[j].value.i;
+                if( lastsubcat == SUBCAT_HIDDEN ) {
                     categoryItem = nil;
+                    subCategoryItem = nil;
                     continue;
                 }
-                categoryItem = [self itemRepresentingCategory:(int)p_configs[j].value.i];
+                lastcat = vlc_config_cat_FromSubcat(lastsubcat);
+
+                categoryItem = [self itemRepresentingCategory:lastcat];
                 if (!categoryItem) {
-                    categoryItem = [VLCTreeCategoryItem categoryTreeItemWithCategory:(int)p_configs[j].value.i];
+                    categoryItem = [VLCTreeCategoryItem categoryTreeItemWithCategory:lastcat];
                     if (categoryItem)
                         [[self children] addObject:categoryItem];
                 }
-                continue;
-            }
 
-            if (configType == CONFIG_SUBCATEGORY) {
-                lastsubcat = (int)p_configs[j].value.i;
-                if( lastsubcat == SUBCAT_HIDDEN ) {
-                    subCategoryItem = nil;
-                    continue;
-                }
                 if (categoryItem && !vlc_config_subcat_IsGeneral(lastsubcat)) {
                     subCategoryItem = [categoryItem itemRepresentingSubCategory:lastsubcat];
                     if (!subCategoryItem) {
@@ -557,7 +557,7 @@
 @implementation VLCTreeCategoryItem
 + (VLCTreeCategoryItem *)categoryTreeItemWithCategory:(int)category
 {
-    if (!config_CategoryNameGet(category)) {
+    if (!vlc_config_cat_GetName(category)) {
         msg_Err(getIntf(), "failed to get name for category %i", category);
         return nil;
     }
@@ -566,10 +566,10 @@
 
 - (id)initWithCategory:(int)category
 {
-    NSString * name = _NS(config_CategoryNameGet(category));
+    NSString * name = _NS(vlc_config_cat_GetName(category));
     if (self = [super initWithName:name]) {
         _category = category;
-        //_help = [_NS(config_CategoryHelpGet(category)) retain];
+        //_help = [_NS(vlc_config_cat_GetHelp(category)) retain];
     }
     return self;
 }
@@ -597,17 +597,17 @@
 @implementation VLCTreeSubCategoryItem
 - (id)initWithSubCategory:(int)subCategory
 {
-    NSString * name = _NS(config_CategoryNameGet(subCategory));
+    NSString * name = _NS(vlc_config_subcat_GetName(subCategory));
     if (self = [super initWithName:name]) {
         _subCategory = subCategory;
-        //_help = [_NS(config_CategoryHelpGet(subCategory)) retain];
+        //_help = [_NS(vlc_config_subcat_GetHelp(subCategory)) retain];
     }
     return self;
 }
 
 + (VLCTreeSubCategoryItem *)subCategoryTreeItemWithSubCategory:(int)subCategory
 {
-    if (!config_CategoryNameGet(subCategory))
+    if (!vlc_config_subcat_GetName(subCategory))
         return nil;
     return [[[self class] alloc] initWithSubCategory:subCategory];
 }
@@ -627,7 +627,7 @@
     if (self = [super initWithName:name]) {
         _configItems = module_config_get(plugin, &_configSize);
         //_plugin = plugin;
-        //_help = [_NS(config_CategoryHelpGet(subCategory)) retain];
+        //_help = [_NS(vlc_config_subcat_GetHelp(subCategory)) retain];
     }
     return self;
 }


=====================================
modules/gui/qt/dialogs/preferences/complete_preferences.cpp
=====================================
@@ -79,35 +79,43 @@ PrefsTree::PrefsTree( qt_intf_t *_p_intf, QWidget *_parent,
     module_t *p_module = module_get_main();
 
     /* Initialisation and get the confsize */
+    int last_cat = CAT_UNKNOWN;
     PrefsItemData *data = NULL;
     PrefsItemData *data_sub = NULL;
     QTreeWidgetItem *current_item = NULL;
     unsigned confsize;
     module_config_t *const p_config = module_config_get (p_module, &confsize);
 
-    /* Go through the list of conf */
+    /* Go through the list of core conf to build the base tree */
     for( size_t i = 0; i < confsize; i++ )
     {
         QIcon icon;
 
-        /* Work on a new item */
         module_config_t *p_item = p_config + i;
 
-        switch( p_item->i_type )
+        if( p_item->i_type != CONFIG_SUBCATEGORY )
+            continue;
+
+        int subcat = p_item->value.i;
+        int cat = vlc_config_cat_FromSubcat(subcat);
+
+        if( cat == CAT_UNKNOWN || cat == CAT_HIDDEN )
+            continue;
+
+        /* Create parent cat node? */
+        if( cat != last_cat )
         {
-        /* This is a category */
-        case CONFIG_CATEGORY:
-            if( p_item->value.i == CAT_HIDDEN ) break;
+            last_cat = cat;
 
             /* PrefsItemData Init */
             data = new PrefsItemData( this );
-            data->name = qfu( config_CategoryNameGet( p_item->value.i ) );
-            data->help = qfu( config_CategoryHelpGet( p_item->value.i ) );
+            data->name = qfu( vlc_config_cat_GetName( cat ) );
+            data->help = qfu( vlc_config_cat_GetHelp( cat ) );
             data->i_type = PrefsItemData::TYPE_CATEGORY;
-            data->i_object_id = p_item->value.i;
+            data->i_object_id = cat;
 
             /* This is a category, put a nice icon */
-            switch( p_item->value.i )
+            switch( cat )
             {
 #define CI(a,b) case a: icon = b##_icon;break
             CI( CAT_AUDIO, audio );
@@ -129,48 +137,40 @@ PrefsTree::PrefsTree( qt_intf_t *_p_intf, QWidget *_parent,
                                    QVariant::fromValue( data ) );
             addTopLevelItem( current_item );
             expandItem( current_item );
-            break;
-
-        /* This is a subcategory */
-        case CONFIG_SUBCATEGORY:
-            if( p_item->value.i == SUBCAT_HIDDEN ) break;
-
-            /* Special cases: move the main subcategories to the parent cat*/
-            if( data && vlc_config_subcat_IsGeneral(p_item->value.i) )
-            {
-                /* Data still contains the correct thing */
-                data->i_type = PrefsItemData::TYPE_CATSUBCAT;
-                data->i_subcat_id = p_item->value.i;
-                data->name = qfu( config_CategoryNameGet( p_item->value.i ) );
-                data->help = qfu( config_CategoryHelpGet( p_item->value.i ) );
-                current_item->setData( 0, Qt::UserRole,
-                                       QVariant::fromValue( data ) );
-                continue;
-            }
-
-            /* Normal Subcategories */
-
-            /* Process the Data */
-            data_sub = new PrefsItemData( this );
-            data_sub->name = qfu( config_CategoryNameGet( p_item->value.i) );
-            data_sub->help = qfu( config_CategoryHelpGet( p_item->value.i ) );
-            data_sub->i_type = PrefsItemData::TYPE_SUBCATEGORY;
-            data_sub->i_object_id = p_item->value.i;
-
-            /* Create a new TreeWidget */
-            QTreeWidgetItem *subcat_item = new QTreeWidgetItem();
-            subcat_item->setText( 0, data_sub->name );
-            subcat_item->setData( 0, Qt::UserRole,
-                                  QVariant::fromValue( data_sub ) );
-            //subcat_item->setSizeHint( 0, QSize( -1, ITEM_HEIGHT ) );
-
-            /* Add it to the parent */
-            assert( current_item );
-            current_item->addChild( subcat_item );
-            break;
+        }
 
-        /* Other items don't need yet a place on the tree */
+        /* Special cases: move the general subcat to the parent cat */
+        if( data && vlc_config_subcat_IsGeneral(subcat) )
+        {
+            /* Data still contains the correct thing */
+            data->i_type = PrefsItemData::TYPE_CATSUBCAT;
+            data->i_subcat_id = subcat;
+            data->name = qfu( vlc_config_subcat_GetName( subcat ) );
+            data->help = qfu( vlc_config_subcat_GetHelp( subcat ) );
+            current_item->setData( 0, Qt::UserRole,
+                                   QVariant::fromValue( data ) );
+            continue;
         }
+
+        /* Normal Subcategories */
+
+        /* Process the Data */
+        data_sub = new PrefsItemData( this );
+        data_sub->name = qfu( vlc_config_subcat_GetName( subcat ) );
+        data_sub->help = qfu( vlc_config_subcat_GetHelp( subcat ) );
+        data_sub->i_type = PrefsItemData::TYPE_SUBCATEGORY;
+        data_sub->i_object_id = subcat;
+
+        /* Create a new TreeWidget */
+        QTreeWidgetItem *subcat_item = new QTreeWidgetItem();
+        subcat_item->setText( 0, data_sub->name );
+        subcat_item->setData( 0, Qt::UserRole,
+                              QVariant::fromValue( data_sub ) );
+        //subcat_item->setSizeHint( 0, QSize( -1, ITEM_HEIGHT ) );
+
+        /* Add it to the parent */
+        assert( current_item );
+        current_item->addChild( subcat_item );
     }
     module_config_free( p_config );
 
@@ -193,20 +193,24 @@ PrefsTree::PrefsTree( qt_intf_t *_p_intf, QWidget *_parent,
             const module_config_t *p_item = p_config + i;
 
             if( p_item->i_type == CONFIG_CATEGORY )
-                i_category = p_item->value.i;
-            else if( p_item->i_type == CONFIG_SUBCATEGORY )
+                continue; /* ignore */
+
+            if( p_item->i_type == CONFIG_SUBCATEGORY )
+            {
                 i_subcategory = p_item->value.i;
+                i_category = vlc_config_cat_FromSubcat( i_subcategory );
+            }
 
             if( CONFIG_ITEM(p_item->i_type) )
                 b_options = true;
 
-            if( b_options && i_category != CAT_UNKNOWN && i_subcategory != SUBCAT_UNKNOWN )
+            if( b_options && i_category != CAT_UNKNOWN )
                 break;
         }
         module_config_free (p_config);
 
         /* Dummy item, please proceed */
-        if( !b_options || i_category == CAT_UNKNOWN || i_subcategory == SUBCAT_UNKNOWN )
+        if( !b_options || i_category == CAT_UNKNOWN )
             continue;
 
         // Locate the category item;
@@ -480,8 +484,8 @@ PrefsItemData::PrefsItemData( QObject *_parent ) : QObject( _parent )
     b_loaded = false;
 }
 
-/* go over the module config items and search text in psz_text
- * also search the module name and head */
+/* go over the config items and search text in psz_text
+ * also search the node name and head */
 bool PrefsItemData::contains( const QString &text, Qt::CaseSensitivity cs )
 {
     if( this->i_type == TYPE_CATEGORY )
@@ -521,7 +525,7 @@ bool PrefsItemData::contains( const QString &text, Qt::CaseSensitivity cs )
         return true;
     }
 
-    /* check options belonging to this subcat or module */
+    /* check options belonging to this core subcat or plugin */
 
     unsigned confsize;
     module_config_t *const p_config = module_config_get (p_module, &confsize),
@@ -553,13 +557,16 @@ bool PrefsItemData::contains( const QString &text, Qt::CaseSensitivity cs )
 
     do
     {
-        if ( p_item->i_type == CONFIG_CATEGORY || p_item->i_type == CONFIG_SUBCATEGORY )
+        if ( p_item->i_type == CONFIG_CATEGORY )
+            continue; /* ignore */
+
+        if ( p_item->i_type == CONFIG_SUBCATEGORY )
         {
-            /* for core, if we hit a cat or subcat, stop */
+            /* for core, if we hit a subcat, stop */
             if ( is_core )
                 break;
-            /* a module's options are grouped under one node; we can/should
-               ignore all cat/subcat entries. */
+            /* a plugin's options are grouped under one node; we can/should
+               ignore all other subcat entries. */
             continue;
         }
 
@@ -673,8 +680,7 @@ AdvPrefsPanel::AdvPrefsPanel( qt_intf_t *_p_intf, QWidget *_parent,
                 p_item->value.i != data->i_object_id ) ||
               ( data->i_type == PrefsItemData::TYPE_CATSUBCAT  &&
                 p_item->value.i != data->i_subcat_id ) ) &&
-            ( p_item->i_type == CONFIG_CATEGORY ||
-              p_item->i_type == CONFIG_SUBCATEGORY ) )
+            p_item->i_type == CONFIG_SUBCATEGORY )
             break;
 
         if( p_item->i_type == CONFIG_SECTION )
@@ -715,8 +721,7 @@ AdvPrefsPanel::AdvPrefsPanel( qt_intf_t *_p_intf, QWidget *_parent,
     }
     while( !( ( data->i_type == PrefsItemData::TYPE_SUBCATEGORY ||
                data->i_type == PrefsItemData::TYPE_CATSUBCAT ) &&
-             ( p_item->i_type == CONFIG_CATEGORY ||
-               p_item->i_type == CONFIG_SUBCATEGORY ) )
+             p_item->i_type == CONFIG_SUBCATEGORY )
         && ( ++p_item < p_end ) );
 
     if( box && i_boxline > 0 )


=====================================
modules/gui/qt/dialogs/preferences/complete_preferences.hpp
=====================================
@@ -38,19 +38,18 @@
 /**
  * Notes:
  *
- * 1) Core's use of set_category()/set_subcategory() defines the base tree,
- *    with its options spread across it.
+ * 1) Core's use of set_subcategory() defines the base tree, with its options
+ *    spread across it.
  * 2) Certain subcats ('general' type) are not given a node under their cat,
  *    they represent the top level cat's option panel itself (otherwise cat
  *    entries would just have empty panels).
- * 3) Other modules (currently) have their options located under a single tree
+ * 3) Plugins (currently) have their option sets located under a single tree
  *    node attached to one of the core cat/subcat nodes. The location for this
- *    is chosen based upon the first cat and subcat encountered in the module's
- *    option set. (If the subcat does not belong to the cat, then the node is
- *    attached directly to the cat; If the module's option set has options
- *    before the cat/subcat hint entries, this does not matter; If no cat or
- *    subcat hint is provided in the option set, then no node is created (i.e.
- *    that module's options will not be available in the prefs GUI).
+ *    is chosen based upon the first subcat encountered in the plugin's option
+ *    set (others are ignored). If the plugin's option set has options before
+ *    the cat/subcat hint entries, this does not matter; If no cat or subcat
+ *    hint is provided in the option set, then no node is created (i.e. that
+ *    plugins's options will not be shown).
  */
 
 class AdvPrefsPanel;



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/914a05ff4c714a76f932cc3623019bf090946519...68039794637968e406c8aa5fdff15647938647b8

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/914a05ff4c714a76f932cc3623019bf090946519...68039794637968e406c8aa5fdff15647938647b8
You're receiving this email because of your account on code.videolan.org.




More information about the vlc-commits mailing list