Merge pull request #14393 from NomAnor/visibility-icon

Change visibility icon default to enabled and tweak visuals
This commit is contained in:
Chris Hennes
2024-06-17 10:36:35 -05:00
committed by GitHub
4 changed files with 41 additions and 27 deletions

View File

@@ -2,20 +2,20 @@
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="64px"
height="64px"
id="svg2816"
version="1.1"
inkscape:version="0.91 r13725"
sodipodi:docname="TreeItemInvisible.svg">
inkscape:version="1.3.2 (091e20ef0f, 2023-11-25, custom)"
sodipodi:docname="TreeItemInvisible.svg"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:xlink="http://www.w3.org/1999/xlink"
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="defs2818">
<linearGradient
@@ -509,8 +509,8 @@
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="5.5"
inkscape:cx="35.267952"
inkscape:cy="19.835481"
inkscape:cx="35.363636"
inkscape:cy="19.818182"
inkscape:current-layer="layer1"
showgrid="true"
inkscape:document-units="px"
@@ -522,19 +522,27 @@
inkscape:snap-bbox-midpoints="true"
inkscape:object-paths="true"
inkscape:object-nodes="true"
inkscape:window-width="1301"
inkscape:window-height="744"
inkscape:window-x="65"
inkscape:window-y="24"
inkscape:window-width="3840"
inkscape:window-height="2074"
inkscape:window-x="3840"
inkscape:window-y="49"
inkscape:window-maximized="1"
inkscape:snap-global="true">
inkscape:snap-global="true"
inkscape:showpageshadow="2"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#d1d1d1">
<inkscape:grid
type="xygrid"
id="grid3234"
empspacing="2"
visible="true"
enabled="true"
snapvisiblegridlinesonly="true" />
snapvisiblegridlinesonly="true"
originx="0"
originy="0"
spacingy="1"
spacingx="1"
units="px" />
</sodipodi:namedview>
<metadata
id="metadata2821">
@@ -587,7 +595,7 @@
style="opacity:0.8479996;fill:#ffffff;stroke:none;stroke-width:0.18025407;stroke-opacity:1" />
</g>
<rect
style="opacity:1;fill:#ff0000;fill-opacity:1;stroke:#ffffff;stroke-width:2.00000024;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
style="opacity:1;fill:#666666;fill-opacity:1;stroke:#ffffff;stroke-width:2.00000024;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect4909"
width="6.1190372"
height="59.347763"

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 22 KiB

View File

@@ -1688,15 +1688,19 @@ void TreeWidget::mousePressEvent(QMouseEvent* event)
// Rect occupied by the item relative to viewport
auto iconRect = visualItemRect(objitem);
auto style = this->style();
// If the checkboxes are visible, these are displayed before the icon
// and we have to compensate for its width.
if (isSelectionCheckBoxesEnabled()) {
auto style = this->style();
int checkboxWidth = style->pixelMetric(QStyle::PM_IndicatorWidth)
+ style->pixelMetric(QStyle::PM_LayoutHorizontalSpacing);
iconRect.adjust(checkboxWidth, 0, 0, 0);
}
int const margin = style->pixelMetric(QStyle::PM_FocusFrameHMargin) + 1;
iconRect.adjust(margin, 0, 0, 0);
// We are interested in the first icon (visibility icon)
iconRect.setWidth(iconSize());
@@ -5308,7 +5312,7 @@ void DocumentObjectItem::testStatus(bool resetStatus, QIcon& icon1, QIcon& icon2
previousStatus = currentStatus;
QIcon::Mode mode = QIcon::Normal;
if (isVisibilityIconEnabled() || (currentStatus & Status::Visible)) {
if (currentStatus & Status::Visible) {
// Note: By default the foreground, i.e. text color is invalid
// to make use of the default color of the tree widget's palette.
// If we temporarily set this color to dark and reset to an invalid
@@ -5426,17 +5430,19 @@ void DocumentObjectItem::testStatus(bool resetStatus, QIcon& icon1, QIcon& icon2
// Prepend the visibility pixmap to the final icon pixmaps and use these as the icon.
QIcon new_icon;
auto style = this->getTree()->style();
int const spacing = style->pixelMetric(QStyle::PM_LayoutHorizontalSpacing);
for (auto state: {QIcon::On, QIcon::Off}) {
QPixmap px_org = icon.pixmap(0xFFFF, 0xFFFF, QIcon::Normal, state);
QPixmap px(2*px_org.width(), px_org.height());
QPixmap px(2*px_org.width() + spacing, px_org.height());
px.fill(Qt::transparent);
QPainter pt;
pt.begin(&px);
pt.setPen(Qt::NoPen);
pt.drawPixmap(0, 0, px_org.width(), px_org.height(), (currentStatus & Status::Visible) ? pxVisible : pxInvisible);
pt.drawPixmap(px_org.width(), 0, px_org.width(), px_org.height(), px_org);
pt.drawPixmap(px_org.width() + spacing, 0, px_org.width(), px_org.height(), px_org);
pt.end();
new_icon.addPixmap(px, QIcon::Normal, state);

View File

@@ -163,7 +163,7 @@ public:
funcs["ColumnSize3"] = &TreeParamsP::updateColumnSize3;
TreeToolTipIcon = handle->GetBool("TreeToolTipIcon", false);
funcs["TreeToolTipIcon"] = &TreeParamsP::updateTreeToolTipIcon;
VisibilityIcon = handle->GetBool("VisibilityIcon", false);
VisibilityIcon = handle->GetBool("VisibilityIcon", true);
funcs["VisibilityIcon"] = &TreeParamsP::updateVisibilityIcon;
}
@@ -413,7 +413,7 @@ public:
}
// Auto generated code (Tools/params_utils.py:296)
static void updateVisibilityIcon(TreeParamsP *self) {
auto v = self->handle->GetBool("VisibilityIcon", false);
auto v = self->handle->GetBool("VisibilityIcon", true);
if (self->VisibilityIcon != v) {
self->VisibilityIcon = v;
TreeParams::onVisibilityIconChanged();
@@ -1480,7 +1480,7 @@ const bool & TreeParams::getVisibilityIcon() {
// Auto generated code (Tools/params_utils.py:366)
const bool & TreeParams::defaultVisibilityIcon() {
const static bool def = false;
const static bool def = true;
return def;
}

View File

@@ -83,7 +83,7 @@ Params = [
ParamInt('ColumnSize2', 0),
ParamInt('ColumnSize3', 0),
ParamBool('TreeToolTipIcon', False, title='Show icon in tool tip'),
ParamBool('VisibilityIcon', False, on_change=True, title='Show visibility icon',
ParamBool('VisibilityIcon', True, on_change=True, title='Show visibility icon',
doc = "If enabled, show an eye icon before the tree view items, showing the items visibility status. When clicked the visibility is toggled"),
]