Fix visibility icon for link elements
The visibility of link elements must be set with setElementVisible. This will first try to use that API otherwise it falls back to setting the Visibility property.
This commit is contained in:
committed by
Chris Hennes
parent
b9cc70ff99
commit
60ec5db4b3
@@ -1622,12 +1622,25 @@ void TreeWidget::mousePressEvent(QMouseEvent* event)
|
||||
|
||||
// If the visibility icon was clicked, toggle the DocumentObject visibility
|
||||
if (iconRect.contains(mousePos)) {
|
||||
auto vp = objitem->object();
|
||||
if (vp->isShow()) {
|
||||
vp->hide();
|
||||
} else {
|
||||
vp->show();
|
||||
auto obj = objitem->object()->getObject();
|
||||
char const* objname = obj->getNameInDocument();
|
||||
|
||||
App::DocumentObject* parent = nullptr;
|
||||
std::ostringstream subName;
|
||||
objitem->getSubName(subName, parent);
|
||||
|
||||
// Try the ElementVisible API, if that is not supported toggle the Visibility property
|
||||
int visible = -1;
|
||||
if (parent) {
|
||||
visible = parent->isElementVisible(objname);
|
||||
}
|
||||
if (parent && visible >= 0) {
|
||||
parent->setElementVisible(objname, !visible);
|
||||
} else {
|
||||
visible = obj->Visibility.getValue();
|
||||
obj->Visibility.setValue(!visible);
|
||||
}
|
||||
|
||||
event->setAccepted(true);
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user