• Michael Weghorn's avatar
    FileChooser: Handle 'options' - 'choices' · 67344e9f
    Michael Weghorn authored
    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
filechooser.cpp 18.9 KB