In the source code of KDE applications, how do shortcuts work?

I am browsing through the Kate source code, trying to find how a Vi mode command is executed. However, I am having trouble doing so. I was trying to find the shortcut that performs a command, because in my head, if I could find the shortcut, I could find what code it runs and I would be able to make changes there. But I cannot find where inputs are recognized and used to execute code anywhere in the source code. The best of luck I could find are shortcuts in docbook files.

Does anyone know how shortcuts are set up and where can I find them in the source code KDE applications? Thank you.

I didn’t look through Kate’s code, but usually keyboard shortcuts are managed in C++ code using KActionCollection::setDefaultShortcut().

What about setting options?

I’ve been trying to understand how they are created, but I don’t fully understand how. I did find where pages for the windows get added, but I don’t know how those pages are created. The names for some of the options don’t exist in the .cpp and .h files as strings, but do appear in .docbook files. I’m under the impression that setting options are somehow parsed somewhere (not including .ui files), but I don’t know if this is true.

Not sure what you’re after exactly. The code that provides the shortcut configuration pages common across apps lives in the repository kxmlgui, the files with kshortcut in the name.

But if you want to hunt down what the action itself does, and the ability to assign a shortcut to it is only incidental, that would be in Kate code itself. You’d want to follow the code path for the “action” that is set in that reference Herzenschein mentioned.

And possibly the particular thing you’re interested in is not in the kate repository but in ktexteditor. src/vimode/inputmodemanager.cpp · master · Frameworks / KTextEditor · GitLab perhaps?

1 Like

Thanks, I think you might have led me to what I am looking for.