vcl/inc/qt5/QtInstanceWidget.hxx | 2 ++ vcl/qt5/QtInstanceTreeView.cxx | 9 +++++++++ vcl/qt5/QtInstanceWidget.cxx | 36 ++++++++++++++++++------------------ 3 files changed, 29 insertions(+), 18 deletions(-)
New commits: commit baab1f2c78d52e2d4b38d70de852030d3c56f529 Author: Michael Weghorn <[email protected]> AuthorDate: Tue Dec 9 21:29:15 2025 +0100 Commit: Michael Weghorn <[email protected]> CommitDate: Wed Dec 10 17:41:33 2025 +0100 tdf#130857 qt weld: Extract helper method to set help ID Extract the logic from QtInstanceWidget::get_help_id to a new static helper method. This will be reused in QtInstanceMenu in an upcoming commit. Change-Id: Ifc6ac06232db1fd4e865af22b556eff0229cd55d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195341 Tested-by: Jenkins Reviewed-by: Michael Weghorn <[email protected]> diff --git a/vcl/inc/qt5/QtInstanceWidget.hxx b/vcl/inc/qt5/QtInstanceWidget.hxx index 045b1c9855ab..ea953358ad3a 100644 --- a/vcl/inc/qt5/QtInstanceWidget.hxx +++ b/vcl/inc/qt5/QtInstanceWidget.hxx @@ -180,6 +180,8 @@ public: virtual bool eventFilter(QObject* pObject, QEvent* pEvent) override; void setFont(vcl::Font rFont); + + static OUString getHelpId(QWidget& rWidget); static void setHelpId(QWidget& rWidget, const OUString& rHelpId); protected: diff --git a/vcl/qt5/QtInstanceWidget.cxx b/vcl/qt5/QtInstanceWidget.cxx index 8531e279703a..fa6e4afb8b07 100644 --- a/vcl/qt5/QtInstanceWidget.cxx +++ b/vcl/qt5/QtInstanceWidget.cxx @@ -350,6 +350,23 @@ void QtInstanceWidget::setFont(vcl::Font rFont) GetQtInstance().RunInMainThread([&] { getQWidget()->setFont(toQtFont(rFont)); }); } +OUString QtInstanceWidget::getHelpId(QWidget& rWidget) +{ + SolarMutexGuard g; + + OUString sHelpId; + GetQtInstance().RunInMainThread([&] { + const QVariant aHelpIdVariant = rWidget.property(PROPERTY_HELP_ID); + if (!aHelpIdVariant.isValid()) + return; + + assert(aHelpIdVariant.canConvert<QString>()); + sHelpId = toOUString(aHelpIdVariant.toString()); + }); + + return sHelpId; +} + void QtInstanceWidget::setHelpId(QWidget& rWidget, const OUString& rHelpId) { SolarMutexGuard g; @@ -359,24 +376,7 @@ void QtInstanceWidget::setHelpId(QWidget& rWidget, const OUString& rHelpId) void QtInstanceWidget::set_help_id(const OUString& rHelpId) { setHelpId(*getQWidget(), rHelpId); } -OUString QtInstanceWidget::get_help_id() const -{ - SolarMutexGuard g; - QtInstance& rQtInstance = GetQtInstance(); - if (!rQtInstance.IsMainThread()) - { - OUString sHelpId; - rQtInstance.RunInMainThread([&] { sHelpId = get_help_id(); }); - return sHelpId; - } - - const QVariant aHelpIdVariant = getQWidget()->property(PROPERTY_HELP_ID); - if (!aHelpIdVariant.isValid()) - return OUString(); - - assert(aHelpIdVariant.canConvert<QString>()); - return toOUString(aHelpIdVariant.toString()); -} +OUString QtInstanceWidget::get_help_id() const { return getHelpId(*getQWidget()); } void QtInstanceWidget::set_hexpand(bool bExpand) { commit 5d287676541d4f844b9b641a05f392d351f30d72 Author: Michael Weghorn <[email protected]> AuthorDate: Tue Dec 9 20:13:07 2025 +0100 Commit: Michael Weghorn <[email protected]> CommitDate: Wed Dec 10 17:41:24 2025 +0100 tdf#130857 qt weld: Forward TreeView context menu event Call the base class method weld::TreeView::signal_popup_menu when a QContextMenuEvent is received in QtInstanceTreeView's underlying QTreeView. This will be used e.g. for the following scenario once support for that dialog will be declared: * start Writer * "File" -> "Templates" -> "Manage Templates" * enable the "List View" by clicking on the corresponding button * select an entry and right-click on it to open the context menu (More is missing to be able to declare support for the dialog, but this makes showing the context menu work in a corresponding WIP branch.) Change-Id: Ib6e66e12669462da839063a7642e02ba125818c3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195338 Tested-by: Jenkins Reviewed-by: Michael Weghorn <[email protected]> diff --git a/vcl/qt5/QtInstanceTreeView.cxx b/vcl/qt5/QtInstanceTreeView.cxx index 75cf1214a926..0a1fe12d3eac 100644 --- a/vcl/qt5/QtInstanceTreeView.cxx +++ b/vcl/qt5/QtInstanceTreeView.cxx @@ -10,6 +10,7 @@ #include <QtInstanceTreeView.hxx> #include <QtInstanceTreeView.moc> +#include <vcl/commandevent.hxx> #include <vcl/qt/QtUtils.hxx> #include <QtWidgets/QHeaderView> @@ -1110,6 +1111,14 @@ bool QtInstanceTreeView::eventFilter(QObject* pObject, QEvent* pEvent) if (pEvent->type() == QEvent::ToolTip && pObject == m_pTreeView->viewport()) return handleViewPortToolTipEvent(static_cast<QHelpEvent&>(*pEvent)); + if (pEvent->type() == QEvent::ContextMenu) + { + QContextMenuEvent* pContextMenuEvent = static_cast<QContextMenuEvent*>(pEvent); + CommandEvent aCEvt(toPoint(pContextMenuEvent->pos()), CommandEventId::ContextMenu, + pContextMenuEvent->reason() == QContextMenuEvent::Mouse); + return signal_popup_menu(aCEvt); + } + return QtInstanceWidget::eventFilter(pObject, pEvent); }
