diff options
author | Michael Weghorn <m.weghorn@posteo.de> | 2024-11-10 19:35:00 +0100 |
---|---|---|
committer | Michael Weghorn <m.weghorn@posteo.de> | 2024-11-11 01:49:34 +0100 |
commit | d4edde13e808aee6ed1a4b8ae049a956733ee4b9 (patch) | |
tree | e133fbd1f8f1dc4543fa0e5b363b52d9cdc74efd | |
parent | 5000c5bdfe4778e24759ee0aeb57ecb9fbb3c73a (diff) |
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.weghorn@posteo.de>
Tested-by: Jenkins
-rw-r--r-- | vcl/inc/qt5/QtInstanceNotebook.hxx | 5 | ||||
-rw-r--r-- | vcl/qt5/QtInstanceNotebook.cxx | 19 |
2 files changed, 24 insertions, 0 deletions
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: */ |