[vlc-commits] [Git][videolan/vlc][master] 4 commits: config: sort category table into a preferred order

Hugo Beauzée-Luyssen (@chouquette) gitlab at videolan.org
Fri Jan 14 09:21:24 UTC 2022



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


Commits:
5788c60e by Lyndon Brown at 2022-01-14T09:03:50+00:00
config: sort category table into a preferred order

this is prep work for the next commit. the intention here is to have the
order of items in the category table reflect the preferred order for the
primary category nodes to be displayed within the advanced preferences
trees.

the current alphabetical ordering used in qt i feel is far from ideal, as
explain in the next commit.

the order i have chosen is based upon my perception of what categories
might be of the most interest to the most users:

 1. Playlist
 2. Interface
 3. Audio
 4. Video
 5. Input / Codecs
 6. Sout
 7. Advanced

i also re-ordered the subcat table, since it only involved moving one
block. this was purely for maintaining consistency.

- - - - -
5a91a25e by Lyndon Brown at 2022-01-14T09:03:50+00:00
qt: use preferred order for adv prefs tree cat nodes

up until now the entire tree has been simply sorted alphabetically. this is
not at all ideal because this means that the "advanced" category comes
first, when logically it should come last. this is particularly unfortunate
because upon switching to advanced/complete/"all" view, the panel shown is
one titled "advanced settings" with a warning underneath saying "use with
care". this category also happens to be a particularly messy one in terms
of its organisation. this mess and warning gives a bad impression and
potential scares off users.

so, let's allow the subcat and plugin nodes to remain alphabetical, but
let's sort the root category nodes into a preferred order. we can do this
simply by resorting to match the order of entries within the category
lookup table in `vlc_config_cat.h`, which was reorganised into a suitable
order in the previous commit.

note that the solution accounts for the possibility that not all cats will
be in use in the tree.

- - - - -
1815c9ea by Lyndon Brown at 2022-01-14T09:03:50+00:00
macos: use preferred order for adv prefs tree cat nodes

this is the macos version of the previous qt commit.

- - - - -
da971f89 by Lyndon Brown at 2022-01-14T09:03:50+00:00
macos: alphabetically sort subcat and plugin prefs node

just as done with qt advanced prefs tree.

- - - - -


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
=====================================
@@ -207,17 +207,21 @@ struct config_subcategory_t
 
 static const struct config_category_t categories_array[] =
 {
+    { CAT_PLAYLIST,   SUBCAT_PLAYLIST_GENERAL,   PLAYLIST_HELP  },
     { CAT_INTERFACE,  SUBCAT_INTERFACE_GENERAL,  INTF_HELP      },
     { CAT_AUDIO,      SUBCAT_AUDIO_GENERAL,      AUDIO_HELP     },
     { CAT_VIDEO,      SUBCAT_VIDEO_GENERAL,      VIDEO_HELP     },
     { CAT_INPUT,      SUBCAT_INPUT_GENERAL,      INPUT_HELP     },
     { CAT_SOUT,       SUBCAT_SOUT_GENERAL,       SOUT_HELP      },
-    { CAT_PLAYLIST,   SUBCAT_PLAYLIST_GENERAL,   PLAYLIST_HELP  },
     { CAT_ADVANCED,   SUBCAT_ADVANCED_MISC,      AADVANCED_HELP },
 };
 
 static const struct config_subcategory_t subcategories_array[] =
 {
+    { 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_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  },
@@ -251,10 +255,6 @@ static const struct config_subcategory_t subcategories_array[] =
     { 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,   AADVANCED_TITLE,      AADVANCED_HELP     },
     { SUBCAT_ADVANCED_NETWORK,     CAT_ADVANCED,   ANETWORK_TITLE,       ANETWORK_HELP      },
 


=====================================
modules/gui/macosx/preferences/prefs.m
=====================================
@@ -560,6 +560,37 @@ enum VLCTreeBranchType {
         }
     }
     module_list_free(modules);
+
+    // Sort the top-level cat items into preferred order
+    NSUInteger index = 0;
+    NSUInteger childrenCount = [[self children] count];
+    for (unsigned i = 0; i < ARRAY_SIZE(categories_array); i++) {
+        // Try to find index of current cat
+        for (NSUInteger j = index; j < childrenCount; j++) {
+            VLCTreeBranchItem * item = [[self children] objectAtIndex:j];
+            if ([item category] == categories_array[i].id) {
+                if (j != index) {
+                    [[self children] exchangeObjectAtIndex:j withObjectAtIndex:index];
+                }
+                ++index;
+                break;
+            }
+        }
+    }
+    // Sort second and third level nodes (mix of subcat and plugin nodes) alphabetically
+    for (NSUInteger i = 0; i < [[self children] count]; i++) {
+        VLCTreeBranchItem * item_i = [[self children] objectAtIndex:i];
+        [[item_i children] sortUsingComparator: ^(id obj1, id obj2) {
+            return [[obj1 name] compare:[obj2 name]];
+        }];
+        for (NSUInteger j = 0; j < [[item_i children] count]; j++) {
+            VLCTreeBranchItem * item_j = [[item_i children] objectAtIndex:j];
+            [[item_j children] sortUsingComparator: ^(id obj1, id obj2) {
+                return [[obj1 name] compare:[obj2 name]];
+            }];
+        }
+    }
+
     return _children;
 }
 


=====================================
modules/gui/qt/dialogs/preferences/complete_preferences.cpp
=====================================
@@ -158,8 +158,24 @@ PrefsTree::PrefsTree( qt_intf_t *_p_intf, QWidget *_parent,
         createPluginNode( subcat_item, p_module );
     }
 
-    /* We got everything, just sort a bit */
+    // We got everything, just sort a bit.
+    // We allow the subcat and plugin nodes to be alphabetical, but we force
+    // the top-level cat nodes into a preferred order.
     sortItems( 0, Qt::AscendingOrder );
+    unsigned index = 0;
+    for (unsigned i = 0; i < ARRAY_SIZE(categories_array); i++)
+    {
+        cat_item = findCatItem( categories_array[i].id );
+        if ( cat_item == NULL )
+            continue;
+        unsigned cur_index = (unsigned)indexOfTopLevelItem( cat_item );
+        if (cur_index != index)
+        {
+            insertTopLevelItem( index, takeTopLevelItem( cur_index ) );
+            expandItem( cat_item );
+        }
+        ++index;
+    }
 
     resizeColumnToContents( 0 );
 }



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/839b9db6e4afcb1d56e5d4d46cd9322302da0358...da971f893c49a87c10aff2f1246ac4dea00796ee

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/839b9db6e4afcb1d56e5d4d46cd9322302da0358...da971f893c49a87c10aff2f1246ac4dea00796ee
You're receiving this email because of your account on code.videolan.org.




More information about the vlc-commits mailing list