Skip to content

kconfigloader: Add support for setting default enum values as strings

Joshua Goins requested to merge work/redstrate/fix-plasmoid-enums into master

Regular KConfig can specify enums like so:

<entry name="DefaultEnumItemString" type="Enum">
        <default>Coconuts</default>
        <choice name="Apples" />
        <choice name="Oranges" />
        <choice name="Coconuts" />
        <choice name="Grapes" />
</entry>

The <default> value can also be an integer. However, at runtime (like with plasmoids) the default value can only be specified as an integer:

<entry name="DefaultEnumItemString" type="Enum">
        <default>2</default>
        <choice name="Apples" />
        <choice name="Oranges" />
        <choice name="Coconuts" />
        <choice name="Grapes" />
</entry>

This MR now makes kconfigloader match regular KConfig behavior, where you can either specify default values as integer values or with strings. A new test is also added to make sure this doesn't regress.

This doesn't currently support enums with custom values (specified on each choice via value) because I didn't find where that was exposed in KCoreConfigSkeleton::ItemEnum::Choice. It might require a lot more changes (I'm not too sure how regular kconfig handles this either), so I'll do that in another MR.

@fusionfuture

Merge request reports