summaryrefslogtreecommitdiff
path: root/vcl/qt5
diff options
context:
space:
mode:
authorMichael Weghorn <m.weghorn@posteo.de>2024-10-04 14:41:29 +0200
committerMichael Weghorn <m.weghorn@posteo.de>2024-10-05 09:38:54 +0200
commit1d4b1feeb47bddd1743c7080dd8bd778fa770ede (patch)
tree2dd0cead0a8ba28544e250a17fa987022deb54dd /vcl/qt5
parentfe39249c795446641e83c06d49ac3c9e196fd660 (diff)
tdf#130857 qt weld: Handle help ID
Implement handling for the help ID by using a new property PROPERTY_HELP_ID that is set on the QtInstanceWidget's QWidget. Implement QtInstanceWidget::set_help_id and QtInstanceWidget::get_help_id accordingly. For setting the ID, introduce and use a static helper method QtInstanceWidget::setHelpId and use that in QtBuilder::makeObject to set the help ID based on help root and widget ID, in line with what is done at the end of VclBuilder::makeObject for the vcl::Window-based builder. Change-Id: I274886d8045b31ccbc92f586e2ead20ff7407d15 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174481 Reviewed-by: Michael Weghorn <m.weghorn@posteo.de> Tested-by: Jenkins
Diffstat (limited to 'vcl/qt5')
-rw-r--r--vcl/qt5/QtBuilder.cxx2
-rw-r--r--vcl/qt5/QtInstanceWidget.cxx31
2 files changed, 31 insertions, 2 deletions
diff --git a/vcl/qt5/QtBuilder.cxx b/vcl/qt5/QtBuilder.cxx
index 0ada179178e2..ad402df02043 100644
--- a/vcl/qt5/QtBuilder.cxx
+++ b/vcl/qt5/QtBuilder.cxx
@@ -165,6 +165,8 @@ QObject* QtBuilder::makeObject(QObject* pParent, std::u16string_view sName, cons
if (pParentLayout)
pParentLayout->addWidget(pWidget);
+ QtInstanceWidget::setHelpId(*pWidget, getHelpRoot() + sID);
+
#if QT_VERSION >= QT_VERSION_CHECK(6, 9, 0)
// Set GtkBuilder ID as accessible ID
pWidget->setAccessibleIdentifier(toQString(sID));
diff --git a/vcl/qt5/QtInstanceWidget.cxx b/vcl/qt5/QtInstanceWidget.cxx
index e0060ebc4905..3338fcb35c73 100644
--- a/vcl/qt5/QtInstanceWidget.cxx
+++ b/vcl/qt5/QtInstanceWidget.cxx
@@ -11,6 +11,9 @@
#include <vcl/transfer.hxx>
+/** Name of QObject property used for the help ID. */
+const char* const PROPERTY_HELP_ID = "help-id";
+
QtInstanceWidget::QtInstanceWidget(QWidget* pWidget)
: m_pWidget(pWidget)
{
@@ -197,9 +200,33 @@ OUString QtInstanceWidget::get_buildable_name() const { return OUString(); }
void QtInstanceWidget::set_buildable_name(const OUString&) {}
-void QtInstanceWidget::set_help_id(const OUString&) {}
+void QtInstanceWidget::setHelpId(QWidget& rWidget, const OUString& rHelpId)
+{
+ SolarMutexGuard g;
+ GetQtInstance().RunInMainThread(
+ [&] { rWidget.setProperty(PROPERTY_HELP_ID, toQString(rHelpId)); });
+}
+
+void QtInstanceWidget::set_help_id(const OUString& rHelpId) { setHelpId(*m_pWidget, 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 = m_pWidget->property(PROPERTY_HELP_ID);
+ if (!aHelpIdVariant.isValid())
+ return OUString();
-OUString QtInstanceWidget::get_help_id() const { return OUString(); }
+ assert(aHelpIdVariant.canConvert<QString>());
+ return toOUString(aHelpIdVariant.toString());
+}
void QtInstanceWidget::set_grid_left_attach(int) {}