feat(StatusChatInput): make text input formatting work via shortcuts

Closes #1803
This commit is contained in:
Pascal Precht 2021-02-15 13:45:08 +01:00 committed by Iuri Matias
parent dd195431a5
commit 96c2f123b4
1 changed files with 31 additions and 21 deletions

View File

@ -683,6 +683,7 @@ Rectangle {
if (messageInputField.selectedText.trim() !== "") { if (messageInputField.selectedText.trim() !== "") {
let x = event.x - (textFormatMenu.width / 2) let x = event.x - (textFormatMenu.width / 2)
textFormatMenu.popup(x, -messageInputField.height-2) textFormatMenu.popup(x, -messageInputField.height-2)
messageInputField.forceActiveFocus();
} }
} }
@ -718,34 +719,43 @@ Rectangle {
} }
} }
} }
Action {
shortcut: StandardKey.Bold Shortcut {
onTriggered: wrapSelection("**") enabled: messageInputField.activeFocus
sequence: StandardKey.Bold
onActivated: wrapSelection("**")
} }
Action { Shortcut {
shortcut: StandardKey.Italic enabled: messageInputField.activeFocus
onTriggered: wrapSelection("*") sequence: StandardKey.Italic
onActivated: wrapSelection("*")
} }
Action { Shortcut {
shortcut: "Ctrl+Shift+Alt+C" enabled: messageInputField.activeFocus
onTriggered: wrapSelection("```") sequence: "Ctrl+Shift+Alt+C"
onActivated: wrapSelection("```")
} }
Action { Shortcut {
shortcut: "Ctrl+Shift+C" enabled: messageInputField.activeFocus
onTriggered: wrapSelection("`") sequence: "Ctrl+Shift+C"
onActivated: wrapSelection("`")
} }
Action { Shortcut {
shortcut: "Ctrl+Alt+-" enabled: messageInputField.activeFocus
onTriggered: wrapSelection("~~") sequence: "Ctrl+Alt+-"
onActivated: wrapSelection("~~")
} }
Action { Shortcut {
shortcut: "Ctrl+Shift+X" enabled: messageInputField.activeFocus
onTriggered: wrapSelection("~~") sequence: "Ctrl+Shift+X"
onActivated: wrapSelection("~~")
} }
Action { Shortcut {
shortcut: "Ctrl+Meta+Space" enabled: messageInputField.activeFocus
onTriggered: emojiBtn.clicked() sequence: "Ctrl+Meta+Space"
onActivated: emojiBtn.clicked()
} }
} }
Rectangle { Rectangle {