[vlc-commits] [Git][videolan/vlc][master] 3 commits: plugin: add HTML help

Steve Lhomme (@robUx4) gitlab at videolan.org
Mon Mar 27 14:10:42 UTC 2023



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
faf8b85a by Maxim Biro at 2023-03-27T12:11:10+00:00
plugin: add HTML help

HTML help that is shown instead of the plain help text where appropriate
and supported by the interface. The command-line help output and the Qt
GUI plugin tooltips show the plain help text, while the Qt GUI plugin
preferences page displays the HTML help, if available, falling back to
displaying the plain help otherwise.

Allows to present the help text in a more structured and expressive way.
Also useful for out-of-tree plugins, in case they want to link to
plugin's home page, bug tracker, donation page, etc.

For the supported HTML subset, see
https://doc.qt.io/qt-6/richtext-html-subset.html

Fixes #27798

- - - - -
caf14331 by Maxim Biro at 2023-03-27T12:11:10+00:00
qt: add HTML help

The Qt GUI part of the previous commit.

- - - - -
0f19973e by Maxim Biro at 2023-03-27T12:11:10+00:00
qt: remove some of unnecessary QString clears

QString::clear() makes QString::isNull() == true, but a
default-constructed QString is already QString::isNull() == true, so
clearing it is unnecessary.

- - - - -


13 changed files:

- NEWS
- include/vlc/libvlc.h
- include/vlc_modules.h
- include/vlc_plugin.h
- lib/core.c
- modules/gui/qt/dialogs/preferences/complete_preferences.cpp
- modules/gui/qt/dialogs/preferences/complete_preferences.hpp
- src/libvlccore.sym
- src/modules/cache.c
- src/modules/entry.c
- src/modules/modules.c
- src/modules/modules.h
- test/libvlc/core.c


Changes:

=====================================
NEWS
=====================================
@@ -29,6 +29,7 @@ Core:
      - Flat, new random implementation
      - Can't browse anymore (cf. mediatree)
  * Add support for dual subtitles selection (via the player)
+ * Support of HTML help (via the vlc_plugin.h:set_help_html macro)
 
 Audio output:
  * ALSA: HDMI passthrough support.


=====================================
include/vlc/libvlc.h
=====================================
@@ -498,6 +498,7 @@ typedef struct libvlc_module_description_t
     char *psz_shortname;
     char *psz_longname;
     char *psz_help;
+    char *psz_help_html;
     struct libvlc_module_description_t *p_next;
 } libvlc_module_description_t;
 


=====================================
include/vlc_modules.h
=====================================
@@ -219,6 +219,14 @@ VLC_API const char *module_get_name(const module_t *m, bool longname) VLC_USED;
  */
 VLC_API const char *module_get_help(const module_t *m) VLC_USED;
 
+/**
+ * Gets the help HTML for a module.
+ *
+ * \param m the module
+ * \return the help HTML
+ */
+VLC_API const char *module_get_help_html(const module_t *m) VLC_USED;
+
 /**
  * Gets the capability string of a module.
  *


=====================================
include/vlc_plugin.h
=====================================
@@ -48,6 +48,7 @@ enum vlc_module_properties
     VLC_MODULE_DESCRIPTION,
     VLC_MODULE_HELP,
     VLC_MODULE_TEXTDOMAIN,
+    VLC_MODULE_HELP_HTML,
     /* Insert new VLC_MODULE_* here */
 
     /* DO NOT EVER REMOVE, INSERT OR REPLACE ANY ITEM! It would break the ABI!
@@ -356,6 +357,10 @@ VLC_METADATA_EXPORTS
     if (vlc_module_set (VLC_MODULE_HELP, VLC_CHECKED_TYPE(const char *, help))) \
         goto error;
 
+#define set_help_html( help_html ) \
+    if (vlc_module_set (VLC_MODULE_HELP_HTML, VLC_CHECKED_TYPE(const char *, help_html))) \
+        goto error;
+
 #define set_capability( cap, score ) \
     if (vlc_module_set (VLC_MODULE_CAPABILITY, VLC_CHECKED_TYPE(const char *, cap)) \
      || vlc_module_set (VLC_MODULE_SCORE, VLC_CHECKED_TYPE(int, score))) \


=====================================
lib/core.c
=====================================
@@ -187,10 +187,12 @@ static libvlc_module_description_t *module_description_list_get(
         const char* shortname = module_GetShortName( p_module );
         const char* longname = module_GetLongName( p_module );
         const char* help = module_get_help( p_module );
+        const char* help_html = module_get_help_html( p_module );
         p_actual->psz_name = name ? strdup( name ) : NULL;
         p_actual->psz_shortname = shortname ? strdup( shortname ) : NULL;
         p_actual->psz_longname = longname ? strdup( longname ) : NULL;
         p_actual->psz_help = help ? strdup( help ) : NULL;
+        p_actual->psz_help_html = help_html ? strdup( help_html ) : NULL;
 
         p_actual->p_next = NULL;
         if ( p_previous )
@@ -214,6 +216,7 @@ void libvlc_module_description_list_release( libvlc_module_description_t *p_list
         free( p_actual->psz_shortname );
         free( p_actual->psz_longname );
         free( p_actual->psz_help );
+        free( p_actual->psz_help_html );
         p_before = p_actual;
         p_actual = p_before->p_next;
         free( p_before );


=====================================
modules/gui/qt/dialogs/preferences/complete_preferences.cpp
=====================================
@@ -257,8 +257,9 @@ void PrefsTree::createPluginNode( QTreeWidgetItem * parent, module_t *mod )
     const char *help = module_get_help( mod );
     if( help )
         item->help = qfut( help );
-    else
-        item->help.clear();
+    const char *help_html = module_get_help_html( mod );
+    if( help_html )
+        item->help_html = qfut( help_html );
 
     item->setText( 0, item->name );
     //item->setSizeHint( 0, QSize( -1, ITEM_HEIGHT ) );
@@ -446,14 +447,12 @@ bool PrefsTreeItem::contains( const QString &text, Qt::CaseSensitivity cs )
     /* check the node itself (its name/longname/helptext) */
 
     QString head;
-    if( is_core )
-        head.clear();
-    else
+    if( !is_core )
         head = QString( qfut( module_GetLongName( p_module ) ) );
 
     if ( name.contains( text, cs )
          || (!is_core && head.contains( text, cs ))
-         || help.contains( text, cs )
+         || (!help_html.isEmpty() ? help_html.contains( text, cs ) : help.contains( text, cs ))
        )
     {
         return true;
@@ -566,8 +565,19 @@ AdvPrefsPanel::AdvPrefsPanel( qt_intf_t *_p_intf, QWidget *_parent,
     title_line->setFrameShape(QFrame::HLine);
     title_line->setFrameShadow(QFrame::Sunken);
 
-    QLabel *helpLabel = new QLabel( node->help, this );
+    QLabel *helpLabel = new QLabel( this );
     helpLabel->setWordWrap( true );
+    if( node->help_html.isEmpty() )
+    {
+        helpLabel->setText( node->help );
+        helpLabel->setTextFormat( Qt::PlainText );
+    }
+    else
+    {
+        helpLabel->setText( node->help_html );
+        helpLabel->setTextFormat( Qt::RichText );
+        helpLabel->setOpenExternalLinks( true );
+    }
 
     global_layout->addWidget( titleLabel );
     global_layout->addWidget( title_line );


=====================================
modules/gui/qt/dialogs/preferences/complete_preferences.hpp
=====================================
@@ -77,6 +77,7 @@ public:
     AdvPrefsPanel *panel;
     QString name;
     QString help;
+    QString help_html;
     enum vlc_config_cat cat_id;
     enum vlc_config_subcat subcat_id;
     module_t *p_module;


=====================================
src/libvlccore.sym
=====================================
@@ -263,6 +263,7 @@ module_config_get
 module_find
 module_get_capability
 module_get_help
+module_get_help_html
 module_get_name
 module_get_object
 module_get_score


=====================================
src/modules/cache.c
=====================================
@@ -302,6 +302,7 @@ static int vlc_cache_load_module(vlc_plugin_t *plugin, block_t *file)
     LOAD_STRING(module->psz_shortname);
     LOAD_STRING(module->psz_longname);
     LOAD_STRING(module->psz_help);
+    LOAD_STRING(module->psz_help_html);
 
     LOAD_IMMEDIATE(module->i_shortcuts);
     if (module->i_shortcuts > MODULE_SHORTCUT_MAX)
@@ -582,6 +583,7 @@ static int CacheSaveModule(FILE *file, const module_t *module)
     SAVE_STRING(module->psz_shortname);
     SAVE_STRING(module->psz_longname);
     SAVE_STRING(module->psz_help);
+    SAVE_STRING(module->psz_help_html);
     SAVE_IMMEDIATE(module->i_shortcuts);
 
     for (size_t j = 0; j < module->i_shortcuts; j++)


=====================================
src/modules/entry.c
=====================================
@@ -66,6 +66,7 @@ module_t *vlc_module_create(vlc_plugin_t *plugin)
     module->psz_shortname = NULL;
     module->psz_longname = NULL;
     module->psz_help = NULL;
+    module->psz_help_html = NULL;
     module->pp_shortcuts = NULL;
     module->i_shortcuts = 0;
     module->psz_capability = NULL;
@@ -310,6 +311,10 @@ static int vlc_plugin_desc_cb(void *ctx, void *tgt, int propid, ...)
             module->psz_help = va_arg (ap, const char *);
             break;
 
+        case VLC_MODULE_HELP_HTML:
+            module->psz_help_html = va_arg (ap, const char *);
+            break;
+
         case VLC_MODULE_TEXTDOMAIN:
             plugin->textdomain = va_arg(ap, const char *);
             break;


=====================================
src/modules/modules.c
=====================================
@@ -69,6 +69,11 @@ const char *module_get_help( const module_t *m )
     return m->psz_help;
 }
 
+const char *module_get_help_html( const module_t *m )
+{
+    return m->psz_help_html;
+}
+
 const char *module_get_capability (const module_t *m)
 {
     return (m->psz_capability != NULL) ? m->psz_capability : "none";


=====================================
src/modules/modules.h
=====================================
@@ -86,7 +86,9 @@ struct module_t
      */
     const char *psz_shortname;                              /**< Module name */
     const char *psz_longname;                   /**< Module descriptive name */
-    const char *psz_help;        /**< Long help string for "special" modules */
+    const char *psz_help;        /**< Long help plain string for "special" modules */
+    const char *psz_help_html;   /**< Long help HTML string, shown instead of the plain help where it makes sense to render HTML.
+                                      Supports only a limited HTML4 subset, see https://doc.qt.io/qt-6/richtext-html-subset.html */
 
     const char *psz_capability;                              /**< Capability */
     int      i_score;                          /**< Score for the capability */


=====================================
test/libvlc/core.c
=====================================
@@ -46,6 +46,7 @@ static void test_moduledescriptionlist (libvlc_module_description_t *list)
         assert (strlen (module->psz_shortname) );
         assert (module->psz_longname == NULL || strlen (module->psz_longname));
         assert (module->psz_help == NULL || strlen (module->psz_help));
+        assert (module->psz_help_html == NULL || strlen (module->psz_help_html));
         module = module->p_next;
     }    
 



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/37ffd8bb088aced6f884a6a0481df2e073e24987...0f19973e396eecbae2c0483213413d8e7d4aadf6

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/37ffd8bb088aced6f884a6a0481df2e073e24987...0f19973e396eecbae2c0483213413d8e7d4aadf6
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list