From ff18467117aa54df7e7d29b78c057a10fb7080c8 Mon Sep 17 00:00:00 2001 From: Laurent Trinques Date: Sun, 18 Oct 2026 16:42:07 +0200 Subject: [PATCH] Terminal strip item: also redraw an item just added to a folio The redraw on change was connected in setTerminalStrip() only, used when an item is read from the project. An item added with the "Add terminal strip" dialog is built with TerminalStripItem(strip), which did not connect: it was not redrawn after the terminal strip editor was applied, until the project was reopened. Both constructors now go through connectStrip(). --- .../GraphicsItem/terminalstripitem.cpp | 39 ++++++++++++------- .../GraphicsItem/terminalstripitem.h | 1 + 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/sources/TerminalStrip/GraphicsItem/terminalstripitem.cpp b/sources/TerminalStrip/GraphicsItem/terminalstripitem.cpp index 1a758c145..c2713898c 100644 --- a/sources/TerminalStrip/GraphicsItem/terminalstripitem.cpp +++ b/sources/TerminalStrip/GraphicsItem/terminalstripitem.cpp @@ -39,6 +39,7 @@ TerminalStripItem::TerminalStripItem(QPointer strip, setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable); setAcceptHoverEvents(true); setDefaultLayout(); + connectStrip(strip); } TerminalStripItem::TerminalStripItem(QGraphicsItem *parent) : @@ -50,21 +51,8 @@ TerminalStripItem::TerminalStripItem(QGraphicsItem *parent) : void TerminalStripItem::setTerminalStrip(TerminalStrip *strip) { - for (const auto &connection_ : std::as_const(m_strip_connections)) { - disconnect(connection_); - } - m_strip_connections.clear(); - m_strip = strip; - if (strip) - { - //Redraw as soon as the strip or one of its terminals changes - //(terminal strip editor applied, undo, redo...) - m_strip_connections << connect(strip, &TerminalStrip::orderChanged, this, &TerminalStripItem::stripChanged) - << connect(strip, &TerminalStrip::bridgeChanged, this, &TerminalStripItem::stripChanged) - << connect(strip, &TerminalStrip::bridgeColorChanged, this, &TerminalStripItem::stripChanged) - << connect(strip, &TerminalStrip::dataChanged, this, &TerminalStripItem::stripChanged); - } + connectStrip(strip); m_drawer.setStrip(QSharedPointer { new TerminalStripDrawer::TrueTerminalStrip { strip }}); m_pending_strip_uuid = QUuid(); @@ -271,6 +259,29 @@ TerminalStripLayoutPattern::DrawStyle TerminalStripItem::drawStyle() const { return m_drawer.drawStyle(); } +/** + * @brief TerminalStripItem::connectStrip + * Redraw this item as soon as @a strip or one of its terminals changes + * (terminal strip editor applied, undo, redo...). + * The connections to the previous strip are removed. + * @param strip + */ +void TerminalStripItem::connectStrip(TerminalStrip *strip) +{ + for (const auto &connection_ : std::as_const(m_strip_connections)) { + disconnect(connection_); + } + m_strip_connections.clear(); + + if (strip) + { + m_strip_connections << connect(strip, &TerminalStrip::orderChanged, this, &TerminalStripItem::stripChanged) + << connect(strip, &TerminalStrip::bridgeChanged, this, &TerminalStripItem::stripChanged) + << connect(strip, &TerminalStrip::bridgeColorChanged, this, &TerminalStripItem::stripChanged) + << connect(strip, &TerminalStrip::dataChanged, this, &TerminalStripItem::stripChanged); + } +} + /** * @brief TerminalStripItem::stripChanged * The strip or one of its terminals changed : the size of the drawing diff --git a/sources/TerminalStrip/GraphicsItem/terminalstripitem.h b/sources/TerminalStrip/GraphicsItem/terminalstripitem.h index c77596aa3..eb762b888 100644 --- a/sources/TerminalStrip/GraphicsItem/terminalstripitem.h +++ b/sources/TerminalStrip/GraphicsItem/terminalstripitem.h @@ -76,6 +76,7 @@ class TerminalStripItem : public QetGraphicsItem private: void setDefaultLayout(); QString xrefToolTip(const TerminalStripDrawer::hoverTerminal &terminal) const; + void connectStrip(TerminalStrip *strip); void stripChanged(); private: