Pages
API Documentation
On this page

KAuthorized Class

Used for checking whether actions are allowed for a user. More...

  • Header: #include <KAuthorized>
  • CMake: find_package(KF6 REQUIRED COMPONENTS Config)
    target_link_libraries(mytarget PRIVATE KF6::ConfigCore)
  • Inherits: QObject

List of all members, including inherited members

Public Types

Static Public Members

Detailed Description

The functions in this namespace provide the core of the Kiosk action restriction system; the KIO and KXMLGui frameworks build on this.

KDE's Kiosk settings allow to control whether a user is allowed to perform actions such as opening files or running shell commands.

The relevant settings are read from the application's KSharedConfig instance, so actions can be disabled on a per-application or global basis (by using the kdeglobals file).

Member Type Documentation

enum KAuthorized::GenericAction

Constant Value Description
KAuthorized::OPEN_WITH 1 If the open-with menu should be shown for files etc.
KAuthorized::EDITFILETYPE 2 If mime-type accociations are allowed to be configured
KAuthorized::OPTIONS_SHOW_TOOLBAR 3 If the toolbar should be displayed in apps
KAuthorized::SWITCH_APPLICATION_LANGUAGE 4 If an action to switch the app language should be shown
KAuthorized::BOOKMARKS 5 If saving bookmarks is allowed

enum KAuthorized::GenericRestriction

The enum values lower cased represent the action that is authorized For example the SHELL_ACCESS value is converted to the "shell_access" string.

Constant Value Description
KAuthorized::SHELL_ACCESS 1 If the user is authorized to open a shell or execute shell commands
KAuthorized::GHNS 2 If the collaborative data sharing framework KNewStuff is authorized GUI behavior
KAuthorized::LINEEDIT_REVEAL_PASSWORD 3 If typed characters in password fields can be made visible
KAuthorized::LINEEDIT_TEXT_COMPLETION 4 If line edits should be allowed to display completions
KAuthorized::MOVABLE_TOOLBARS 5 If toolbars of apps should be movable
KAuthorized::RUN_DESKTOP_FILES 6 If .desktop files should be run as executables when clicked

Member Function Documentation

[static invokable] bool KAuthorized::authorize(const QString &action)

Returns whether the user is permitted to perform a certain action.

All settings are read from the [KDE Action Restrictions] group. For example, if kdeglobals contains

[KDE Action Restrictions][$i]
shell_access=false

then

KAuthorized::authorize("shell_access");

will return false.

This method is intended for actions that do not necessarily have a one-to-one correspondence with a menu or toolbar item (ie: a QAction in a KXMLGui application). "shell_access" is an example of such a "generic" action.

The convention for actions like "File->New" is to prepend the action name with "action/", for example "action/file_new". This is what authorizeAction() does.

Returns true if the action is authorized, false otherwise.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

See also authorizeAction()

[static invokable] bool KAuthorized::authorize(KAuthorized::GenericRestriction action)

Returns whether the user is permitted to perform a common action.

The enum values lower cased represent the action that is passed in to KAuthorized::authorize(const QString &action).

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

This function overloads KAuthorized::authorize(const QString &action).

[static invokable] bool KAuthorized::authorizeAction(const QString &action)

Returns whether the user is permitted to perform a certain action.

This behaves like authorize(), except that "action/" is prepended to action. So if kdeglobals contains

[KDE Action Restrictions][$i]
action/file_new=false

then

KAuthorized::authorizeAction("file_new");

will return false.

KXMLGui-based applications should not normally need to call this function, as KActionCollection will do it automatically.

Returns true if the QAction is authorized, false otherwise.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

See also authorize()

[static invokable] bool KAuthorized::authorizeAction(KAuthorized::GenericAction action)

Overload to authorize a common action.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

This function overloads KAuthorized::authorizeAction(const QString &action).

[static invokable] bool KAuthorized::authorizeControlModule(const QString &pluginId)

Returns whether the user is permitted to use a certain control module with the given pluginId.

All settings are read from the "[KDE Control Module Restrictions]" group. For example, if kdeglobals contains

[KDE Control Module Restrictions][$i]
kcm_desktop-settings=false

then

KAuthorized::authorizeControlModule("kcm_desktop-settings");

will return false.

Returns true if access to the module is authorized, false otherwise.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

We use cookies to personalize content and to analyze our traffic. Please decide if you are willing to accept cookies from our website.