From f733c87902927d967bd67397de843bac44d86c96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Althaus?= Date: Thu, 30 May 2024 15:06:08 +0200 Subject: [PATCH] Account for margin in visibility icon click check --- src/Gui/Tree.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Gui/Tree.cpp b/src/Gui/Tree.cpp index 1833a75523..3432e8ad63 100644 --- a/src/Gui/Tree.cpp +++ b/src/Gui/Tree.cpp @@ -1608,15 +1608,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());