Commit 386a720f authored by dmMaze's avatar dmMaze
Browse files

fix textblock position drifting

parent e77ed406
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -610,7 +610,7 @@ class SceneTextManager(QObject):
        if len(selected_blks) > 0:
            for blkitem in selected_blks:
                old_html_lst.append(blkitem.toHtml())
                old_rect_lst.append(blkitem.absBoundingRect())
                old_rect_lst.append(blkitem.absBoundingRect(qrect=True))
                trans_widget_lst.append(self.pairwidget_list[blkitem.idx].e_trans)
                self.layout_textblk(blkitem)

+6 −2
Original line number Diff line number Diff line
@@ -90,7 +90,7 @@ class ApplyFontformatCommand(QUndoCommand):
        for item in items:
            self.old_html_lst.append(item.toHtml())
            self.old_fmt_lst.append(item.get_fontformat())
            self.old_rect_lst.append(item.absBoundingRect())
            self.old_rect_lst.append(item.absBoundingRect(qrect=True))

    def redo(self):
        for item, edit in zip(self.items, self.trans_widget_lst):
@@ -130,9 +130,13 @@ class ReshapeItemCommand(QUndoCommand):
        super(ReshapeItemCommand, self).__init__()
        self.item = item
        self.oldRect = item.oldRect
        self.newRect = item.absBoundingRect()
        self.newRect = item.absBoundingRect(qrect=True)
        self.idx = -1

    def redo(self):
        if self.idx < 0:
            self.idx += 1
            return
        self.item.setRect(self.newRect)

    def undo(self):
+3 −3
Original line number Diff line number Diff line
@@ -263,7 +263,7 @@ class TextBlkItem(QGraphicsTextItem):
        return QRectF(self.pos(), self.boundingRect().size())

    def startReshape(self):
        self.oldRect = self.absBoundingRect()
        self.oldRect = self.absBoundingRect(qrect=True)
        self.reshaping = True

    def endReshape(self):
@@ -312,7 +312,7 @@ class TextBlkItem(QGraphicsTextItem):
        _p = self.padding()
        if _p >= p:
            return
        abr = self.absBoundingRect()
        abr = self.absBoundingRect(qrect=True)
        self.layout.relayout_on_changed = False
        self.layout.updateDocumentMargin(p)
        self.layout.relayout_on_changed = True
@@ -335,7 +335,7 @@ class TextBlkItem(QGraphicsTextItem):
            w = min(max_w, x1) - x
        if qrect:
            return QRectF(x, y, w, h)
        return [math.ceil(x), math.ceil(y), math.ceil(w), math.ceil(h)]
        return [int(round(x)), int(round(y)), math.ceil(w), math.ceil(h)]

    def shape(self) -> QPainterPath:
        path = QPainterPath()