summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Weghorn <m.weghorn@posteo.de>2025-01-14 17:00:53 +0100
committerMichael Weghorn <m.weghorn@posteo.de>2025-01-15 11:13:08 +0100
commit1b14aced2b382eb876f27f17c251060361905a4a (patch)
tree15e93dad693eb2be606ec532f0d42f3313742444
parentb954798dc2a249c8cd12e9b384e0c157ac07f1ea (diff)
tdf#130857 qt weld: Implement QtInstanceMenuButton::insert_item
Add initial implementation for QtInstanceMenuButton::insert_item. See also QtBuilder::insertMenuObject which partially has the same logic. Handling for radio or check items is not implemented yet, so assert that `eCheckRadioFalse` is `TRISTATE_INDET` for now. This will e.g. be used by the "File" -> "Templates" -> "Manage Templates" dialog once that one is supported. Change-Id: Ib34d6b61b26ae900eac3b34b68224e6ac2e11711 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180250 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
-rw-r--r--vcl/inc/qt5/QtInstanceMenuButton.hxx2
-rw-r--r--vcl/qt5/QtInstanceMenuButton.cxx23
2 files changed, 21 insertions, 4 deletions
diff --git a/vcl/inc/qt5/QtInstanceMenuButton.hxx b/vcl/inc/qt5/QtInstanceMenuButton.hxx
index 1388bf29f688..398488076d30 100644
--- a/vcl/inc/qt5/QtInstanceMenuButton.hxx
+++ b/vcl/inc/qt5/QtInstanceMenuButton.hxx
@@ -22,7 +22,7 @@ class QtInstanceMenuButton : public QtInstanceToggleButton, public virtual weld:
public:
QtInstanceMenuButton(QToolButton* pButton);
- virtual void insert_item(int pos, const OUString& rId, const OUString& rStr,
+ virtual void insert_item(int nPos, const OUString& rId, const OUString& rStr,
const OUString* pIconName, VirtualDevice* pImageSurface,
TriState eCheckRadioFalse) override;
diff --git a/vcl/qt5/QtInstanceMenuButton.cxx b/vcl/qt5/QtInstanceMenuButton.cxx
index 8223e65b80ca..45191ef937f9 100644
--- a/vcl/qt5/QtInstanceMenuButton.cxx
+++ b/vcl/qt5/QtInstanceMenuButton.cxx
@@ -23,10 +23,27 @@ QtInstanceMenuButton::QtInstanceMenuButton(QToolButton* pButton)
assert(m_pToolButton);
}
-void QtInstanceMenuButton::insert_item(int, const OUString&, const OUString&, const OUString*,
- VirtualDevice*, TriState)
+void QtInstanceMenuButton::insert_item(int nPos, const OUString& rId, const OUString& rStr,
+ const OUString* pIconName, VirtualDevice* pImageSurface,
+ TriState eCheckRadioFalse)
{
- assert(false && "Not implemented yet");
+ SolarMutexGuard g;
+
+ assert(eCheckRadioFalse == TRISTATE_INDET && "Param not handled yet");
+ (void)eCheckRadioFalse;
+
+ GetQtInstance().RunInMainThread([&] {
+ if (nPos == -1)
+ nPos = getMenu().actions().count();
+
+ QAction* pAction = getMenu().addAction(vclToQtStringWithAccelerator(rStr));
+ pAction->setObjectName(toQString(rId));
+
+ if (pIconName)
+ pAction->setIcon(loadQPixmapIcon(*pIconName));
+ else if (pImageSurface)
+ pAction->setIcon(toQPixmap(*pImageSurface));
+ });
}
void QtInstanceMenuButton::insert_separator(int, const OUString&)