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:
parent
e94cfaec74
commit
e6f17fdf55
|
@ -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("`")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue