vcl/inc/qt5/QtInstanceWindow.hxx | 3 +++ vcl/qt5/QtInstanceWindow.cxx | 27 +++++++++++++++++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-)
New commits: commit 455b86ba6d26c0186a3954e6f06c12de9fa02b12 Author: Michael Weghorn <[email protected]> AuthorDate: Thu Feb 12 23:12:33 2026 +0100 Commit: Michael Weghorn <[email protected]> CommitDate: Fri Feb 13 09:10:18 2026 +0100 tdf#130857 qt weld: Implement QtInstanceWindow::collect_screenshot_data Implement in line with what the GTK and vcl implementations do. This will be used to allow highlighting widgets in the screenshot annotation that can be triggered as described at [1]: > To create dialog screenshots from running LibreOffice, you need to > activate screenshotting mode (akin to experimental mode) in Tools ▸ > Options ▸ Advanced ▸ Open Expert Configuration, the relevant > configuration key is org.openoffice.Office.Common.Misc.ScreenshotMode. > Once screenshotting mode is active, right mouse click into any dialog > action area (where "OK", "Cancel" etc. buttons are) will make a context > menu appear: > > Click Screenshot item of the context menu to create screenshot of the > current dialog. For QtInstanceDialog, the logic to actually trigger the dialog is not implemented yet, but in a WIP branch where it is, the area of the widgets are shown as expected when the dialog gets triggered for the "Help" -> "About LibreOffice" dialog. [1] https://wiki.documentfoundation.org/Documentation/Screenshots#Creating_screenshots_manually Change-Id: I6436b1e1188b9b19b1c997923c591e984f31dca5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/199310 Tested-by: Jenkins Reviewed-by: Michael Weghorn <[email protected]> diff --git a/vcl/inc/qt5/QtInstanceWindow.hxx b/vcl/inc/qt5/QtInstanceWindow.hxx index 5ae39260838a..ecf3f98cc2f7 100644 --- a/vcl/inc/qt5/QtInstanceWindow.hxx +++ b/vcl/inc/qt5/QtInstanceWindow.hxx @@ -48,6 +48,9 @@ public: virtual const vcl::ILibreOfficeKitNotifier* GetLOKNotifier() override; bool eventFilter(QObject* pObject, QEvent* pEvent) override; + +private: + void collectScreenShotData(QWidget& rWidget, weld::ScreenShotCollection& rScreenShotCollection); }; /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/vcl/qt5/QtInstanceWindow.cxx b/vcl/qt5/QtInstanceWindow.cxx index 2999133c5691..323e84258195 100644 --- a/vcl/qt5/QtInstanceWindow.cxx +++ b/vcl/qt5/QtInstanceWindow.cxx @@ -190,10 +190,33 @@ SystemEnvData QtInstanceWindow::get_system_data() const void QtInstanceWindow::resize_to_request() { queue_resize(); } +void QtInstanceWindow::collectScreenShotData(QWidget& rWidget, + weld::ScreenShotCollection& rScreenShotCollection) +{ + if (!rWidget.isVisible()) + return; + + const QRect aGeometry( + rWidget.mapTo(rWidget.topLevelWidget(), rWidget.mapFromParent(rWidget.pos())), + rWidget.size()); + + const basegfx::B2IRange aRange(aGeometry.left(), aGeometry.top(), aGeometry.right(), + aGeometry.bottom()); + if (!aGeometry.isEmpty()) + rScreenShotCollection.emplace_back(QtInstanceWidget::getHelpId(rWidget), aRange); + + for (QObject* pChild : rWidget.children()) + { + if (pChild && pChild->isWidgetType()) + collectScreenShotData(static_cast<QWidget&>(*pChild), rScreenShotCollection); + } +} + weld::ScreenShotCollection QtInstanceWindow::collect_screenshot_data() { - assert(false && "Not implemented yet"); - return weld::ScreenShotCollection(); + weld::ScreenShotCollection aScreenShotCollection; + collectScreenShotData(*getQWidget(), aScreenShotCollection); + return aScreenShotCollection; } VclPtr<VirtualDevice> QtInstanceWindow::screenshot()
