Reload xml to update shortcuts when they change in other parts

Or if we are using and "old" kxmlgui, reloadXML every time
remotes/origin/release/20.12 v20.12.2
Albert Astals Cid 5 years ago
parent 2aff8958b1
commit 2d69bd6e3a
  1. 16
      shell/shell.cpp
  2. 1
      shell/shell.h

@ -53,6 +53,7 @@
#endif
#include <kio_version.h>
#include <kxmlgui_version.h>
// 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);
}

@ -154,6 +154,7 @@ private:
int findTabIndex(const QUrl &url) const;
private:
void reloadAllXML();
bool eventFilter(QObject *obj, QEvent *event) override;
KPluginFactory *m_partFactory;

Loading…
Cancel
Save