From: shangxiaoyang <shangxiaoyang@kylinos.cn>
Date: Mon, 27 May 2024 07:03:23 +0000
Subject: =?utf-8?q?!4_=E6=9B=B4=E6=96=B0changlog_Merge_pull_request_!4_from?=
 =?utf-8?q?_shangxiaoyang/openkylin/nile?=

---
 widgets/toolbars/kpAiDrawingBar.cpp | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/widgets/toolbars/kpAiDrawingBar.cpp b/widgets/toolbars/kpAiDrawingBar.cpp
index 91cf3be..0af3828 100644
--- a/widgets/toolbars/kpAiDrawingBar.cpp
+++ b/widgets/toolbars/kpAiDrawingBar.cpp
@@ -828,13 +828,16 @@ QPixmap kpAIDrawingBar::createPixmapWithText(const QString &text)
 
     // 设置字体和字体大小，这里假设使用默认字体，根据实际需求可自定义
     QFont font = painter.font();
+    font.setPointSize(12);
     // 若需要调整字体大小以适应换行，请在此处设置，例如：font.setPointSize(10);
 
+    QRect textRect = pixmap.rect().adjusted(8, 8, -8, -8);
     // 计算文本在给定宽度下的自动换行字符串
-    QString wrappedText = fontMetrics().elidedText(i18n(text.toLocal8Bit().data()), Qt::ElideNone, pixmap.rect().width(), Qt::TextWordWrap);
+    QString wrappedText = fontMetrics().elidedText(i18n(text.toLocal8Bit().data()), Qt::ElideNone, textRect.width(), Qt::TextWordWrap);
 
+    painter.setFont(font);
     painter.setPen(color);
-    painter.drawText(pixmap.rect(), Qt::AlignCenter | Qt::TextWordWrap, wrappedText);
+    painter.drawText(textRect, Qt::AlignCenter | Qt::TextWordWrap, wrappedText);
     painter.end();
 
     qDebug()<<"Error message:"<<i18n(text.toLocal8Bit().data())<<"size = "<<size;
@@ -1027,7 +1030,7 @@ QSize kpAIDrawingBar::getImageLabelSize()
 {
     imageColumn = 2;
     QSize labelSize = QSize(108,108);
-    qreal ratio = showAIImageSize.width() / 108;
+    double ratio = static_cast<double>(showAIImageSize.width()) / static_cast<double>(108);
     int height = showAIImageSize.height() / ratio;
 
     if (height != 0)
