uiux(StatusChatInput): highlight matching formatting option

This will highlight any option in the text formatting menu whose
formatting matches the selected text formatting

Closes #1931
This commit is contained in:
Pascal Precht 2021-03-03 16:38:46 +01:00 committed by Iuri Matias
parent e94cfaec74
commit e6f17fdf55
2 changed files with 9 additions and 0 deletions

View File

@ -708,6 +708,10 @@ Rectangle {
StatusTextFormatMenu {
id: textFormatMenu
function surroundedBy(chars) {
return messageInputField.selectedText.trim().startsWith(chars) &&
messageInputField.selectedText.trim().endsWith(chars)
}
Action {
icon.name: "format-text-bold"
icon.width: 12
@ -715,6 +719,7 @@ Rectangle {
onTriggered: wrapSelection("**")
//% "Bold"
text: qsTrId("bold")
checked: textFormatMenu.surroundedBy("**")
}
Action {
icon.name: "format-text-italic"
@ -723,6 +728,7 @@ Rectangle {
onTriggered: wrapSelection("*")
//% "Italic"
text: qsTrId("italic")
checked: textFormatMenu.surroundedBy("*") && !textFormatMenu.surroundedBy("**")
}
Action {
icon.name: "format-text-strike-through"
@ -731,6 +737,7 @@ Rectangle {
onTriggered: wrapSelection("~~")
//% "Strikethrough"
text: qsTrId("strikethrough")
checked: textFormatMenu.surroundedBy("~~")
}
Action {
icon.name: "format-text-code"
@ -739,6 +746,7 @@ Rectangle {
onTriggered: wrapSelection("`")
//% "Code"
text: qsTrId("code")
checked: textFormatMenu.surroundedBy("`")
}
}
}

View File

@ -65,6 +65,7 @@ Menu {
icon.width: menuItem.action.icon.width
icon.height: menuItem.action.icon.height
onClicked: menuItem.action.trigger()
highlighted: menuItem.action.checked
StatusToolTip {
visible: parent.hovered
text: menuItem.action.text