[vlc-commits] [Git][videolan/vlc][master] config: use common function for identifying 'general' subcats
Jean-Baptiste Kempf (@jbk)
gitlab at videolan.org
Thu Jul 1 22:09:29 UTC 2021
Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC
Commits:
e6de716f by Lyndon Brown at 2021-07-01T21:23:24+00:00
config: use common function for identifying 'general' subcats
...removing the code duplication and helping avoid mistakes.
this reverts the fix in 08134b3f77fad1a0da3a20ddc869aadb8fe997cc
that stopped treating the 'advanced-misc' subcat as a general one
for the macos interface module, as a means of solving some issues
with displaying nodes for plugins associated with the 'advanced'
category. later commits properly fix the issues with the macos
tree construction code. in the meantime i want the predicate that
every cat has a general subcat restored such that it can be
properly relied upon once again by further preference tree code
improvements.
- - - - -
3 changed files:
- include/vlc_config_cat.h
- modules/gui/macosx/preferences/prefs.m
- modules/gui/qt/dialogs/preferences/complete_preferences.cpp
Changes:
=====================================
include/vlc_config_cat.h
=====================================
@@ -274,4 +274,37 @@ static inline const char *config_CategoryHelpGet( int i_value )
return NULL;
}
+/** Check if the given subcategory is a "general" one.
+ *
+ * In a cat/subcat preference tree, subcategories typically appear as child
+ * nodes under their respective parent category node. Core config items, which
+ * are always associated with a particular subcategory, are shown when that
+ * subcategory node is selected. Each category however has a "general"
+ * subcategory which is not shown as a child node, instead the options for
+ * this are shown when the category node itself is selected in the tree.
+ *
+ * One or more nodes are also created in the tree per plugin, with the
+ * location relating to the subcategory association of its config items. Plugin
+ * nodes associated with general subcategories naturally appear as child nodes
+ * of the category node (as a sibling to its subcategory nodes), rather than as
+ * a child node of a subcategory node.
+ */
+VLC_USED
+static inline bool vlc_config_subcat_IsGeneral( int subcat )
+{
+ switch (subcat)
+ {
+ case SUBCAT_INTERFACE_GENERAL:
+ case SUBCAT_AUDIO_GENERAL:
+ case SUBCAT_VIDEO_GENERAL:
+ case SUBCAT_INPUT_GENERAL:
+ case SUBCAT_SOUT_GENERAL:
+ case SUBCAT_ADVANCED_MISC:
+ case SUBCAT_PLAYLIST_GENERAL:
+ return true;
+ default:
+ return false;
+ }
+}
+
#endif /* VLC_HELP_H */
=====================================
modules/gui/macosx/preferences/prefs.m
=====================================
@@ -456,19 +456,6 @@
return nil;
}
-- (bool)isSubCategoryGeneral:(int)category
-{
- if (category == SUBCAT_VIDEO_GENERAL ||
- category == SUBCAT_INPUT_GENERAL ||
- category == SUBCAT_INTERFACE_GENERAL ||
- category == SUBCAT_SOUT_GENERAL||
- category == SUBCAT_PLAYLIST_GENERAL||
- category == SUBCAT_AUDIO_GENERAL) {
- return true;
- }
- return false;
-}
-
/* Creates and returns the array of children
* Loads children incrementally */
- (NSMutableArray *)children
@@ -529,7 +516,7 @@
subCategoryItem = nil;
continue;
}
- if (categoryItem && ![self isSubCategoryGeneral:lastsubcat]) {
+ if (categoryItem && !vlc_config_subcat_IsGeneral(lastsubcat)) {
subCategoryItem = [categoryItem itemRepresentingSubCategory:lastsubcat];
if (!subCategoryItem) {
subCategoryItem = [VLCTreeSubCategoryItem subCategoryTreeItemWithSubCategory:lastsubcat];
@@ -544,7 +531,7 @@
continue;
if (mod_is_main) {
- if (categoryItem && [self isSubCategoryGeneral:lastsubcat]) {
+ if (categoryItem && vlc_config_subcat_IsGeneral(lastsubcat)) {
[[categoryItem options] addObject:[[VLCTreeLeafItem alloc] initWithConfigItem:&p_configs[j]]];
} else if (subCategoryItem) {
[[subCategoryItem options] addObject:[[VLCTreeLeafItem alloc] initWithConfigItem:&p_configs[j]]];
=====================================
modules/gui/qt/dialogs/preferences/complete_preferences.cpp
=====================================
@@ -136,14 +136,7 @@ PrefsTree::PrefsTree( qt_intf_t *_p_intf, QWidget *_parent,
if( p_item->value.i == SUBCAT_HIDDEN ) break;
/* Special cases: move the main subcategories to the parent cat*/
- if( data &&
- ( p_item->value.i == SUBCAT_VIDEO_GENERAL ||
- p_item->value.i == SUBCAT_ADVANCED_MISC ||
- p_item->value.i == SUBCAT_INPUT_GENERAL ||
- p_item->value.i == SUBCAT_INTERFACE_GENERAL ||
- p_item->value.i == SUBCAT_SOUT_GENERAL||
- p_item->value.i == SUBCAT_PLAYLIST_GENERAL||
- p_item->value.i == SUBCAT_AUDIO_GENERAL ) )
+ if( data && vlc_config_subcat_IsGeneral(p_item->value.i) )
{
/* Data still contains the correct thing */
data->i_type = PrefsItemData::TYPE_CATSUBCAT;
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/e6de716f063e816bd0e32a556398db9d36b73372
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/e6de716f063e816bd0e32a556398db9d36b73372
You're receiving this email because of your account on code.videolan.org.
More information about the vlc-commits
mailing list