mirror of
https://github.com/Palm1r/QodeAssist.git
synced 2025-12-17 06:43:14 -05:00
feat: Add context menu to input field and text blocks
This commit is contained in:
@ -23,6 +23,7 @@ import QtQuick.Controls.Basic as QQC
|
|||||||
import QtQuick.Layouts
|
import QtQuick.Layouts
|
||||||
import ChatView
|
import ChatView
|
||||||
import UIControls
|
import UIControls
|
||||||
|
import Qt.labs.platform as Platform
|
||||||
import "./parts"
|
import "./parts"
|
||||||
|
|
||||||
ChatRootView {
|
ChatRootView {
|
||||||
@ -183,8 +184,8 @@ ChatRootView {
|
|||||||
id: messageInput
|
id: messageInput
|
||||||
|
|
||||||
placeholderText: Qt.platform.os === "osx"
|
placeholderText: Qt.platform.os === "osx"
|
||||||
? qsTr("Type your message here... (⌘+↩ to send)")
|
? qsTr("Type your message here... (⌘+↩ to send)")
|
||||||
: qsTr("Type your message here... (Ctrl+Enter to send)")
|
: qsTr("Type your message here... (Ctrl+Enter to send)")
|
||||||
placeholderTextColor: palette.mid
|
placeholderTextColor: palette.mid
|
||||||
color: palette.text
|
color: palette.text
|
||||||
background: Rectangle {
|
background: Rectangle {
|
||||||
@ -206,6 +207,51 @@ ChatRootView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onTextChanged: root.calculateMessageTokensCount(messageInput.text)
|
onTextChanged: root.calculateMessageTokensCount(messageInput.text)
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
anchors.fill: parent
|
||||||
|
acceptedButtons: Qt.RightButton
|
||||||
|
onClicked: messageContextMenu.open()
|
||||||
|
propagateComposedEvents: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Platform.Menu {
|
||||||
|
id: messageContextMenu
|
||||||
|
|
||||||
|
Platform.MenuItem {
|
||||||
|
text: qsTr("Cut")
|
||||||
|
enabled: messageInput.selectedText.length > 0
|
||||||
|
onTriggered: messageInput.cut()
|
||||||
|
}
|
||||||
|
|
||||||
|
Platform.MenuItem {
|
||||||
|
text: qsTr("Copy")
|
||||||
|
enabled: messageInput.selectedText.length > 0
|
||||||
|
onTriggered: messageInput.copy()
|
||||||
|
}
|
||||||
|
|
||||||
|
Platform.MenuItem {
|
||||||
|
text: qsTr("Paste")
|
||||||
|
enabled: messageInput.canPaste
|
||||||
|
onTriggered: messageInput.paste()
|
||||||
|
}
|
||||||
|
|
||||||
|
Platform.MenuSeparator {}
|
||||||
|
|
||||||
|
Platform.MenuItem {
|
||||||
|
text: qsTr("Select All")
|
||||||
|
enabled: messageInput.text.length > 0
|
||||||
|
onTriggered: messageInput.selectAll()
|
||||||
|
}
|
||||||
|
|
||||||
|
Platform.MenuSeparator {}
|
||||||
|
|
||||||
|
Platform.MenuItem {
|
||||||
|
text: qsTr("Clear")
|
||||||
|
enabled: messageInput.text.length > 0
|
||||||
|
onTriggered: messageInput.clear()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -18,6 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import QtQuick
|
import QtQuick
|
||||||
|
import Qt.labs.platform as Platform
|
||||||
|
|
||||||
TextEdit {
|
TextEdit {
|
||||||
id: root
|
id: root
|
||||||
@ -27,4 +28,29 @@ TextEdit {
|
|||||||
wrapMode: Text.WordWrap
|
wrapMode: Text.WordWrap
|
||||||
selectionColor: palette.highlight
|
selectionColor: palette.highlight
|
||||||
color: palette.text
|
color: palette.text
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
anchors.fill: parent
|
||||||
|
acceptedButtons: Qt.RightButton
|
||||||
|
onClicked: contextMenu.open()
|
||||||
|
propagateComposedEvents: true
|
||||||
|
}
|
||||||
|
|
||||||
|
Platform.Menu {
|
||||||
|
id: contextMenu
|
||||||
|
|
||||||
|
Platform.MenuItem {
|
||||||
|
text: qsTr("Copy")
|
||||||
|
enabled: root.selectedText.length > 0
|
||||||
|
onTriggered: root.copy()
|
||||||
|
}
|
||||||
|
|
||||||
|
Platform.MenuSeparator {}
|
||||||
|
|
||||||
|
Platform.MenuItem {
|
||||||
|
text: qsTr("Select All")
|
||||||
|
enabled: root.text.length > 0
|
||||||
|
onTriggered: root.selectAll()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user