From 67e3d1517d8ee4505ccf1be7a27847159df6a1eb Mon Sep 17 00:00:00 2001 From: Damir Porobic Date: Wed, 23 Dec 2020 20:24:56 +0100 Subject: [PATCH] Improve cursor visibility in text tool #184 --- CHANGELOG.md | 1 + src/annotations/items/text/AnnotationTextHandler.cpp | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a419b97e..0d56286d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ ## Release 0.4.1 * Fixed: Brazilian Portuguese translation not loaded. ([#176](https://github.com/ksnip/kImageAnnotator/issues/176)) * Fixed: error: control reaches end of non-void function. ([#177](https://github.com/ksnip/kImageAnnotator/issues/177)) +* Fixed: Cursor in Text tool have too bad visibility. ([#184](https://github.com/ksnip/kImageAnnotator/issues/184)) ## Release 0.4.0 * New: Add Pixelate image area tool. ([#140](https://github.com/ksnip/kImageAnnotator/issues/140)) diff --git a/src/annotations/items/text/AnnotationTextHandler.cpp b/src/annotations/items/text/AnnotationTextHandler.cpp index 60df4648..7673bdf5 100644 --- a/src/annotations/items/text/AnnotationTextHandler.cpp +++ b/src/annotations/items/text/AnnotationTextHandler.cpp @@ -103,7 +103,7 @@ void AnnotationTextHandler::paintText(QPainter *painter, QRectF *rect, const QFo // Workaround for issue #70 -> Cursor not drawn with with Qt 5.9 if (mIsInEditMode) { - painter->setBrush(QColor(255,255,255,10)); + painter->setBrush(QColor(255,255,255,50)); painter->drawRect(*rect); } @@ -142,7 +142,7 @@ void AnnotationTextHandler::paintText(QPainter *painter, QRectF *rect, const QFo textLayout.draw(painter, QPoint(0, boxHeight)); if (mTextCursor.isVisible() && isCursorInBlock(blockPosition, blockLength)) { - textLayout.drawCursor(painter, QPointF(1, boxHeight), mTextCursor.position() - blockPosition, 2); + textLayout.drawCursor(painter, QPointF(0, boxHeight), mTextCursor.position() - blockPosition, 1); } boxHeight += blockHeight; } @@ -177,7 +177,7 @@ QRect AnnotationTextHandler::getTextRect(QRectF *rect, const QFont& font, int ma { QFontMetrics fontMetrics(font); auto newRect = fontMetrics.boundingRect(rect->toRect().normalized(), Qt::AlignLeft, mText); - newRect.adjust(0, 0, margin * 2, margin * 2); + newRect.adjust(0, 2, (margin * 2) + 2, margin * 2); return newRect; }