KShortcutsEditor Class

Widget for configuration of KAccel and KGlobalAccel. More...

Header: #include <KShortcutsEditor>
CMake: find_package(KF6 REQUIRED COMPONENTS XmlGui)
target_link_libraries(mytarget PRIVATE KF6::XmlGui)
Inherits: QWidget

Public Types

enum ActionType { WidgetAction, WindowAction, ApplicationAction, GlobalAction, AllActions }
flags ActionTypes
enum LetterShortcuts { LetterShortcutsDisallowed, LetterShortcutsAllowed }

Properties

Public Functions

KShortcutsEditor(KActionCollection *collection, QWidget *parent, KShortcutsEditor::ActionTypes actionTypes = AllActions, KShortcutsEditor::LetterShortcuts allowLetterShortcuts = LetterShortcutsAllowed)
KShortcutsEditor(QWidget *parent, KShortcutsEditor::ActionTypes actionTypes = AllActions, KShortcutsEditor::LetterShortcuts allowLetterShortcuts = LetterShortcutsAllowed)
virtual ~KShortcutsEditor() override
(since 5.0) KShortcutsEditor::ActionTypes actionTypes() const
void addCollection(KActionCollection *, const QString &title = QString())
void clearCollections()
bool isModified() const
void save()
(since 5.0) void setActionTypes(KShortcutsEditor::ActionTypes actionTypes)
(since 5.75) void undo()

Public Slots

void allDefault()

Signals

void keyChange()

Detailed Description

Configure dictionaries of key/action associations for QActions, including global shortcuts.

The class takes care of all aspects of configuration, including handling key conflicts internally. Connect to the allDefault() slot if you want to set all configurable shortcuts to their default values.

See also KShortcutsDialog.

Member Type Documentation

enum KShortcutsEditor::ActionType
flags KShortcutsEditor::ActionTypes

ConstantValueDescription
KShortcutsEditor::WidgetActionQt::WidgetShortcutActions which are triggered by any keypress in a widget that has the action added to it.
KShortcutsEditor::WindowActionQt::WindowShortcutActions which are triggered by any keypress in a window that has the action added to it or its child widget(s).
KShortcutsEditor::ApplicationActionQt::ApplicationShortcutActions that are triggered by any keypress in the application.
KShortcutsEditor::GlobalAction4Actions which are triggered by any keypress in the windowing system.
KShortcutsEditor::AllActions0xffffffffA combination of all available actions.

Note: Since 5.95, GlobalAction is ignored if there are no actual Global shortcuts in any of the action collections that are added.

The ActionTypes type is a typedef for QFlags<ActionType>. It stores an OR combination of ActionType values.

enum KShortcutsEditor::LetterShortcuts

ConstantValueDescription
KShortcutsEditor::LetterShortcutsDisallowed0Shortcuts without a modifier are not allowed, so 'A' would not be valid, whereas 'Ctrl+A' would be. This only applies to printable characters, however. 'F1', 'Insert' etc. could still be used.
KShortcutsEditor::LetterShortcutsAllowed1Letter shortcuts are allowed.

Property Documentation

actionTypes : ActionTypes

Access functions:

KShortcutsEditor::ActionTypes actionTypes() const
void setActionTypes(KShortcutsEditor::ActionTypes actionTypes)

Member Function Documentation

KShortcutsEditor::KShortcutsEditor(KActionCollection *collection, QWidget *parent, KShortcutsEditor::ActionTypes actionTypes = AllActions, KShortcutsEditor::LetterShortcuts allowLetterShortcuts = LetterShortcutsAllowed)

Constructor.

collection The KActionCollection to configure.

parent Parent widget.

actionTypes Types of actions to display in this widget.

allowLetterShortcuts Set to LetterShortcutsDisallowed if unmodified alphanumeric keys ('A', '1', etc.) are not permissible shortcuts.

[explicit] KShortcutsEditor::KShortcutsEditor(QWidget *parent, KShortcutsEditor::ActionTypes actionTypes = AllActions, KShortcutsEditor::LetterShortcuts allowLetterShortcuts = LetterShortcutsAllowed)

Creates a key chooser without a starting action collection.

This function overloads KShortcutsEditor::KShortcutsEditor().

parent Parent widget.

actionTypes Types of actions to display in this widget.

allowLetterShortcuts Set to LetterShortcutsDisallowed if unmodified alphanumeric keys ('A', '1', etc.) are not permissible shortcuts.

[override virtual noexcept] KShortcutsEditor::~KShortcutsEditor()

Destructor

[since 5.0] KShortcutsEditor::ActionTypes KShortcutsEditor::actionTypes() const

Returns The types of actions currently displayed in this widget.

Note: Getter function for property actionTypes.

This function was introduced in 5.0.

See also setActionTypes().

void KShortcutsEditor::addCollection(KActionCollection *, const QString &title = QString())

Insert an action collection, i.e. add all its actions to the ones already associated with the KShortcutsEditor object.

title Subtree title of this collection of shortcut.

[slot] void KShortcutsEditor::allDefault()

Sets all shortcuts to their default values (bindings).

void KShortcutsEditor::clearCollections()

Removes all action collections from the editor

bool KShortcutsEditor::isModified() const

Returns whether there are unsaved changes.

[signal] void KShortcutsEditor::keyChange()

Emitted when an action's shortcut has been changed.

void KShortcutsEditor::save()

Save the changes.

This saves the actions to disk. Any KActionCollection objects with the xmlFile() value set will be written to an XML file. All others will be written to the application's rc file.

[since 5.0] void KShortcutsEditor::setActionTypes(KShortcutsEditor::ActionTypes actionTypes)

Sets the types of actions to display in this widget.

actionTypes New types of actions.

Note: Setter function for property actionTypes.

This function was introduced in 5.0.

See also actionTypes().

[since 5.75] void KShortcutsEditor::undo()

Undo all changes made since the last save().

This function was introduced in 5.75.