From 2d69bd6e3a8a59642be58f1d285e55c3df8b6a67 Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Thu, 31 Dec 2020 00:32:30 +0100 Subject: [PATCH] Reload xml to update shortcuts when they change in other parts Or if we are using and "old" kxmlgui, reloadXML every time --- shell/shell.cpp | 16 ++++++++++++++++ shell/shell.h | 1 + 2 files changed, 17 insertions(+) diff --git a/shell/shell.cpp b/shell/shell.cpp index 6ad02793f..be6ef738c 100644 --- a/shell/shell.cpp +++ b/shell/shell.cpp @@ -53,6 +53,7 @@ #endif #include +#include // local includes #include "../interfaces/viewerinterface.h" @@ -146,6 +147,17 @@ Shell::Shell(const QString &serializedOptions) m_isValid = false; KMessageBox::error(this, i18n("Unable to find the Okular component.")); } + +#if KXMLGUI_VERSION > QT_VERSION_CHECK(5, 78, 0) + connect(guiFactory(), &KXMLGUIFactory::shortcutsSaved, this, &Shell::reloadAllXML); +#endif +} + +void Shell::reloadAllXML() +{ + for (const TabState &tab : qAsConst(m_tabs)) { + tab.part->reloadXML(); + } } bool Shell::eventFilter(QObject *obj, QEvent *event) @@ -623,7 +635,11 @@ bool Shell::queryClose() void Shell::setActiveTab(int tab) { m_tabWidget->setCurrentIndex(tab); +#if KXMLGUI_VERSION <= QT_VERSION_CHECK(5, 78, 0) + m_tabs[tab].part->reloadXML(); +#endif createGUI(m_tabs[tab].part); + m_printAction->setEnabled(m_tabs[tab].printEnabled); m_closeAction->setEnabled(m_tabs[tab].closeEnabled); } diff --git a/shell/shell.h b/shell/shell.h index 12986dc06..93f6907a0 100644 --- a/shell/shell.h +++ b/shell/shell.h @@ -154,6 +154,7 @@ private: int findTabIndex(const QUrl &url) const; private: + void reloadAllXML(); bool eventFilter(QObject *obj, QEvent *event) override; KPluginFactory *m_partFactory;