[neon/extras/kxstitch/Neon/release] debian: fix rendering on certain occasions
Pino Toscano
null at kde.org
Thu Sep 8 16:49:47 BST 2022
Git commit 797bcd7f2cb9a017fd126f0a3449ec45f0d6907f by Pino Toscano.
Committed on 25/02/2021 at 06:27.
Pushed by jriddell into branch 'Neon/release'.
fix rendering on certain occasions
backport upstream commit c9e6a03c32fe6e6901fad8439bf2235ddb8c288c
M +3 -0 debian/changelog
M +1 -0 debian/patches/series
A +202 -0 debian/patches/upstream_Fix-for-rendering-on-scaled-painter.patch
https://invent.kde.org/neon/extras/kxstitch/commit/797bcd7f2cb9a017fd126f0a3449ec45f0d6907f
diff --git a/debian/changelog b/debian/changelog
index 49796eb..c5848e2 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -5,6 +5,9 @@ kxstitch (2.2.0-3) UNRELEASED; urgency=medium
11f715597e64e6901428de81f7fa1944026c8eca to fix the AppStream metadata;
patches upstream_Improve-appdata.patch, and
upstream_Update-kxstitch-appdata-to-pass-flathub-validation.patch.
+ * Backport upstream commit c9e6a03c32fe6e6901fad8439bf2235ddb8c288c to fix
+ the rendering on certain occasions; patch
+ upstream_Fix-for-rendering-on-scaled-painter.patch.
-- Debian Qt/KDE Maintainers <debian-qt-kde at lists.debian.org> Thu, 25 Feb 2021 07:23:00 +0100
diff --git a/debian/patches/series b/debian/patches/series
index 5d3689b..c6a78b2 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1,2 +1,3 @@
upstream_Improve-appdata.patch
upstream_Update-kxstitch-appdata-to-pass-flathub-validation.patch
+upstream_Fix-for-rendering-on-scaled-painter.patch
diff --git a/debian/patches/upstream_Fix-for-rendering-on-scaled-painter.patch b/debian/patches/upstream_Fix-for-rendering-on-scaled-painter.patch
new file mode 100644
index 0000000..47ec687
--- /dev/null
+++ b/debian/patches/upstream_Fix-for-rendering-on-scaled-painter.patch
@@ -0,0 +1,202 @@
+From c9e6a03c32fe6e6901fad8439bf2235ddb8c288c Mon Sep 17 00:00:00 2001
+From: Steve Allewell <steve.allewell at gmail.com>
+Date: Sun, 3 Jan 2021 13:43:59 +0000
+Subject: [PATCH] Fix for rendering on scaled painter
+
+Fixes for rendering seletion areas on scaled painter in recent versions
+of Qt which were half a square out.
+---
+ src/Editor.cpp | 74 ++++++++++++++++++++++++++++----------------------
+ 1 file changed, 41 insertions(+), 33 deletions(-)
+
+diff --git a/src/Editor.cpp b/src/Editor.cpp
+index 4d314e4..263df1e 100644
+--- a/src/Editor.cpp
++++ b/src/Editor.cpp
+@@ -1388,11 +1388,12 @@ void Editor::renderRubberBandRectangle(QPainter *painter, const QRect&)
+ if (m_rubberBand.isValid()) {
+ painter->setRenderHint(QPainter::Qt4CompatiblePainting, true);
+
++ painter->resetTransform();
+ QStyleOptionRubberBand opt;
+ opt.initFrom(this);
+ opt.shape = QRubberBand::Rectangle;
+ opt.opaque = false;
+- opt.rect = m_rubberBand.adjusted(0, 0, 1, 1);
++ opt.rect = rectToContents(m_rubberBand);
+
+ style()->drawControl(QStyle::CE_RubberBand, &opt, painter);
+ }
+@@ -1408,14 +1409,15 @@ void Editor::renderRubberBandEllipse(QPainter *painter, const QRect&)
+ if (m_rubberBand.isValid()) {
+ painter->setRenderHint(QPainter::Qt4CompatiblePainting, true);
+
+- painter->setPen(Qt::NoPen);
+- painter->setBrush(QColor(200,225,255));
+- painter->setOpacity(0.5);
+- painter->drawEllipse(m_rubberBand);
++ painter->resetTransform();
++ QStyleOptionRubberBand opt;
++ opt.initFrom(this);
+
+- painter->setPen(Qt::darkBlue);
+- painter->setBrush(Qt::NoBrush);
+- painter->drawEllipse(m_rubberBand);
++ painter->setPen(opt.palette.color(QPalette::WindowText));
++ painter->setBrush(QBrush(opt.palette.color(QPalette::Highlight), Qt::Dense4Pattern));
++ painter->setBackground(QBrush(opt.palette.base()));
++ painter->setBackgroundMode(Qt::TransparentMode);
++ painter->drawEllipse(rectToContents(m_rubberBand));
+ }
+
+ painter->restore();
+@@ -1427,7 +1429,10 @@ void Editor::renderFillPolygon(QPainter *painter, const QRect&)
+ QPolygonF polyline;
+ painter->save();
+
+- painter->setPen(Qt::green); // use green for the first point
++ QPen pen(Qt::green);
++ pen.setWidth(0);
++
++ painter->setPen(pen); // use green for the first point
+ painter->setBrush(Qt::green);
+
+ QVector<QPoint>::const_iterator i;
+@@ -1435,7 +1440,8 @@ void Editor::renderFillPolygon(QPainter *painter, const QRect&)
+ for (i = m_polygon.constBegin() ; i != m_polygon.constEnd() ; ++i) {
+ QPointF cell = QPointF(*i) + QPointF(0.5, 0.5);
+ painter->drawEllipse(QRectF(-0.5, -0.5, 1, 1).translated(cell));
+- painter->setPen(Qt::blue); // use blue for subsequent points
++ pen.setColor(Qt::blue);
++ painter->setPen(pen); // use blue for subsequent points
+ painter->setBrush(Qt::blue);
+ polyline.append(cell);
+ }
+@@ -1555,9 +1561,9 @@ void Editor::mouseMoveEvent_Draw(QMouseEvent *e)
+
+ dynamic_cast<QScrollArea *>(parentWidget()->parentWidget())->ensureVisible(p.x(), p.y());
+
+- m_cellTracking = contentsToCell(p);
+- m_cellEnd = m_cellTracking;
+- m_rubberBand = QRect(m_cellStart, m_cellEnd).normalized();
++ m_cellEnd = m_cellTracking = contentsToCell(p);
++ m_rubberBand = QRect(m_cellStart, QSize(1, 1)).united(QRect(m_cellEnd, QSize(1, 1)));
++
+ update();
+ }
+
+@@ -1703,9 +1709,9 @@ void Editor::mouseMoveEvent_Rectangle(QMouseEvent *e)
+
+ dynamic_cast<QScrollArea *>(parentWidget()->parentWidget())->ensureVisible(p.x(), p.y());
+
+- m_cellTracking = contentsToCell(p);
+- m_cellEnd = m_cellTracking;
+- m_rubberBand = QRect(m_cellStart, m_cellEnd).normalized();
++ m_cellEnd = m_cellTracking = contentsToCell(p);
++ m_rubberBand = QRect(m_cellStart, QSize(1, 1)).united(QRect(m_cellEnd, QSize(1, 1)));
++
+ update();
+ }
+
+@@ -1757,9 +1763,9 @@ void Editor::mouseMoveEvent_FillRectangle(QMouseEvent *e)
+
+ dynamic_cast<QScrollArea *>(parentWidget()->parentWidget())->ensureVisible(p.x(), p.y());
+
+- m_cellTracking = contentsToCell(p);
+- m_cellEnd = m_cellTracking;
+- m_rubberBand = QRect(m_cellStart, m_cellEnd).normalized();
++ m_cellEnd = m_cellTracking = contentsToCell(p);
++ m_rubberBand = QRect(m_cellStart, QSize(1, 1)).united(QRect(m_cellEnd, QSize(1, 1)));
++
+ update();
+ }
+
+@@ -1793,9 +1799,9 @@ void Editor::mouseMoveEvent_Ellipse(QMouseEvent *e)
+
+ dynamic_cast<QScrollArea *>(parentWidget()->parentWidget())->ensureVisible(p.x(), p.y());
+
+- m_cellTracking = contentsToCell(p);
+- m_cellEnd = m_cellTracking;
+- m_rubberBand = QRect(m_cellStart, m_cellEnd).normalized();
++ m_cellEnd = m_cellTracking = contentsToCell(p);
++ m_rubberBand = QRect(m_cellStart, QSize(1, 1)).united(QRect(m_cellEnd, QSize(1, 1)));
++
+ update();
+ }
+
+@@ -1848,9 +1854,9 @@ void Editor::mouseMoveEvent_FillEllipse(QMouseEvent *e)
+
+ dynamic_cast<QScrollArea *>(parentWidget()->parentWidget())->ensureVisible(p.x(), p.y());
+
+- m_cellTracking = contentsToCell(p);
+- m_cellEnd = m_cellTracking;
+- m_rubberBand = QRect(m_cellStart, m_cellEnd).normalized();
++ m_cellEnd = m_cellTracking = contentsToCell(p);
++ m_rubberBand = QRect(m_cellStart, QSize(1, 1)).united(QRect(m_cellEnd, QSize(1, 1)));
++
+ update();
+ }
+
+@@ -1877,7 +1883,7 @@ void Editor::mouseReleaseEvent_FillEllipse(QMouseEvent*)
+ painter.setRenderHint(QPainter::Antialiasing, !useFractionals);
+ painter.setPen(QPen(Qt::color1));
+ painter.setBrush(Qt::color1);
+- painter.drawEllipse(QRect(m_cellStart, m_cellEnd).normalized());
++ painter.drawEllipse(QRect(m_cellStart, QSize(1,1)).united(QRect(m_cellEnd, QSize(1, 1))));
+ painter.end();
+
+ QUndoCommand *cmd = new FillEllipseCommand(m_document);
+@@ -1894,6 +1900,7 @@ void Editor::mousePressEvent_FillPolygon(QMouseEvent *e)
+ {
+ m_cellStart = m_cellTracking = m_cellEnd = contentsToCell(e->pos());
+ m_polygon.append(m_cellStart);
++
+ update();
+ }
+
+@@ -2001,6 +2008,7 @@ void Editor::mouseReleaseEvent_Alphabet(QMouseEvent *e)
+
+ m_cellStart = m_cellTracking = m_cellEnd = contentsToCell(e->pos());
+ m_cursorStack.push(m_cellEnd);
++
+ update();
+ }
+
+@@ -2023,9 +2031,9 @@ void Editor::mouseMoveEvent_Select(QMouseEvent *e)
+
+ dynamic_cast<QScrollArea *>(parentWidget()->parentWidget())->ensureVisible(p.x(), p.y());
+
+- m_cellTracking = contentsToCell(p);
+- m_cellEnd = m_cellTracking;
+- m_rubberBand = QRect(m_cellStart, m_cellEnd).normalized();
++ m_cellEnd = m_cellTracking = contentsToCell(p);
++ m_rubberBand = QRect(m_cellStart, QSize(1, 1)).united(QRect(m_cellEnd, QSize(1, 1)));
++
+ update();
+
+ QToolTip::showText(QCursor::pos(), QString::fromLatin1("%1,%2 %3 x %4").arg(m_rubberBand.left()).arg(m_rubberBand.top()).arg(m_rubberBand.width()).arg(m_rubberBand.height()));
+@@ -2034,7 +2042,7 @@ void Editor::mouseMoveEvent_Select(QMouseEvent *e)
+
+ void Editor::mouseReleaseEvent_Select(QMouseEvent*)
+ {
+- m_selectionArea = QRect(m_cellStart, m_cellEnd).normalized();
++ m_selectionArea = m_rubberBand;
+ emit(selectionMade(true));
+ }
+
+@@ -2052,9 +2060,9 @@ void Editor::mouseMoveEvent_Backstitch(QMouseEvent *e)
+
+ dynamic_cast<QScrollArea *>(parentWidget()->parentWidget())->ensureVisible(p.x(), p.y());
+
+- m_cellTracking = contentsToSnap(p);
+- m_cellEnd = m_cellTracking;
+- m_rubberBand = (snapToCells(m_cellStart).united(snapToCells(m_cellEnd))).normalized();
++ m_cellEnd = m_cellTracking = contentsToSnap(p);
++ m_rubberBand = snapToCells(m_cellStart).united(snapToCells(m_cellEnd));
++
+ update();
+ }
+
+--
+2.30.0
+
More information about the Neon-commits
mailing list