vcl/inc/qt5/QtInstanceNotebook.hxx | 5 +++++ vcl/qt5/QtInstanceNotebook.cxx | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+)
New commits: commit d4edde13e808aee6ed1a4b8ae049a956733ee4b9 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Sun Nov 10 19:35:00 2024 +0100 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Mon Nov 11 01:49:34 2024 +0100 tdf#130857 qt weld: Call handlers when tab page changes Call the corresponding handlers to notify about the previous and current tab page when switching the tab page in QtInstanceNotebook, by remembering the identifier of the current page and using that in a slot connected to the QTabWidget::currentChanged signal. Change-Id: I387c75b3af138cf9b89f169f0a3c223c262c2a92 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176356 Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> Tested-by: Jenkins diff --git a/vcl/inc/qt5/QtInstanceNotebook.hxx b/vcl/inc/qt5/QtInstanceNotebook.hxx index f55c9c60d9d6..4969e0f40aaf 100644 --- a/vcl/inc/qt5/QtInstanceNotebook.hxx +++ b/vcl/inc/qt5/QtInstanceNotebook.hxx @@ -22,6 +22,8 @@ class QtInstanceNotebook : public QObject, public QtInstanceWidget, public virtu QTabWidget* m_pTabWidget; + OUString m_sCurrentTabId; + mutable std::map<QWidget*, std::unique_ptr<QtInstanceContainer>> m_aPageContainerInstances; public: @@ -43,6 +45,9 @@ public: static void setTabIdAndLabel(QTabWidget& rTabWidget, int nPage, const OUString& rIdent, const OUString& rLabel); + +private Q_SLOTS: + void currentTabChanged(); }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/qt5/QtInstanceNotebook.cxx b/vcl/qt5/QtInstanceNotebook.cxx index bb26817c3196..48344f2cb08a 100644 --- a/vcl/qt5/QtInstanceNotebook.cxx +++ b/vcl/qt5/QtInstanceNotebook.cxx @@ -24,6 +24,12 @@ QtInstanceNotebook::QtInstanceNotebook(QTabWidget* pTabWidget) , m_pTabWidget(pTabWidget) { assert(m_pTabWidget); + + if (m_pTabWidget->count()) + m_sCurrentTabId = get_current_page_ident(); + + connect(m_pTabWidget, &QTabWidget::currentChanged, this, + &QtInstanceNotebook::currentTabChanged); } int QtInstanceNotebook::get_current_page() const @@ -167,4 +173,17 @@ void QtInstanceNotebook::setTabIdAndLabel(QTabWidget& rTabWidget, int nPage, con }); } +void QtInstanceNotebook::currentTabChanged() +{ + SolarMutexGuard g; + + if (!m_sCurrentTabId.isEmpty()) + m_aLeavePageHdl.Call(m_sCurrentTabId); + + m_sCurrentTabId = get_current_page_ident(); + + if (!m_sCurrentTabId.isEmpty()) + m_aLeavePageHdl.Call(m_sCurrentTabId); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */