fix: merge two strokecanvas into one + better cursorShape and pointer handling

This commit is contained in:
2026-10-04 13:48:50 +02:00
parent dc99d6677c
commit 5507b99fdc
4 changed files with 110 additions and 87 deletions
@@ -1,6 +1,7 @@
#include "strokecanvasrenderer.hpp"
#include "strokecanvasitem.hpp"
#include <qcolor.h>
#include <QSet>
namespace ZShell::internal {
@@ -148,14 +149,27 @@ void StrokeCanvasRenderer::synchronizeData(QCanvasPainterItem* item) {
m_penColor = canvas->m_penColor;
m_penWidth = canvas->m_penWidth;
while (m_strokes.size() < canvas->m_strokes.size())
m_strokes.append(canvas->m_strokes[m_strokes.size()]);
// Detect removed strokes: present in renderer but no longer in canvas
QSet<int> canvasGroupIds;
for (const auto& stroke : canvas->m_strokes)
canvasGroupIds.insert(stroke.groupId);
if (canvas->m_strokes.isEmpty() && !m_strokes.isEmpty()) {
for (const auto& stroke : m_strokes)
if (stroke.groupId >= 0)
m_pendingGroupRemovals.append(stroke.groupId);
m_strokes.clear();
for (int i = m_strokes.size() - 1; i >= 0; --i) {
if (!canvasGroupIds.contains(m_strokes[i].groupId)) {
if (m_strokes[i].groupId >= 0)
m_pendingGroupRemovals.append(m_strokes[i].groupId);
m_strokes.remove(i);
}
}
// Detect added strokes: present in canvas but not yet in renderer
QSet<int> rendererGroupIds;
for (const auto& stroke : m_strokes)
rendererGroupIds.insert(stroke.groupId);
for (const auto& stroke : canvas->m_strokes) {
if (!rendererGroupIds.contains(stroke.groupId))
m_strokes.append(stroke);
}
m_currentStroke = canvas->m_currentStroke;