MCPcopy Create free account
hub / github.com/KDE/kdevelop / configureShortcuts

Method configureShortcuts

kdevplatform/shell/mainwindow.cpp:278–325  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

276}
277
278void MainWindow::configureShortcuts()
279{
280 ///Workaround for a problem with the actions: Always start the shortcut-configuration in the first mainwindow, then propagate the updated
281 ///settings into the other windows
282
283
284// We need to bring up the shortcut dialog ourself instead of
285// Core::self()->uiControllerInternal()->mainWindows()[0]->guiFactory()->configureShortcuts();
286// so we can connect to the saved() signal to propagate changes in the editor shortcuts
287
288 KShortcutsDialog dlg(KShortcutsEditor::AllActions, KShortcutsEditor::LetterShortcutsAllowed, this);
289
290 const auto firstMainWindowClientsBefore = Core::self()->uiControllerInternal()->mainWindows()[0]->guiFactory()->clients();
291 for (KXMLGUIClient* client : firstMainWindowClientsBefore) {
292 if(client && !client->xmlFile().isEmpty())
293 dlg.addCollection( client->actionCollection() );
294 }
295
296 connect(&dlg, &KShortcutsDialog::saved, this, &MainWindow::shortcutsChanged);
297 dlg.configure(true);
298
299 QMap<QString, QKeySequence> shortcuts;
300 // querying again just in case something changed behind our back
301 const auto firstMainWindowClientsAfter = Core::self()->uiControllerInternal()->mainWindows()[0]->guiFactory()->clients();
302 for (KXMLGUIClient* client : firstMainWindowClientsAfter) {
303 const auto actions = client->actionCollection()->actions();
304 for (QAction* action : actions) {
305 if(!action->objectName().isEmpty()) {
306 shortcuts[action->objectName()] = action->shortcut();
307 }
308 }
309 }
310
311 for(int a = 1; a < Core::self()->uiControllerInternal()->mainWindows().size(); ++a) {
312 const auto clients = Core::self()->uiControllerInternal()->mainWindows()[a]->guiFactory()->clients();
313 for (KXMLGUIClient* client : clients) {
314 const auto actions = client->actionCollection()->actions();
315 for (QAction* action : actions) {
316 qCDebug(SHELL) << "transferring setting shortcut for" << action->objectName();
317 const auto shortcutIt = shortcuts.constFind(action->objectName());
318 if (shortcutIt != shortcuts.constEnd()) {
319 action->setShortcut(*shortcutIt);
320 }
321 }
322 }
323 }
324
325}
326
327void MainWindow::shortcutsChanged()
328{

Callers

nothing calls this directly

Calls 11

guiFactoryMethod · 0.80
mainWindowsMethod · 0.80
uiControllerInternalMethod · 0.80
constEndMethod · 0.80
isEmptyMethod · 0.45
xmlFileMethod · 0.45
actionCollectionMethod · 0.45
configureMethod · 0.45
actionsMethod · 0.45
sizeMethod · 0.45
constFindMethod · 0.45

Tested by

no test coverage detected