Skip to content

Commit

Permalink
Merge release-next into main
Browse files Browse the repository at this point in the history
  • Loading branch information
mantid-builder committed May 10, 2024
2 parents b7676f5 + 2d38088 commit f2b8b49
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 4 deletions.
6 changes: 6 additions & 0 deletions Framework/Kernel/inc/MantidKernel/Property.h
Expand Up @@ -196,6 +196,9 @@ class MANTID_KERNEL_DLL Property {
bool autoTrim() const;
void setAutoTrim(const bool &setting);

bool disableReplaceWSButton() const;
void setDisableReplaceWSButton(const bool &disable);

protected:
/// Constructor
Property(std::string name, const std::type_info &type, const unsigned int &direction = Direction::Input);
Expand Down Expand Up @@ -232,6 +235,9 @@ class MANTID_KERNEL_DLL Property {
/// Flag to determine if string inputs to the property should be automatically
/// trimmed of whitespace
bool m_autotrim;

/// Flag to disable the generation of the "Replace Workspace" button on the OutputWorkspace property
bool m_disableReplaceWSButton;
};

/// Compares this to another property for equality
Expand Down
16 changes: 14 additions & 2 deletions Framework/Kernel/src/Property.cpp
Expand Up @@ -28,7 +28,7 @@ namespace Kernel {
*/
Property::Property(std::string name, const std::type_info &type, const unsigned int &direction)
: m_name(std::move(name)), m_documentation(""), m_typeinfo(&type), m_direction(direction), m_units(""), m_group(""),
m_remember(true), m_autotrim(true) {
m_remember(true), m_autotrim(true), m_disableReplaceWSButton(false) {
if (m_name.empty()) {
throw std::invalid_argument("An empty property name is not permitted");
}
Expand All @@ -43,7 +43,7 @@ Property::Property(std::string name, const std::type_info &type, const unsigned
Property::Property(const Property &right)
: m_name(right.m_name), m_documentation(right.m_documentation), m_typeinfo(right.m_typeinfo),
m_direction(right.m_direction), m_units(right.m_units), m_group(right.m_group), m_remember(right.m_remember),
m_autotrim(right.m_autotrim) {
m_autotrim(right.m_autotrim), m_disableReplaceWSButton(right.m_disableReplaceWSButton) {
if (m_name.empty()) {
throw std::invalid_argument("An empty property name is not permitted");
}
Expand Down Expand Up @@ -342,6 +342,18 @@ bool Property::autoTrim() const { return m_autotrim; }
* @param setting The new setting value
*/
void Property::setAutoTrim(const bool &setting) { m_autotrim = setting; }

/**
* Returns if the property is set to disable the creation of the "Replace Workspace" button
* @returns True/False
*/
bool Property::disableReplaceWSButton() const { return m_disableReplaceWSButton; }

/**
* Sets the property to disable the creation of the "Replace Workspace" button
* @param disable The option to disable or not
*/
void Property::setDisableReplaceWSButton(const bool &disable) { m_disableReplaceWSButton = disable; }
} // namespace Kernel

} // namespace Mantid
9 changes: 9 additions & 0 deletions Framework/Kernel/test/PropertyTest.h
Expand Up @@ -99,6 +99,15 @@ class PropertyTest : public CxxTest::TestSuite {
TS_ASSERT(p3->remember());
}

void testDisableReplaceWSButton() {
auto p = std::make_unique<PropertyHelper>();
TS_ASSERT(!p->disableReplaceWSButton());
p->setDisableReplaceWSButton(true);
TS_ASSERT(p->disableReplaceWSButton());
p->setDisableReplaceWSButton(false);
TS_ASSERT(!p->disableReplaceWSButton());
}

private:
std::unique_ptr<Property> p;
};
Expand Up @@ -175,5 +175,7 @@ void export_Property() {
.add_static_property("EMPTY_LONG", emptyLong)

.def("setAutoTrim", &Property::setAutoTrim, (arg("setting")), "Setting automatic trimming of whitespaces.")
.def("getAutoTrim", &Property::autoTrim, "Gets the setting of automatic trimming of whitespaces.");
.def("getAutoTrim", &Property::autoTrim, "Gets the setting of automatic trimming of whitespaces.")
.def("setDisableReplaceWSButton", &Property::setDisableReplaceWSButton, (arg("disable")),
"Disable the creation of the Replace Workspace button.");
}
Expand Up @@ -169,6 +169,7 @@ def PyInit(self):
WorkspaceProperty("OutputWorkspace", "", direction=Direction.Output),
doc="Output Workspace",
)
self.getProperty("OutputWorkspace").setDisableReplaceWSButton(True)

self.declareProperty(
"Sum",
Expand Down
@@ -0,0 +1 @@
- Remove the confusing "Replace input workspace" button in the :ref:`WANDPowderReduction <algm-WANDPowderReduction>` algorithm
2 changes: 1 addition & 1 deletion qt/widgets/common/src/AlgorithmPropertiesWidget.cpp
Expand Up @@ -255,7 +255,7 @@ void AlgorithmPropertiesWidget::initLayout() {

// Only show the "Replace Workspace" button if the algorithm has an input
// workspace.
if (hasInputWS)
if (hasInputWS && !prop->disableReplaceWSButton())
widget->addReplaceWSButton();

++row;
Expand Down

0 comments on commit f2b8b49

Please sign in to comment.