mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-09-27 12:34:14 +02:00
1ec4f56a50
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>
136 lines
2.9 KiB
C++
136 lines
2.9 KiB
C++
/*
|
|
Copyright 2006-2026 The QElectroTech Team
|
|
This file is part of QElectroTech.
|
|
|
|
QElectroTech is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation, either version 2 of the License, or
|
|
(at your option) any later version.
|
|
|
|
QElectroTech is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
#include "lastusedstyle.h"
|
|
|
|
QPen LastUsedStyle::m_shape_pen;
|
|
bool LastUsedStyle::m_has_shape_pen = false;
|
|
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
|
|
*/
|
|
bool LastUsedStyle::hasShapePen()
|
|
{
|
|
return m_has_shape_pen;
|
|
}
|
|
|
|
/**
|
|
@return the last pen applied to a shape this session
|
|
*/
|
|
QPen LastUsedStyle::shapePen()
|
|
{
|
|
return m_shape_pen;
|
|
}
|
|
|
|
/**
|
|
@brief LastUsedStyle::setShapePen
|
|
Record @a pen as the last-used shape pen for this session
|
|
@param pen
|
|
*/
|
|
void LastUsedStyle::setShapePen(const QPen &pen)
|
|
{
|
|
m_shape_pen = pen;
|
|
m_has_shape_pen = true;
|
|
}
|
|
|
|
/**
|
|
@return true if a shape brush was set this session
|
|
*/
|
|
bool LastUsedStyle::hasShapeBrush()
|
|
{
|
|
return m_has_shape_brush;
|
|
}
|
|
|
|
/**
|
|
@return the last brush applied to a shape this session
|
|
*/
|
|
QBrush LastUsedStyle::shapeBrush()
|
|
{
|
|
return m_shape_brush;
|
|
}
|
|
|
|
/**
|
|
@brief LastUsedStyle::setShapeBrush
|
|
Record @a brush as the last-used shape brush for this session
|
|
@param brush
|
|
*/
|
|
void LastUsedStyle::setShapeBrush(const QBrush &brush)
|
|
{
|
|
m_shape_brush = brush;
|
|
m_has_shape_brush = true;
|
|
}
|
|
|
|
/**
|
|
@return true if a text font was set this session
|
|
*/
|
|
bool LastUsedStyle::hasTextFont()
|
|
{
|
|
return m_has_text_font;
|
|
}
|
|
|
|
/**
|
|
@return the last font applied to a free text item this session
|
|
*/
|
|
QFont LastUsedStyle::textFont()
|
|
{
|
|
return m_text_font;
|
|
}
|
|
|
|
/**
|
|
@brief LastUsedStyle::setTextFont
|
|
Record @a font as the last-used free text font for this session
|
|
@param font
|
|
*/
|
|
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;
|
|
}
|