From f9cbf2365d9627897d3e8afeeaed28a154160f4a Mon Sep 17 00:00:00 2001 From: ispyisail Date: Tue, 11 Aug 2026 12:51:54 +1200 Subject: [PATCH] Fix bugtracker #247: XRef slave reference hidden with dark themes DynamicElementTextItem's slave cross-reference sub-item (m_slave_Xref_item, the small "_(1-D3)_"-style text next to a slave element pointing back to its master) hardcoded Qt::black in three places: on creation, on hover-leave, and when restoring color after text editing. The PARENT text item's color is a real, user-configurable property (color()/setColor(), persisted in the diagram XML, exposed in the text editor's color picker) -- but the slave-Xref sub-item never used it, so a user applying a dark theme/stylesheet had no way to make this specific text visible even by explicitly setting a text color, unlike every other text item in the diagram. Fix: use color() (the parent DynamicElementTextItem's own configured color, inherited from DiagramTextItem) instead of the Qt::black constant in all three places. This doesn't change the default appearance (color() defaults to black, same as before) but makes the slave-Xref text finally respect whatever color the user sets on the parent text field, giving dark-theme users the same escape hatch already available for all other diagram text. Verified: clean rebuild, only the intended object file recompiled and linked successfully. Not verified: a live visual confirmation of the slave-Xref text picking up a non-default color, since reproducing this requires constructing a master/slave-linked element pair with composite text containing %{label} in an actual multi-folio project, which was out of scope for the time available. Confidence rests on this being a direct, mechanical substitution of an existing, already-used accessor (color()) for a hardcoded constant, applied identically to the exact three call sites that previously hardcoded Qt::black for this item, with no other logic changed. --- sources/qetgraphicsitem/dynamicelementtextitem.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/sources/qetgraphicsitem/dynamicelementtextitem.cpp b/sources/qetgraphicsitem/dynamicelementtextitem.cpp index a9af725ae..9f197f3bb 100644 --- a/sources/qetgraphicsitem/dynamicelementtextitem.cpp +++ b/sources/qetgraphicsitem/dynamicelementtextitem.cpp @@ -553,7 +553,7 @@ void DynamicElementTextItem::mousePressEvent(QGraphicsSceneMouseEvent *event) setDefaultTextColor(m_user_color); m_user_color = QColor(); //m_user_color is now invalid if(m_slave_Xref_item) - m_slave_Xref_item->setDefaultTextColor(Qt::black); + m_slave_Xref_item->setDefaultTextColor(color()); } // Shift or no parent initiates movement of dynamic text, otherwise movement of parent element @@ -792,7 +792,7 @@ bool DynamicElementTextItem::sceneEventFilter(QGraphicsItem *watched, QEvent *ev return true; } else if(event->type() == QEvent::GraphicsSceneHoverLeave) { - m_slave_Xref_item->setDefaultTextColor(Qt::black); + m_slave_Xref_item->setDefaultTextColor(color()); return true; } else if(event->type() == QEvent::GraphicsSceneMouseDoubleClick) { @@ -1374,7 +1374,12 @@ void DynamicElementTextItem::updateXref() { m_slave_Xref_item = new QGraphicsTextItem(xref_label, this); m_slave_Xref_item->setFont(QETApp::diagramTextsFont(5)); - m_slave_Xref_item->setDefaultTextColor(Qt::black); + // Match the parent text's user-configurable color + // instead of hardcoding black, which renders + // invisible under dark themes/stylesheets that + // don't affect this sub-item the same way they do + // the parent (bugtracker #247). + m_slave_Xref_item->setDefaultTextColor(color()); m_slave_Xref_item->installSceneEventFilter(this); m_update_slave_Xref_connection << connect(master_elmt, &Element::xChanged, this, &DynamicElementTextItem::updateXref);