feat: Add chat font settings (#180)

This commit is contained in:
Petr Mironychev
2025-04-30 22:44:59 +02:00
committed by GitHub
parent 155153a763
commit 784529e344
8 changed files with 154 additions and 16 deletions

View File

@ -27,6 +27,22 @@ Rectangle {
property alias msgModel: msgCreator.model
property alias messageAttachments: attachmentsModel.model
property string textFontFamily: Qt.application.font.family
property string codeFontFamily: {
switch (Qt.platform.os) {
case "windows":
return "Consolas";
case "osx":
return "Menlo";
case "linux":
return "DejaVu Sans Mono";
default:
return "monospace";
}
}
property int textFontSize: Qt.application.font.pointSize
property int codeFontSize: Qt.application.font.pointSize
property bool isUserMessage: false
property int messageIndex: -1
property real listViewContentY: 0
@ -159,6 +175,8 @@ Rectangle {
verticalAlignment: Text.AlignVCenter
leftPadding: 10
text: utils.getSafeMarkdownText(itemData.text)
font.family: root.textFontFamily
font.pointSize: root.textFontSize
ChatUtils {
id: utils
@ -178,5 +196,7 @@ Rectangle {
code: itemData.text
language: itemData.language
codeFontFamily: root.codeFontFamily
codeFontSize: root.codeFontSize
}
}

View File

@ -100,6 +100,10 @@ ChatRootView {
isUserMessage: model.roleType === ChatModel.User
messageIndex: index
listViewContentY: chatListView.contentY
textFontFamily: root.textFontFamily
codeFontFamily: root.codeFontFamily
codeFontSize: root.codeFontSize
textFontSize: root.textFontSize
onResetChatToMessage: function(index) {
messageInput.text = model.content

View File

@ -30,6 +30,9 @@ Rectangle {
property real currentContentY: 0
property real blockStart: 0
property alias codeFontFamily: codeText.font.family
property alias codeFontSize: codeText.font.pointSize
readonly property real buttonTopMargin: 5
readonly property real blockEnd: blockStart + root.height
readonly property real maxButtonOffset: Math.max(0, root.height - copyButton.height - buttonTopMargin)
@ -45,19 +48,6 @@ Rectangle {
return buttonTopMargin;
}
readonly property string monospaceFont: {
switch (Qt.platform.os) {
case "windows":
return "Consolas";
case "osx":
return "Menlo";
case "linux":
return "DejaVu Sans Mono";
default:
return "monospace";
}
}
color: palette.alternateBase
border.color: root.color.hslLightness > 0.5 ? Qt.darker(root.color, 1.3)
: Qt.lighter(root.color, 1.3)
@ -77,8 +67,6 @@ Rectangle {
text: root.code
readOnly: true
selectByMouse: true
font.family: root.monospaceFont
font.pointSize: Qt.application.font.pointSize
color: parent.color.hslLightness > 0.5 ? "black" : "white"
wrapMode: Text.WordWrap
selectionColor: palette.highlight
@ -93,7 +81,7 @@ Rectangle {
text: root.language
color: root.color.hslLightness > 0.5 ? Qt.darker(root.color, 1.1)
: Qt.lighter(root.color, 1.1)
font.pointSize: 8
font.pointSize: codeText.font.pointSize - 4
}
QoAButton {