Kiosk self-documentation improvement
Open, Needs TriagePublic

Description

One of the nice thing about KConfig is that all the keys used by the application are listed in an XML file with labels and default value.

Example:

<entry name="menuItems" type="StringList">
  <label>The menu tabs to show.</label>
  <default>bookmark:t,application:t,computer:t,used:t,oftenUsed:f,leave:t</default>
</entry>

This allows to generate documentation for those configuration files. In Kiosk, we only have bool KAuthorized::authorize(const QString &action), so we can't really enforce the documentation of the various existing keys, since there is no way to list all the existing keys, and we don't have any descriptions.

Forcing the keys to be listed in an XML files will break the existing API, but maybe we could investigate doing it for KF6.

I'm not and KConfig or Kiosk expert, so I could be wrong but I think this could allow generating documentation but also create an admin GUI for Kiosk and other fancy stuff ;)

ognarb created this task.Oct 30 2019, 8:52 PM

There's basically two types of actions that could be authorized

  • Individual KXmlGui actions (authorizeAction, basically just "action/" + name), like "open", "quit", "paste", "undo", "configure", "show_toolbar", whatever. Perhaps we can just list all the KStandardActions or something. Really hard to get a sensible list out of them, unless we just list *all* of the actions in *all* of kxmlgui rc files... Could be useful for some other purpose, maybe still.
  • A bunch of keys (authorize), like "run_command" (which I think even is/was an action...), "switch_user", "ghns", "start_session", "shell_access", "lineedit_autocomplete", etc. I would be in favor of having an enum for those.

The advantage of using an enum is:

  • better autogeneratable documentation
  • no random strings in your code
  • harder to add arbitrary new values without telling anyone
ognarb added a comment.Dec 2 2021, 3:28 PM

It seems this was done in https://invent.kde.org/frameworks/kconfig/-/merge_requests/82. We no longer need to use magic strings for the authorize command :)

ognarb moved this task from Needs Input to Done on the KF6 board.Dec 2 2021, 3:29 PM
alex moved this task from Done to In Progress on the KF6 board.Dec 2 2021, 4:55 PM
alex added a subscriber: alex.

No, I would not consider it done. It was just the first step to get rid of most string based check we have all over the place.

This allows to generate documentation for those configuration files

This is still a TODO I will work on.

Forcing the keys to be listed in an XML files will break the existing API, but maybe we could investigate doing it for KF6.

And this will be done once the TODO above is figured out.