include/vcl/weld/Menu.hxx | 1 + vcl/UIConfig_vcl.mk | 1 + vcl/inc/qt5/QtInstanceMenu.hxx | 1 + vcl/inc/salvtables.hxx | 1 + vcl/qt5/QtInstanceMenu.cxx | 10 ++++++++++ vcl/source/app/salvtables.cxx | 31 ++++++++++++++++++------------- vcl/uiconfig/ui/screenshotmenu.ui | 9 +++++++++ vcl/unx/gtk3/gtkinst.cxx | 24 ++++++++++++++++++++---- 8 files changed, 61 insertions(+), 17 deletions(-)
New commits: commit 4511cb851436765cae77f412bea26cd1505e6303 Author: Michael Weghorn <[email protected]> AuthorDate: Fri Feb 13 11:46:42 2026 +0100 Commit: Michael Weghorn <[email protected]> CommitDate: Sat Feb 14 00:49:26 2026 +0100 tdf#130857 gtk weld: Extract GtkInstanceWidget::ensurePopupMenuSignal helper This is similar to GtkInstanceWidget::ensureButtonPressSignal and will be reused in an upcoming commit. Change-Id: Iaf3a7e56f919de66ee6d77177c40cfd73ff904a5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/199341 Reviewed-by: Michael Weghorn <[email protected]> Tested-by: Jenkins diff --git a/vcl/unx/gtk3/gtkinst.cxx b/vcl/unx/gtk3/gtkinst.cxx index eea75a5b3741..d1f53f59eef0 100644 --- a/vcl/unx/gtk3/gtkinst.cxx +++ b/vcl/unx/gtk3/gtkinst.cxx @@ -2584,6 +2584,14 @@ protected: } } + void ensurePopupMenuSignal() + { +#if !GTK_CHECK_VERSION(4, 0, 0) + if (!m_nPopupMenuSignalId) + m_nPopupMenuSignalId = g_signal_connect(m_pWidget, "popup-menu", G_CALLBACK(signalPopupMenu), this); +#endif + } + #if !GTK_CHECK_VERSION(4, 0, 0) static gboolean signalPopupMenu(GtkWidget* pWidget, gpointer widget) { @@ -3394,11 +3402,9 @@ public: virtual void connect_command(const Link<const CommandEvent&, bool>& rLink) override { -#if !GTK_CHECK_VERSION(4, 0, 0) - if (!m_nPopupMenuSignalId) - m_nPopupMenuSignalId = g_signal_connect(m_pWidget, "popup-menu", G_CALLBACK(signalPopupMenu), this); -#endif + ensureButtonPressSignal(); + ensurePopupMenuSignal(); weld::Widget::connect_command(rLink); } commit 90bdc8480f3edde089e3d7f5b6ddb178df0194cf Author: Michael Weghorn <[email protected]> AuthorDate: Fri Feb 13 11:13:11 2026 +0100 Commit: Michael Weghorn <[email protected]> CommitDate: Sat Feb 14 00:49:19 2026 +0100 tdf#130857 vcl: Port dialog screenshot menu to weld abstraction Port the logic in SalInstanceDialog::PopupScreenShotMenuHdl from creating a PopupMenu directly to instead use the weld::Menu abstraction. This will allow reusing this implementation in the GTK- and Qt-based weld::Dialog implementations as well in an upcoming commit. The menu/dialog 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. [1] https://wiki.documentfoundation.org/Documentation/Screenshots#Creating_screenshots_manually Change-Id: I1fa5c132e485ec0042176e9cc5b6f07fcdce7c75 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/199340 Tested-by: Jenkins Reviewed-by: Michael Weghorn <[email protected]> diff --git a/vcl/UIConfig_vcl.mk b/vcl/UIConfig_vcl.mk index a0bf093c25c2..0ccfb2f5dd84 100644 --- a/vcl/UIConfig_vcl.mk +++ b/vcl/UIConfig_vcl.mk @@ -25,6 +25,7 @@ $(eval $(call gb_UIConfig_add_uifiles,vcl,\ vcl/uiconfig/ui/printerpropertiesdialog \ vcl/uiconfig/ui/printprogressdialog \ vcl/uiconfig/ui/querydialog \ + vcl/uiconfig/ui/screenshotmenu \ vcl/uiconfig/ui/screenshotparent \ vcl/uiconfig/ui/wizard \ vcl/uiconfig/ui/openlockedquerybox \ diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx index a5d24a04055e..14434d5adc9d 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -1982,19 +1982,18 @@ IMPL_LINK(SalInstanceDialog, PopupScreenShotMenuHdl, const CommandEvent&, rCEvt, { if (CommandEventId::ContextMenu == rCEvt.GetCommand()) { - const Point aMenuPos(rCEvt.GetMousePosPixel()); - ScopedVclPtrInstance<PopupMenu> aMenu; - sal_uInt16 nLocalID(1); - - aMenu->InsertItem(nLocalID, VclResId(SV_BUTTONTEXT_SCREENSHOT)); - aMenu->SetHelpText(nLocalID, VclResId(SV_HELPTEXT_SCREENSHOT)); - aMenu->SetHelpId(nLocalID, u"InteractiveScreenshotMode"_ustr); - aMenu->EnableItem(nLocalID); - - const sal_uInt16 nId(aMenu->Execute(m_xDialog, aMenuPos)); - - // 0 == no selection (so not usable as ID) - if (0 != nId) + std::unique_ptr<weld::Builder> xBuilder( + Application::CreateBuilder(this, u"vcl/ui/screenshotmenu.ui"_ustr)); + std::unique_ptr<weld::Menu> pMenu = xBuilder->weld_menu(u"menu"_ustr); + static constexpr OUString sMenuItemId = u"screenshot"_ustr; + pMenu->append(sMenuItemId, VclResId(SV_BUTTONTEXT_SCREENSHOT)); + // set tooltip if extended tips are enabled + if (ImplGetSVHelpData().mbBalloonHelp) + pMenu->set_tooltip_text(sMenuItemId, VclResId(SV_HELPTEXT_SCREENSHOT)); + pMenu->set_item_help_id(sMenuItemId, u"InteractiveScreenshotMode"_ustr); + + if (pMenu->popup_at_rect(this, tools::Rectangle(rCEvt.GetMousePosPixel(), Size(1, 1))) + == sMenuItemId) executeScreenshotAnnotationDialog(); // consume event when: diff --git a/vcl/uiconfig/ui/screenshotmenu.ui b/vcl/uiconfig/ui/screenshotmenu.ui new file mode 100644 index 000000000000..70ee6b794194 --- /dev/null +++ b/vcl/uiconfig/ui/screenshotmenu.ui @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Generated with glade 3.40.0 --> +<interface domain="vcl"> + <requires lib="gtk+" version="3.24"/> + <object class="GtkMenu" id="menu"> + <property name="visible">True</property> + <property name="can-focus">False</property> + </object> +</interface> commit 084709b42601fa165649e29d7b010b33ee513f05 Author: Michael Weghorn <[email protected]> AuthorDate: Fri Feb 13 10:55:04 2026 +0100 Commit: Michael Weghorn <[email protected]> CommitDate: Sat Feb 14 00:49:12 2026 +0100 tdf#130857 weld: Add weld::Menu::set_tooltip_text to set item tooltip Add this new method that allows setting the tooltip for a menu item. This will be used in an upcoming commit to replace the current implementation to trigger a menu to start the screenshot annotation dialog in SalInstanceDialog::PopupScreenShotMenuHdl (and equivalent for gtk3) with one shared implementation based using the weld::Menu API/abstraction. Change-Id: I152444515f404938107c5a2d83f96b5f2452bdc9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/199339 Reviewed-by: Michael Weghorn <[email protected]> Tested-by: Jenkins diff --git a/include/vcl/weld/Menu.hxx b/include/vcl/weld/Menu.hxx index 7513e994a222..06dfe7fbe4e9 100644 --- a/include/vcl/weld/Menu.hxx +++ b/include/vcl/weld/Menu.hxx @@ -34,6 +34,7 @@ public: virtual bool get_sensitive(const OUString& rIdent) const = 0; virtual void set_label(const OUString& rIdent, const OUString& rLabel) = 0; virtual OUString get_label(const OUString& rIdent) const = 0; + virtual void set_tooltip_text(const OUString& rIdent, const OUString& rTip) = 0; virtual void set_active(const OUString& rIdent, bool bActive) = 0; virtual bool get_active(const OUString& rIdent) const = 0; virtual void set_visible(const OUString& rIdent, bool bVisible) = 0; diff --git a/vcl/inc/qt5/QtInstanceMenu.hxx b/vcl/inc/qt5/QtInstanceMenu.hxx index 271e8a51bc44..7aa69569492c 100644 --- a/vcl/inc/qt5/QtInstanceMenu.hxx +++ b/vcl/inc/qt5/QtInstanceMenu.hxx @@ -32,6 +32,7 @@ public: virtual bool get_sensitive(const OUString& rIdent) const override; virtual void set_label(const OUString& rIdent, const OUString& rLabel) override; virtual OUString get_label(const OUString& rIdent) const override; + virtual void set_tooltip_text(const OUString& rIdent, const OUString& rTip) override; virtual void set_active(const OUString& rIdent, bool bActive) override; virtual bool get_active(const OUString& rIdent) const override; virtual void set_visible(const OUString& rIdent, bool bVisible) override; diff --git a/vcl/inc/salvtables.hxx b/vcl/inc/salvtables.hxx index 14a7c9be7a8c..06163e9ea6e5 100644 --- a/vcl/inc/salvtables.hxx +++ b/vcl/inc/salvtables.hxx @@ -189,6 +189,7 @@ public: virtual bool get_active(const OUString& rIdent) const override; virtual void set_label(const OUString& rIdent, const OUString& rLabel) override; virtual OUString get_label(const OUString& rIdent) const override; + virtual void set_tooltip_text(const OUString& rIdent, const OUString& rTip) override; virtual void set_visible(const OUString& rIdent, bool bShow) override; virtual void clear() override; virtual void insert(int pos, const OUString& rId, const OUString& rStr, diff --git a/vcl/qt5/QtInstanceMenu.cxx b/vcl/qt5/QtInstanceMenu.cxx index d4a76085ab71..4e33f1a0edba 100644 --- a/vcl/qt5/QtInstanceMenu.cxx +++ b/vcl/qt5/QtInstanceMenu.cxx @@ -116,6 +116,16 @@ OUString QtInstanceMenu::get_label(const OUString& rIdent) const return sLabel; } +void QtInstanceMenu::set_tooltip_text(const OUString& rIdent, const OUString& rTip) +{ + SolarMutexGuard g; + + GetQtInstance().RunInMainThread([&] { + if (QAction* pAction = getAction(rIdent)) + pAction->setToolTip(toQString(rTip)); + }); +} + void QtInstanceMenu::set_active(const OUString& rIdent, bool bActive) { SolarMutexGuard g; diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx index 3f446a776659..a5d24a04055e 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -940,6 +940,12 @@ OUString SalInstanceMenu::get_label(const OUString& rIdent) const { return m_xMenu->GetItemText(m_xMenu->GetItemId(rIdent)); } + +void SalInstanceMenu::set_tooltip_text(const OUString& rIdent, const OUString& rTip) +{ + m_xMenu->SetTipHelpText(m_xMenu->GetItemId(rIdent), rTip); +} + void SalInstanceMenu::set_visible(const OUString& rIdent, bool bShow) { m_xMenu->ShowItem(m_xMenu->GetItemId(rIdent), bShow); diff --git a/vcl/unx/gtk3/gtkinst.cxx b/vcl/unx/gtk3/gtkinst.cxx index 4d55047104e6..eea75a5b3741 100644 --- a/vcl/unx/gtk3/gtkinst.cxx +++ b/vcl/unx/gtk3/gtkinst.cxx @@ -11397,6 +11397,16 @@ public: return get_item_label(rIdent); } + virtual void set_tooltip_text(const OUString& rIdent, const OUString& rTip) override + { +#if !GTK_CHECK_VERSION(4, 0, 0) + gtk_widget_set_tooltip_text(GTK_WIDGET(m_aMap[rIdent]), rTip.toUtf8().getStr()); +#else + (void)rIdent; + (void)rTip; +#endif + } + virtual void insert_separator(int pos, const OUString& rId) override { MenuHelper::insert_separator(pos, rId);
