[Libreoffice-commits] core.git: extensions/source include/vcl vcl/inc vcl/source vcl/unx
Caolán McNamara (via logerrit)
logerrit at kemper.freedesktop.org
Tue Nov 24 16:02:28 UTC 2020
extensions/source/propctrlr/formcomponenthandler.cxx | 4 ++
include/vcl/weld.hxx | 26 +++++++++++++------
vcl/inc/salvtables.hxx | 2 +
vcl/source/app/salvtables.cxx | 2 +
vcl/unx/gtk3/gtk3gtkinst.cxx | 5 +++
5 files changed, 31 insertions(+), 8 deletions(-)
New commits:
commit d4ca173f2babde53c1d20f10e335244b092c5c97
Author: Caolán McNamara <caolanm at redhat.com>
AuthorDate: Tue Nov 24 12:33:05 2020 +0000
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Tue Nov 24 17:01:46 2020 +0100
add set_buildable_name to enable distinguishing different instances
of widgets loaded from the same .ui snippet in the same dialog so
ui-testing can identify the right one
Change-Id: I2ecc7fd60ab891ae9f94971a3035585d4500f694
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106500
Tested-by: Xisco Fauli <xiscofauli at libreoffice.org>
Tested-by: Caolán McNamara <caolanm at redhat.com>
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/extensions/source/propctrlr/formcomponenthandler.cxx b/extensions/source/propctrlr/formcomponenthandler.cxx
index a981f7dff30c..c0f3cea4e51d 100644
--- a/extensions/source/propctrlr/formcomponenthandler.cxx
+++ b/extensions/source/propctrlr/formcomponenthandler.cxx
@@ -1108,6 +1108,8 @@ namespace pcr
{
std::unique_ptr<weld::Builder> xBuilder(PropertyHandlerHelper::makeBuilder("modules/spropctrlr/ui/formattedcontrol.ui", m_xContext));
auto pSpinButton = xBuilder->weld_formatted_spin_button("formattedcontrol");
+ // for ui-testing try and distinguish different instances of this formatted control
+ pSpinButton->set_buildable_name(pSpinButton->get_buildable_name() + "-" + aDescriptor.DisplayName.toUtf8());
auto pControl = new OFormattedNumericControl(std::move(pSpinButton), std::move(xBuilder), false);
pControl->SetModifyHandler();
@@ -1147,6 +1149,8 @@ namespace pcr
{
std::unique_ptr<weld::Builder> xBuilder(PropertyHandlerHelper::makeBuilder("modules/spropctrlr/ui/formattedcontrol.ui", m_xContext));
auto pSpinButton = xBuilder->weld_formatted_spin_button("formattedcontrol");
+ // for ui-testing try and distinguish different instances of this formatted control
+ pSpinButton->set_buildable_name(pSpinButton->get_buildable_name() + "-" + aDescriptor.DisplayName.toUtf8());
auto pControl = new OFormattedNumericControl(std::move(pSpinButton), std::move(xBuilder), false);
pControl->SetModifyHandler();
aDescriptor.Control = pControl;
diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx
index 28dd95818293..10686ffe705e 100644
--- a/include/vcl/weld.hxx
+++ b/include/vcl/weld.hxx
@@ -117,15 +117,25 @@ public:
// The name of the widget in the GtkBuilder UI definition used to construct it.
virtual OString get_buildable_name() const = 0;
+ /*
+ Typically there is no need to change the buildable name at runtime, changing
+ the id in .ui file itself is preferred.
- /* The help id of the widget used to identify help for this widget.
- *
- * By default the help id of a widget is a path-like sequence of
- * buildable-names from the widgets UI definition ancestor to this
- * widget, e.g. grandparent/parent/widget.
- *
- * The default can be overwritten with set_help_id
- */
+ But for ui-testing purposes it can sometimes be useful to rename
+ different widgets, that were loaded from the same .ui, to unique names
+ in order to distinguish between them
+ */
+ virtual void set_buildable_name(const OString& rName) = 0;
+
+ /*
+ The help id of the widget used to identify help for this widget.
+
+ By default the help id of a widget is a path-like sequence of (load-time)
+ buildable-names from the widgets UI definition ancestor to this widget,
+ e.g. grandparent/parent/widget.
+
+ The default can be overwritten with set_help_id
+ */
virtual OString get_help_id() const = 0;
virtual void set_help_id(const OString& rName) = 0;
diff --git a/vcl/inc/salvtables.hxx b/vcl/inc/salvtables.hxx
index f3f4a585cecf..4fca8ff49cc5 100644
--- a/vcl/inc/salvtables.hxx
+++ b/vcl/inc/salvtables.hxx
@@ -234,6 +234,8 @@ public:
virtual OString get_buildable_name() const override;
+ virtual void set_buildable_name(const OString& rId) override;
+
virtual void set_help_id(const OString& rId) override;
virtual OString get_help_id() const override;
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index 03f68e381163..c1421562d2c0 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -312,6 +312,8 @@ vcl::Font SalInstanceWidget::get_font() { return m_xWidget->GetPointFont(*m_xWid
OString SalInstanceWidget::get_buildable_name() const { return m_xWidget->get_id().toUtf8(); }
+void SalInstanceWidget::set_buildable_name(const OString& rId) { return m_xWidget->set_id(OUString::fromUtf8(rId)); }
+
void SalInstanceWidget::set_help_id(const OString& rId) { return m_xWidget->SetHelpId(rId); }
OString SalInstanceWidget::get_help_id() const { return m_xWidget->GetHelpId(); }
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx
index c045e8e7ac80..af7653b71e57 100644
--- a/vcl/unx/gtk3/gtk3gtkinst.cxx
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx
@@ -2837,6 +2837,11 @@ public:
return OString(pStr, pStr ? strlen(pStr) : 0);
}
+ virtual void set_buildable_name(const OString& rId) override
+ {
+ gtk_buildable_set_name(GTK_BUILDABLE(m_pWidget), rId.getStr());
+ }
+
virtual void set_help_id(const OString& rHelpId) override
{
::set_help_id(m_pWidget, rHelpId);
More information about the Libreoffice-commits
mailing list