mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-08-13 18:14:13 +02:00
Remember last-used shape/text style for new items this session
Drawing tools on the diagram canvas always started new shapes and free text from a fixed hardcoded default (Qt's plain QPen()/QBrush(), and the static Preferences font) -- changing a shape's color or a text's font had zero effect on what the next new item of that type got, even within the same editing session. Add LastUsedStyle: a small in-memory, session-scoped static helper (no QSettings, no persistence across restarts -- this is a live "what did I just use" value, not a new app-wide default). Write side hooks capture the value right where the properties editors already apply a change (ShapeGraphicsItemPropertiesWidget::associatedUndo(), both the live-edit dock path and the modal editProperty() dialog path; and IndiTextPropertiesWidget::on_m_font_pb_clicked() right after the font dialog returns). Read side hooks apply the stored value, if any, to a newly created item: DiagramEventAddShape::mousePressEvent for shapes, IndependentTextItem's constructor for free text (falling back to the existing QETApp::indiTextsItemFont() Preferences default otherwise). Doesn't touch the element/symbol editor's own drawing tools (a separate subsystem) or add last-used text color (no color control exists in the text properties UI to originate it from yet).
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
#include "diagrameventaddshape.h"
|
||||
|
||||
#include "../diagram.h"
|
||||
#include "../lastusedstyle.h"
|
||||
#include "../undocommand/addgraphicsobjectcommand.h"
|
||||
|
||||
/**
|
||||
@@ -77,6 +78,14 @@ void DiagramEventAddShape::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||
if (!m_shape_item)
|
||||
{
|
||||
m_shape_item = new QetShapeItem(pos, pos, m_shape_type);
|
||||
//Start from whatever pen/brush was last applied this
|
||||
//session, rather than always the hardcoded default.
|
||||
if (LastUsedStyle::hasShapePen()) {
|
||||
m_shape_item->setPen(LastUsedStyle::shapePen());
|
||||
}
|
||||
if (LastUsedStyle::hasShapeBrush()) {
|
||||
m_shape_item->setBrush(LastUsedStyle::shapeBrush());
|
||||
}
|
||||
m_diagram->addItem (m_shape_item);
|
||||
event->setAccepted(true);
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user