Skip to content

Commit

Permalink
Merge pull request #5 from Soft2012/users/Soft2012
Browse files Browse the repository at this point in the history
fix 2 errors
  • Loading branch information
Sorok-Dva authored Sep 9, 2024
2 parents 2c21ef0 + b07cab5 commit fa2748f
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/screenshotdisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,12 +163,12 @@ void ScreenshotDisplay::mouseMoveEvent(QMouseEvent* event) {
updateEditorPosition();
}
else if (drawing && editor->getCurrentTool() == Editor::Pen) {
QPixmap tempPixmap = drawingPixmap.copy();
QPixmap tempPixmap = originalPixmap.copy();
QPainter painter(&tempPixmap);
painter.setPen(QPen(editor->getCurrentColor(), borderWidth, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
painter.drawLine(lastPoint, event->pos());
lastPoint = event->pos();
drawingPixmap = tempPixmap;
originalPixmap = tempPixmap;
update();
}
else if (shapeDrawing) {
Expand Down Expand Up @@ -702,15 +702,20 @@ void ScreenshotDisplay::adjustTextEditSize() {
void ScreenshotDisplay::finalizeTextEdit() {
if (textEdit) {
saveStateForUndo();
QPainter painter(&drawingPixmap);
QPainter painter(&originalPixmap);
painter.setFont(textEdit->font());
painter.setPen(QPen(editor->getCurrentColor()));

QFontMetrics fm(textEdit->font());
QStringList lines = textEdit->toPlainText().split('\n');
QPoint currentPos = textEditPosition;

currentPos.setY(currentPos.y() + fm.ascent());
QMargins contentMargins = textEdit->contentsMargins();
int leftMargin = contentMargins.left();
int topMargin = contentMargins.top();

currentPos.setY(currentPos.y() + fm.height() + topMargin);
currentPos.setX(currentPos.x() + fm.descent() + leftMargin);

for (const QString& line : lines) {
painter.drawText(currentPos, line);
Expand Down

0 comments on commit fa2748f

Please sign in to comment.