Sketcher: Disable visibility checkbox for external geometry

This commit is contained in:
Kacper Donat
2024-01-21 19:47:42 +01:00
parent 2fac012226
commit 34b6b36547
3 changed files with 120 additions and 7 deletions

View File

@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="30"
height="30"
id="svg2"
version="1.1"
viewBox="0 0 30 29.999999"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:dc="http://purl.org/dc/elements/1.1/">
<defs
id="defs4" />
<metadata
id="metadata7">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:creator>
<cc:Agent>
<dc:title>Pablo Gil</dc:title>
</cc:Agent>
</dc:creator>
<dc:subject>
<rdf:Bag>
<rdf:li>SVG</rdf:li>
<rdf:li>template</rdf:li>
</rdf:Bag>
</dc:subject>
</cc:Work>
</rdf:RDF>
</metadata>
<g
id="layer1"
transform="translate(-1074.0663,-326.59799)">
<path
id="path8685"
d="m 1081.0663,345.09799 3.9999,4 12.0001,-12"
style="opacity:1;vector-effect:none;fill:none;fill-opacity:0.600939;stroke:#1b0909;stroke-width:6;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.117647" />
<path
style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#555555;stroke-width:6;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
d="m 1081.0663,342.59799 3.9999,4 12.0001,-12"
id="path7899" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="30"
height="30"
id="svg2"
version="1.1"
viewBox="0 0 30 29.999999"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:dc="http://purl.org/dc/elements/1.1/">
<defs
id="defs4" />
<metadata
id="metadata7">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:creator>
<cc:Agent>
<dc:title>Pablo Gil</dc:title>
</cc:Agent>
</dc:creator>
<dc:subject>
<rdf:Bag>
<rdf:li>SVG</rdf:li>
<rdf:li>template</rdf:li>
</rdf:Bag>
</dc:subject>
</cc:Work>
</rdf:RDF>
</metadata>
<g
id="layer1"
transform="translate(-1074.0663,-326.59799)">
<path
id="path8685"
d="m 1081.0663,345.09799 3.9999,4 12.0001,-12"
style="opacity:1;vector-effect:none;fill:none;fill-opacity:0.600939;stroke:#1b0909;stroke-width:6;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.117647" />
<path
style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#aaaaaa;stroke-width:6;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
d="m 1081.0663,342.59799 3.9999,4 12.0001,-12"
id="path7899" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@@ -193,7 +193,12 @@ public:
~ElementItem() override
{}
bool isVisible()
bool canBeHidden() const
{
return State != GeometryState::External;
}
bool isVisible() const
{
if (State != GeometryState::External) {
const auto geo = sketchView->getSketchObject()->getGeometry(ElementNbr);
@@ -957,10 +962,14 @@ void ElementItemDelegate::drawSubControl(SubControl element,
QStyleOptionButton checkboxOption;
checkboxOption.initFrom(option.widget);
checkboxOption.state |= QStyle::State_Enabled;
checkboxOption.rect = rect;
checkboxOption.state.setFlag(QStyle::State_Enabled, item->canBeHidden());
if (isHovered) {
checkboxOption.state |= QStyle::State_MouseOver;
}
if (item->isVisible()) {
checkboxOption.state |= QStyle::State_On;
}
@@ -1040,10 +1049,12 @@ bool ElementItemDelegate::editorEvent(QEvent* event, QAbstractItemModel* model,
item->clickedOn = getSubElementType(mouseEvent->pos());
item->rightClicked = mouseEvent->button() == Qt::RightButton;
QRect checkboxRect = subControlRect(SubControl::CheckBox, option, index);
if (item->canBeHidden()) {
QRect checkboxRect = subControlRect(SubControl::CheckBox, option, index);
if (mouseEvent->button() == Qt::LeftButton && checkboxRect.contains(mouseEvent->pos())) {
Q_EMIT itemChecked(index, item->isVisible() ? Qt::Unchecked : Qt::Checked);
if (mouseEvent->button() == Qt::LeftButton && checkboxRect.contains(mouseEvent->pos())) {
Q_EMIT itemChecked(index, item->isVisible() ? Qt::Unchecked : Qt::Checked);
}
}
}
else if (event->type() == QEvent::MouseMove) {
@@ -1056,7 +1067,7 @@ bool ElementItemDelegate::editorEvent(QEvent* event, QAbstractItemModel* model,
return QStyledItemDelegate::editorEvent(event, model, option, index);
}
const QWidget *w
ElementItem* ElementItemDelegate::getElementItem(const QModelIndex& index) const
{
ElementView* elementView = static_cast<ElementView*>(parent());