diff --git a/QodeAssist.json.in b/QodeAssist.json.in index 26de130..b8e36d8 100644 --- a/QodeAssist.json.in +++ b/QodeAssist.json.in @@ -1,6 +1,6 @@ { "Name" : "QodeAssist", - "Version" : "0.3.0", + "Version" : "0.3.1", "CompatVersion" : "${IDE_VERSION_COMPAT}", "Vendor" : "Petr Mironychev", "Copyright" : "(C) ${IDE_COPYRIGHT_YEAR} Petr Mironychev, (C) ${IDE_COPYRIGHT_YEAR} The Qt Company Ltd", diff --git a/chatview/ChatUtils.cpp b/chatview/ChatUtils.cpp index 2b41f56..97079bc 100644 --- a/chatview/ChatUtils.cpp +++ b/chatview/ChatUtils.cpp @@ -7,7 +7,6 @@ namespace QodeAssist::Chat { void ChatUtils::copyToClipboard(const QString &text) { - qDebug() << "call clipboard" << text; QGuiApplication::clipboard()->setText(text); } diff --git a/chatview/qml/RootItem.qml b/chatview/qml/RootItem.qml index 4a41fae..29556a7 100644 --- a/chatview/qml/RootItem.qml +++ b/chatview/qml/RootItem.qml @@ -81,17 +81,16 @@ ChatRootView { } } - RowLayout { - Layout.fillWidth: true - spacing: 5 + ScrollView { + id: view - QQC.TextField { + Layout.fillWidth: true + Layout.minimumHeight: 30 + Layout.maximumHeight: root.height / 2 + + QQC.TextArea { id: messageInput - Layout.fillWidth: true - Layout.minimumWidth: 60 - Layout.minimumHeight: 30 - rightInset: -(parent.width - sendButton.width - clearButton.width) placeholderText: qsTr("Type your message here...") placeholderTextColor: "#888" color: root.primaryColor.hslLightness > 0.5 ? "black" : "white" @@ -102,30 +101,31 @@ ChatRootView { : Qt.darker(root.primaryColor, 1.5) border.width: 1 } - - onAccepted: sendButton.clicked() + Keys.onPressed: function(event) { + if ((event.key === Qt.Key_Return || event.key === Qt.Key_Enter) && !(event.modifiers & Qt.ShiftModifier)) { + sendChatMessage() + event.accepted = true; + } + } } + } + + RowLayout { + Layout.fillWidth: true + spacing: 5 Button { id: sendButton - Layout.alignment: Qt.AlignVCenter - Layout.minimumHeight: 30 + Layout.alignment: Qt.AlignBottom text: qsTr("Send") - onClicked: { - if (messageInput.text.trim() !== "") { - root.sendMessage(messageInput.text); - messageInput.text = "" - scrollToBottom() - } - } + onClicked: sendChatMessage() } Button { id: clearButton - Layout.alignment: Qt.AlignVCenter - Layout.minimumHeight: 30 - text: qsTr("Clear") + Layout.alignment: Qt.AlignBottom + text: qsTr("Clear Chat") onClicked: clearChat() } } @@ -158,4 +158,10 @@ ChatRootView { function scrollToBottom() { Qt.callLater(chatListView.positionViewAtEnd) } + + function sendChatMessage() { + root.sendMessage(messageInput.text); + messageInput.text = "" + scrollToBottom() + } } diff --git a/chatview/qml/dialog/CodeBlock.qml b/chatview/qml/dialog/CodeBlock.qml index 581815c..4445bfd 100644 --- a/chatview/qml/dialog/CodeBlock.qml +++ b/chatview/qml/dialog/CodeBlock.qml @@ -28,6 +28,19 @@ Rectangle { property string language: "" property color selectionColor + 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"; + } + } + border.color: root.color.hslLightness > 0.5 ? Qt.darker(root.color, 1.3) : Qt.lighter(root.color, 1.3) border.width: 2 @@ -48,7 +61,8 @@ Rectangle { text: root.code readOnly: true selectByMouse: true - font.family: "monospace" + font.family: monospaceFont + font.pointSize: 12 color: parent.color.hslLightness > 0.5 ? "black" : "white" wrapMode: Text.WordWrap selectionColor: root.selectionColor diff --git a/qodeassist.cpp b/qodeassist.cpp index 77e37f6..2ab2f4b 100644 --- a/qodeassist.cpp +++ b/qodeassist.cpp @@ -94,6 +94,7 @@ public: templateManager.registerTemplate(); templateManager.registerTemplate(); templateManager.registerTemplate(); + templateManager.registerTemplate(); Utils::Icon QCODEASSIST_ICON( {{":/resources/images/qoderassist-icon.png", Utils::Theme::IconsBaseColor}}); diff --git a/templates/CodeLlamaChat.hpp b/templates/CodeLlamaChat.hpp index 2342e3c..c7c9dac 100644 --- a/templates/CodeLlamaChat.hpp +++ b/templates/CodeLlamaChat.hpp @@ -46,4 +46,10 @@ public: } }; +class LlamaChat : public CodeLlamaChat +{ +public: + QString name() const override { return "Llama Chat"; } +}; + } // namespace QodeAssist::Templates