Skip to content
Commit 67344e9f authored by Michael Weghorn's avatar Michael Weghorn
Browse files

FileChooser: Handle 'options' - 'choices'

This impelements handling for the 'choices' in the 'options'
vardict of the FileChooser portal, which is described in the
spec [1] as:

> choices a(ssa(ss)s)
>
>     List of serialized combo boxes to add to the file chooser.
>
>     For each element, the first string is an ID that will be returned
>     with the response, te second string is a user-visible label. The
>     a(ss) is the list of choices, each being a is an ID and a
>     user-visible label. The final string is the initial selection, or
>     "", to let the portal decide which choice will be initially
>     selected. None of the strings, except for the initial selection,
>     should be empty.
>
>     As a special case, passing an empty array for the list of choices
>     indicates a boolean choice that is typically displayed as a check
>     button, using "true" and "false" as the choices.
>
>     Example: [('encoding', 'Encoding', [('utf8', 'Unicode (UTF-8)'),
>             ('latin15', 'Western')], 'latin15'), ('reencode',
>                 'Reencode', [], 'false')]

The corresponding types are added for marshalling/unmarshalling to/from
the QDBusArgument.

Note that the implementation uses the term "Option" for a top-level
element in the list passed by the 'choices' key while "Choice" refers
to an element in the "list of choices" for a single element/option.

For every option, a checkbox (for boolean options) or combobox is
created and all of them are inserted into the layout of a widget that
is then set as the custom widget of the a custom widget that is then
added to the file dialog using 'KFileWidget::KFilesetCustomWidget'.

[1] https://flatpak.github.io/xdg-desktop-portal/portal-docs.html#gdbus-org.freedesktop.portal.FileChooser
parent 5b9b8f19
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment