mirror of
https://github.com/Palm1r/QodeAssist.git
synced 2025-05-28 03:10:28 -04:00
feat: Add settings for text format
This commit is contained in:
parent
784529e344
commit
4e05abc7d2
@ -122,6 +122,11 @@ ChatRootView::ChatRootView(QQuickItem *parent)
|
|||||||
&Utils::BaseAspect::changed,
|
&Utils::BaseAspect::changed,
|
||||||
this,
|
this,
|
||||||
&ChatRootView::codeFontSizeChanged);
|
&ChatRootView::codeFontSizeChanged);
|
||||||
|
connect(
|
||||||
|
&Settings::chatAssistantSettings().textFormat,
|
||||||
|
&Utils::BaseAspect::changed,
|
||||||
|
this,
|
||||||
|
&ChatRootView::textFormatChanged);
|
||||||
|
|
||||||
updateInputTokensCount();
|
updateInputTokensCount();
|
||||||
}
|
}
|
||||||
@ -592,4 +597,9 @@ int ChatRootView::textFontSize() const
|
|||||||
return Settings::chatAssistantSettings().textFontSize();
|
return Settings::chatAssistantSettings().textFontSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ChatRootView::textFormat() const
|
||||||
|
{
|
||||||
|
return Settings::chatAssistantSettings().textFormat();
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace QodeAssist::Chat
|
} // namespace QodeAssist::Chat
|
||||||
|
@ -42,6 +42,7 @@ class ChatRootView : public QQuickItem
|
|||||||
Q_PROPERTY(QString codeFontFamily READ codeFontFamily NOTIFY codeFamilyChanged FINAL)
|
Q_PROPERTY(QString codeFontFamily READ codeFontFamily NOTIFY codeFamilyChanged FINAL)
|
||||||
Q_PROPERTY(int codeFontSize READ codeFontSize NOTIFY codeFontSizeChanged FINAL)
|
Q_PROPERTY(int codeFontSize READ codeFontSize NOTIFY codeFontSizeChanged FINAL)
|
||||||
Q_PROPERTY(int textFontSize READ textFontSize NOTIFY textFontSizeChanged FINAL)
|
Q_PROPERTY(int textFontSize READ textFontSize NOTIFY textFontSizeChanged FINAL)
|
||||||
|
Q_PROPERTY(int textFormat READ textFormat NOTIFY textFormatChanged FINAL)
|
||||||
|
|
||||||
QML_ELEMENT
|
QML_ELEMENT
|
||||||
|
|
||||||
@ -89,6 +90,7 @@ public:
|
|||||||
|
|
||||||
int codeFontSize() const;
|
int codeFontSize() const;
|
||||||
int textFontSize() const;
|
int textFontSize() const;
|
||||||
|
int textFormat() const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void sendMessage(const QString &message);
|
void sendMessage(const QString &message);
|
||||||
@ -109,6 +111,7 @@ signals:
|
|||||||
void codeFamilyChanged();
|
void codeFamilyChanged();
|
||||||
void codeFontSizeChanged();
|
void codeFontSizeChanged();
|
||||||
void textFontSizeChanged();
|
void textFontSizeChanged();
|
||||||
|
void textFormatChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString getChatsHistoryDir() const;
|
QString getChatsHistoryDir() const;
|
||||||
|
@ -42,6 +42,7 @@ Rectangle {
|
|||||||
}
|
}
|
||||||
property int textFontSize: Qt.application.font.pointSize
|
property int textFontSize: Qt.application.font.pointSize
|
||||||
property int codeFontSize: Qt.application.font.pointSize
|
property int codeFontSize: Qt.application.font.pointSize
|
||||||
|
property int textFormat: 0
|
||||||
|
|
||||||
property bool isUserMessage: false
|
property bool isUserMessage: false
|
||||||
property int messageIndex: -1
|
property int messageIndex: -1
|
||||||
@ -174,9 +175,19 @@ Rectangle {
|
|||||||
height: implicitHeight + 10
|
height: implicitHeight + 10
|
||||||
verticalAlignment: Text.AlignVCenter
|
verticalAlignment: Text.AlignVCenter
|
||||||
leftPadding: 10
|
leftPadding: 10
|
||||||
text: utils.getSafeMarkdownText(itemData.text)
|
text: textFormat == Text.MarkdownText ? utils.getSafeMarkdownText(itemData.text)
|
||||||
|
: itemData.text
|
||||||
font.family: root.textFontFamily
|
font.family: root.textFontFamily
|
||||||
font.pointSize: root.textFontSize
|
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 {
|
ChatUtils {
|
||||||
id: utils
|
id: utils
|
||||||
|
@ -104,6 +104,7 @@ ChatRootView {
|
|||||||
codeFontFamily: root.codeFontFamily
|
codeFontFamily: root.codeFontFamily
|
||||||
codeFontSize: root.codeFontSize
|
codeFontSize: root.codeFontSize
|
||||||
textFontSize: root.textFontSize
|
textFontSize: root.textFontSize
|
||||||
|
textFormat: root.textFormat
|
||||||
|
|
||||||
onResetChatToMessage: function(index) {
|
onResetChatToMessage: function(index) {
|
||||||
messageInput.text = model.content
|
messageInput.text = model.content
|
||||||
|
@ -25,7 +25,6 @@ TextEdit {
|
|||||||
readOnly: true
|
readOnly: true
|
||||||
selectByMouse: true
|
selectByMouse: true
|
||||||
wrapMode: Text.WordWrap
|
wrapMode: Text.WordWrap
|
||||||
textFormat: Text.MarkdownText
|
|
||||||
selectionColor: palette.highlight
|
selectionColor: palette.highlight
|
||||||
color: palette.text
|
color: palette.text
|
||||||
}
|
}
|
||||||
|
@ -190,6 +190,14 @@ ChatAssistantSettings::ChatAssistantSettings()
|
|||||||
codeFontSize.setLabelText(Tr::tr("Code Font Size:"));
|
codeFontSize.setLabelText(Tr::tr("Code Font Size:"));
|
||||||
codeFontSize.setDefaultValue(QApplication::font().pointSize());
|
codeFontSize.setDefaultValue(QApplication::font().pointSize());
|
||||||
|
|
||||||
|
textFormat.setSettingsKey(Constants::CA_TEXT_FORMAT);
|
||||||
|
textFormat.setLabelText(Tr::tr("Text Format:"));
|
||||||
|
textFormat.setDefaultValue(0);
|
||||||
|
textFormat.setDisplayStyle(Utils::SelectionAspect::DisplayStyle::ComboBox);
|
||||||
|
textFormat.addOption("Markdown");
|
||||||
|
textFormat.addOption("HTML");
|
||||||
|
textFormat.addOption("Plain Text");
|
||||||
|
|
||||||
resetToDefaults.m_buttonText = TrConstants::RESET_TO_DEFAULTS;
|
resetToDefaults.m_buttonText = TrConstants::RESET_TO_DEFAULTS;
|
||||||
|
|
||||||
readSettings();
|
readSettings();
|
||||||
@ -216,6 +224,7 @@ ChatAssistantSettings::ChatAssistantSettings()
|
|||||||
auto chatViewSettingsGrid = Grid{};
|
auto chatViewSettingsGrid = Grid{};
|
||||||
chatViewSettingsGrid.addRow({textFontFamily, textFontSize});
|
chatViewSettingsGrid.addRow({textFontFamily, textFontSize});
|
||||||
chatViewSettingsGrid.addRow({codeFontFamily, codeFontSize});
|
chatViewSettingsGrid.addRow({codeFontFamily, codeFontSize});
|
||||||
|
chatViewSettingsGrid.addRow({textFormat});
|
||||||
|
|
||||||
return Column{
|
return Column{
|
||||||
Row{Stretch{1}, resetToDefaults},
|
Row{Stretch{1}, resetToDefaults},
|
||||||
@ -283,6 +292,7 @@ void ChatAssistantSettings::resetSettingsToDefaults()
|
|||||||
resetAspect(codeFontFamily);
|
resetAspect(codeFontFamily);
|
||||||
resetAspect(textFontSize);
|
resetAspect(textFontSize);
|
||||||
resetAspect(codeFontSize);
|
resetAspect(codeFontSize);
|
||||||
|
resetAspect(textFormat);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,6 +68,7 @@ public:
|
|||||||
Utils::IntegerAspect textFontSize{this};
|
Utils::IntegerAspect textFontSize{this};
|
||||||
Utils::SelectionAspect codeFontFamily{this};
|
Utils::SelectionAspect codeFontFamily{this};
|
||||||
Utils::IntegerAspect codeFontSize{this};
|
Utils::IntegerAspect codeFontSize{this};
|
||||||
|
Utils::SelectionAspect textFormat{this};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setupConnections();
|
void setupConnections();
|
||||||
|
@ -155,5 +155,6 @@ const char CA_TEXT_FONT_FAMILY[] = "QodeAssist.caTextFontFamily";
|
|||||||
const char CA_TEXT_FONT_SIZE[] = "QodeAssist.caTextFontSize";
|
const char CA_TEXT_FONT_SIZE[] = "QodeAssist.caTextFontSize";
|
||||||
const char CA_CODE_FONT_FAMILY[] = "QodeAssist.caCodeFontFamily";
|
const char CA_CODE_FONT_FAMILY[] = "QodeAssist.caCodeFontFamily";
|
||||||
const char CA_CODE_FONT_SIZE[] = "QodeAssist.caCodeFontSize";
|
const char CA_CODE_FONT_SIZE[] = "QodeAssist.caCodeFontSize";
|
||||||
|
const char CA_TEXT_FORMAT[] = "QodeAssist.caTextFormat";
|
||||||
|
|
||||||
} // namespace QodeAssist::Constants
|
} // namespace QodeAssist::Constants
|
||||||
|
Loading…
Reference in New Issue
Block a user