mirror of
https://github.com/Palm1r/QodeAssist.git
synced 2025-06-04 01:28:58 -04:00
Replace textinput to textfield
This commit is contained in:
parent
146e772514
commit
1dd50b6c83
@ -81,17 +81,16 @@ ChatRootView {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RowLayout {
|
ScrollView {
|
||||||
Layout.fillWidth: true
|
id: view
|
||||||
spacing: 5
|
|
||||||
|
|
||||||
QQC.TextField {
|
Layout.fillWidth: true
|
||||||
|
Layout.minimumHeight: 30
|
||||||
|
Layout.maximumHeight: root.height / 2
|
||||||
|
|
||||||
|
QQC.TextArea {
|
||||||
id: messageInput
|
id: messageInput
|
||||||
|
|
||||||
Layout.fillWidth: true
|
|
||||||
Layout.minimumWidth: 60
|
|
||||||
Layout.minimumHeight: 30
|
|
||||||
rightInset: -(parent.width - sendButton.width - clearButton.width)
|
|
||||||
placeholderText: qsTr("Type your message here...")
|
placeholderText: qsTr("Type your message here...")
|
||||||
placeholderTextColor: "#888"
|
placeholderTextColor: "#888"
|
||||||
color: root.primaryColor.hslLightness > 0.5 ? "black" : "white"
|
color: root.primaryColor.hslLightness > 0.5 ? "black" : "white"
|
||||||
@ -102,30 +101,31 @@ ChatRootView {
|
|||||||
: Qt.darker(root.primaryColor, 1.5)
|
: Qt.darker(root.primaryColor, 1.5)
|
||||||
border.width: 1
|
border.width: 1
|
||||||
}
|
}
|
||||||
|
Keys.onPressed: function(event) {
|
||||||
onAccepted: sendButton.clicked()
|
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 {
|
Button {
|
||||||
id: sendButton
|
id: sendButton
|
||||||
|
|
||||||
Layout.alignment: Qt.AlignVCenter
|
Layout.alignment: Qt.AlignBottom
|
||||||
Layout.minimumHeight: 30
|
|
||||||
text: qsTr("Send")
|
text: qsTr("Send")
|
||||||
onClicked: {
|
onClicked: sendChatMessage()
|
||||||
if (messageInput.text.trim() !== "") {
|
|
||||||
root.sendMessage(messageInput.text);
|
|
||||||
messageInput.text = ""
|
|
||||||
scrollToBottom()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Button {
|
Button {
|
||||||
id: clearButton
|
id: clearButton
|
||||||
|
|
||||||
Layout.alignment: Qt.AlignVCenter
|
Layout.alignment: Qt.AlignBottom
|
||||||
Layout.minimumHeight: 30
|
text: qsTr("Clear Chat")
|
||||||
text: qsTr("Clear")
|
|
||||||
onClicked: clearChat()
|
onClicked: clearChat()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -158,4 +158,10 @@ ChatRootView {
|
|||||||
function scrollToBottom() {
|
function scrollToBottom() {
|
||||||
Qt.callLater(chatListView.positionViewAtEnd)
|
Qt.callLater(chatListView.positionViewAtEnd)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function sendChatMessage() {
|
||||||
|
root.sendMessage(messageInput.text);
|
||||||
|
messageInput.text = ""
|
||||||
|
scrollToBottom()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user