mirror of
https://github.com/Palm1r/QodeAssist.git
synced 2025-07-18 21:14:34 -04:00
feat: Add settings for text format
This commit is contained in:
@ -122,6 +122,11 @@ ChatRootView::ChatRootView(QQuickItem *parent)
|
||||
&Utils::BaseAspect::changed,
|
||||
this,
|
||||
&ChatRootView::codeFontSizeChanged);
|
||||
connect(
|
||||
&Settings::chatAssistantSettings().textFormat,
|
||||
&Utils::BaseAspect::changed,
|
||||
this,
|
||||
&ChatRootView::textFormatChanged);
|
||||
|
||||
updateInputTokensCount();
|
||||
}
|
||||
@ -592,4 +597,9 @@ int ChatRootView::textFontSize() const
|
||||
return Settings::chatAssistantSettings().textFontSize();
|
||||
}
|
||||
|
||||
int ChatRootView::textFormat() const
|
||||
{
|
||||
return Settings::chatAssistantSettings().textFormat();
|
||||
}
|
||||
|
||||
} // namespace QodeAssist::Chat
|
||||
|
@ -42,6 +42,7 @@ class ChatRootView : public QQuickItem
|
||||
Q_PROPERTY(QString codeFontFamily READ codeFontFamily NOTIFY codeFamilyChanged FINAL)
|
||||
Q_PROPERTY(int codeFontSize READ codeFontSize NOTIFY codeFontSizeChanged FINAL)
|
||||
Q_PROPERTY(int textFontSize READ textFontSize NOTIFY textFontSizeChanged FINAL)
|
||||
Q_PROPERTY(int textFormat READ textFormat NOTIFY textFormatChanged FINAL)
|
||||
|
||||
QML_ELEMENT
|
||||
|
||||
@ -89,6 +90,7 @@ public:
|
||||
|
||||
int codeFontSize() const;
|
||||
int textFontSize() const;
|
||||
int textFormat() const;
|
||||
|
||||
public slots:
|
||||
void sendMessage(const QString &message);
|
||||
@ -109,6 +111,7 @@ signals:
|
||||
void codeFamilyChanged();
|
||||
void codeFontSizeChanged();
|
||||
void textFontSizeChanged();
|
||||
void textFormatChanged();
|
||||
|
||||
private:
|
||||
QString getChatsHistoryDir() const;
|
||||
|
@ -42,6 +42,7 @@ Rectangle {
|
||||
}
|
||||
property int textFontSize: Qt.application.font.pointSize
|
||||
property int codeFontSize: Qt.application.font.pointSize
|
||||
property int textFormat: 0
|
||||
|
||||
property bool isUserMessage: false
|
||||
property int messageIndex: -1
|
||||
@ -174,9 +175,19 @@ Rectangle {
|
||||
height: implicitHeight + 10
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
leftPadding: 10
|
||||
text: utils.getSafeMarkdownText(itemData.text)
|
||||
text: textFormat == Text.MarkdownText ? utils.getSafeMarkdownText(itemData.text)
|
||||
: itemData.text
|
||||
font.family: root.textFontFamily
|
||||
font.pointSize: root.textFontSize
|
||||
textFormat: {
|
||||
if (root.textFormat == 0) {
|
||||
return Text.MarkdownText
|
||||
} else if (root.textFormat == 1) {
|
||||
return Text.RichText
|
||||
} else {
|
||||
return Text.PlainText
|
||||
}
|
||||
}
|
||||
|
||||
ChatUtils {
|
||||
id: utils
|
||||
|
@ -104,6 +104,7 @@ ChatRootView {
|
||||
codeFontFamily: root.codeFontFamily
|
||||
codeFontSize: root.codeFontSize
|
||||
textFontSize: root.textFontSize
|
||||
textFormat: root.textFormat
|
||||
|
||||
onResetChatToMessage: function(index) {
|
||||
messageInput.text = model.content
|
||||
|
@ -25,7 +25,6 @@ TextEdit {
|
||||
readOnly: true
|
||||
selectByMouse: true
|
||||
wrapMode: Text.WordWrap
|
||||
textFormat: Text.MarkdownText
|
||||
selectionColor: palette.highlight
|
||||
color: palette.text
|
||||
}
|
||||
|
Reference in New Issue
Block a user