mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-10-07 20:34:14 +02:00
Refresh the free text handles when the text comes back to a folio
itemChange() removed the corner handles when the text left the scene but did not bring them back when it returned still selected, which Qt allows (undoing a scripted delete does it) without a selection change. Refresh on every scene change. The two handle helpers are protected: nothing outside the class calls them. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
@@ -365,17 +365,19 @@ void DiagramTextItem::focusOutEvent(QFocusEvent *event)
|
||||
|
||||
/**
|
||||
@brief DiagramTextItem::itemChange
|
||||
Show or hide the resize handles with the selection.
|
||||
Show or hide the resize handles with the selection and the scene.
|
||||
@param change
|
||||
@param value
|
||||
@return
|
||||
*/
|
||||
QVariant DiagramTextItem::itemChange(GraphicsItemChange change, const QVariant &value)
|
||||
{
|
||||
if (change == QGraphicsItem::ItemSelectedHasChanged)
|
||||
//Also when the text comes back to a scene: Qt keeps it selected
|
||||
//across removeItem()/addItem() (undoing a delete) and sends no
|
||||
//selection change, and its handles were removed with the scene.
|
||||
if (change == QGraphicsItem::ItemSelectedHasChanged
|
||||
|| change == QGraphicsItem::ItemSceneHasChanged)
|
||||
refreshTextResizeHandles();
|
||||
else if (change == QGraphicsItem::ItemSceneHasChanged && !scene())
|
||||
removeTextResizeHandles();
|
||||
|
||||
return QGraphicsTextItem::itemChange(change, value);
|
||||
}
|
||||
|
||||
@@ -91,10 +91,10 @@ class DiagramTextItem : public QGraphicsTextItem
|
||||
void setPlainText(const QString &text);
|
||||
bool isHtml() const;
|
||||
|
||||
protected:
|
||||
void refreshTextResizeHandles();
|
||||
TextResizeHandles *textResizeHandles() const {return m_resize_handles;}
|
||||
|
||||
protected:
|
||||
void paint(QPainter *,
|
||||
const QStyleOptionGraphicsItem *,
|
||||
QWidget *) override;
|
||||
|
||||
Reference in New Issue
Block a user