From kde-commits Wed Jul 07 17:36:06 2010 From: Mantia Andras Date: Wed, 07 Jul 2010 17:36:06 +0000 To: kde-commits Subject: [kdevplatform] 8a2ab12: Propagate shortcuts setting to all the opened Message-Id: <201007071736.o67Ha6jd009775 () kore ! kollide ! net> X-MARC-Message: https://marc.info/?l=kde-commits&m=127852512614868 commit 8a2ab12875f3030a8f0551b13635acd082dc3228 Author: Mantia Andras Date: Wed Jul 7 11:29:16 2010 +0300 Propagate shortcuts setting to all the opened editor views. diff --git a/shell/mainwindow.cpp b/shell/mainwindow.cpp index f7c50b3..6d0369e 100644 --- a/shell/mainwindow.cpp +++ b/shell/mainwindow.cpp @@ -37,7 +37,9 @@ Boston, MA 02110-1301, USA. #include #include #include +#include #include +#include #include #include @@ -219,7 +221,21 @@ void MainWindow::configureShortcuts() { ///Workaround for a problem with the actions: Always start the shortcut-configuration in the first mainwindow, then propagate the updated ///settings into the other windows - Core::self()->uiControllerInternal()->mainWindows()[0]->guiFactory()->configureShortcuts(); + + +// We need to bring up the shortcut dialog ourself instead of +// Core::self()->uiControllerInternal()->mainWindows()[0]->guiFactory()->configureShortcuts(); +// so we can connect to the saved() signal to propagate changes in the editor shortcuts + + KShortcutsDialog dlg(KShortcutsEditor::AllActions, KShortcutsEditor::LetterShortcutsAllowed, this); + foreach (KXMLGUIClient *client, Core::self()->uiControllerInternal()->mainWindows()[0]->guiFactory()->clients()) + { + if(client && !client->xmlFile().isEmpty()) + dlg.addCollection( client->actionCollection() ); + } + + connect(&dlg, SIGNAL(saved()), SLOT(shortcutsChanged())); + dlg.configure(true); QMap shortcuts; foreach(KXMLGUIClient* client, Core::self()->uiControllerInternal()->mainWindows()[0]->guiFactory()->clients()) { @@ -240,8 +256,29 @@ void MainWindow::configureShortcuts() } } } + } +void MainWindow::shortcutsChanged() +{ + //propagate shortcut changes to all the opened text documents by reloading the UI XML file + KTextEditor::Document *activeDocument = Core::self()->documentController()->activeDocument()->textDocument(); + if (activeDocument) { + + KTextEditor::View *activeClient = activeDocument->activeView(); + + foreach(IDocument * doc, Core::self()->documentController()->openDocuments()) { + KTextEditor::Document *textDocument = doc->textDocument(); + foreach(KTextEditor::View *client, textDocument->views()) { + if (client != activeClient) { + client->reloadXML(); + } + } + } + } +} + + void MainWindow::initialize() { KStandardAction::keyBindings(this, SLOT(configureShortcuts()), actionCollection()); diff --git a/shell/mainwindow.h b/shell/mainwindow.h index e8c18df..584f289 100644 --- a/shell/mainwindow.h +++ b/shell/mainwindow.h @@ -97,6 +97,7 @@ protected Q_SLOTS: private Q_SLOTS: void updateCaption(); + void shortcutsChanged(); private: class MainWindowPrivate *d;