Remember the F2 conductor color for the rest of the session (#879)

The F2 color editor recolors one conductor, but the next one drawn
falls straight back to defaultConductorProperties -- the choice made
via F2 is lost the moment you place another wire, and lost again on
restart. LastUsedStyle already solves the same problem for shapes
(pen/brush) and free text (font), session-scoped and deliberately not
QSettings-backed; this extends it with a conductor color, following
the identical has/get/set shape.

F2's handler records the color after pushing its undo command.
Conductor's constructor -- the one place a new conductor's properties
are set from defaultConductorProperties -- overrides just the color
field when a session color has been recorded, leaving every other
default (style, thickness, text) alone.

Verified: build clean, ctest 6/6. Could not get a reliable headless
GUI trace of "F2 one wire, draw a new one, see it inherit the color"
-- drag-and-drop element placement under Xvfb was unreliable in this
environment (one attempt did nothing, another drew an unintended long
conductor undo didn't fully clear). The code path is otherwise
identical to the already-shipped shape/text mechanism this mirrors.

Refs #461.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
ispyisail
2026-09-16 15:40:41 +12:00
parent 265aa44320
commit 1ec4f56a50
4 changed files with 60 additions and 10 deletions
+29
View File
@@ -23,6 +23,8 @@ QBrush LastUsedStyle::m_shape_brush;
bool LastUsedStyle::m_has_shape_brush = false;
QFont LastUsedStyle::m_text_font;
bool LastUsedStyle::m_has_text_font = false;
QColor LastUsedStyle::m_conductor_color;
bool LastUsedStyle::m_has_conductor_color = false;
/**
@return true if a shape pen was set this session
@@ -104,3 +106,30 @@ void LastUsedStyle::setTextFont(const QFont &font)
m_text_font = font;
m_has_text_font = true;
}
/**
@return true if a conductor color was set this session
*/
bool LastUsedStyle::hasConductorColor()
{
return m_has_conductor_color;
}
/**
@return the last color applied to a conductor this session
*/
QColor LastUsedStyle::conductorColor()
{
return m_conductor_color;
}
/**
@brief LastUsedStyle::setConductorColor
Record @a color as the last-used conductor color for this session
@param color
*/
void LastUsedStyle::setConductorColor(const QColor &color)
{
m_conductor_color = color;
m_has_conductor_color = true;
}