KAuthorized Class

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

Public Types

(since 5.88) enum GenericAction { OPEN_WITH, EDITFILETYPE, OPTIONS_SHOW_TOOLBAR, SWITCH_APPLICATION_LANGUAGE, BOOKMARKS }
(since 5.88) enum GenericRestriction { SHELL_ACCESS, GHNS, LINEEDIT_REVEAL_PASSWORD, LINEEDIT_TEXT_COMPLETION, MOVABLE_TOOLBARS, RUN_DESKTOP_FILES }

Static Public Members

bool authorize(const QString &action)
(since 5.88) bool authorize(KAuthorized::GenericRestriction action)
(since 5.24) bool authorizeAction(const QString &action)
(since 5.88) bool authorizeAction(KAuthorized::GenericAction action)
bool authorizeControlModule(const QString &pluginId)

Detailed Description

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

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

[since 5.88] enum KAuthorized::GenericAction

ConstantValueDescription
KAuthorized::OPEN_WITH1If the open-with menu should be shown for files etc.
KAuthorized::EDITFILETYPE2If mime-type accociations are allowed to be configured
KAuthorized::OPTIONS_SHOW_TOOLBAR3If the toolbar should be displayed in apps
KAuthorized::SWITCH_APPLICATION_LANGUAGE4If an action to switch the app language should be shown
KAuthorized::BOOKMARKS5If saving bookmarks is allowed

This enum was introduced in 5.88.

[since 5.88] 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.

ConstantValueDescription
KAuthorized::SHELL_ACCESS1If the user is authorized to open a shell or execute shell commands
KAuthorized::GHNS2If the collaborative data sharing framework KNewStuff is authorized GUI behavior
KAuthorized::LINEEDIT_REVEAL_PASSWORD3If typed characters in password fields can be made visible
KAuthorized::LINEEDIT_TEXT_COMPLETION4If line edits should be allowed to display completions
KAuthorized::MOVABLE_TOOLBARS5If toolbars of apps should be movable
KAuthorized::RUN_DESKTOP_FILES6If .desktop files should be run as executables when clicked

This enum was introduced in 5.88.

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.

action The name of the action.

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, since 5.88] 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 authorize(QString)

This is an overloaded function.

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

This function was introduced in 5.88.

[static invokable, since 5.24] 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.

action The name of a QAction action.

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.

This function was introduced in 5.24.

See also authorize().

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

Overload to authorize common actions.

This is an overloaded function.

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

This function was introduced in 5.88.

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

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

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.

pluginId The desktop menu ID for the control module.

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.