mirror of
https://github.com/status-im/status-desktop.git
synced 2025-01-24 13:32:22 +00:00
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 {
|
StatusTextFormatMenu {
|
||||||
id: textFormatMenu
|
id: textFormatMenu
|
||||||
|
function surroundedBy(chars) {
|
||||||
|
return messageInputField.selectedText.trim().startsWith(chars) &&
|
||||||
|
messageInputField.selectedText.trim().endsWith(chars)
|
||||||
|
}
|
||||||
Action {
|
Action {
|
||||||
icon.name: "format-text-bold"
|
icon.name: "format-text-bold"
|
||||||
icon.width: 12
|
icon.width: 12
|
||||||
@ -715,6 +719,7 @@ Rectangle {
|
|||||||
onTriggered: wrapSelection("**")
|
onTriggered: wrapSelection("**")
|
||||||
//% "Bold"
|
//% "Bold"
|
||||||
text: qsTrId("bold")
|
text: qsTrId("bold")
|
||||||
|
checked: textFormatMenu.surroundedBy("**")
|
||||||
}
|
}
|
||||||
Action {
|
Action {
|
||||||
icon.name: "format-text-italic"
|
icon.name: "format-text-italic"
|
||||||
@ -723,6 +728,7 @@ Rectangle {
|
|||||||
onTriggered: wrapSelection("*")
|
onTriggered: wrapSelection("*")
|
||||||
//% "Italic"
|
//% "Italic"
|
||||||
text: qsTrId("italic")
|
text: qsTrId("italic")
|
||||||
|
checked: textFormatMenu.surroundedBy("*") && !textFormatMenu.surroundedBy("**")
|
||||||
}
|
}
|
||||||
Action {
|
Action {
|
||||||
icon.name: "format-text-strike-through"
|
icon.name: "format-text-strike-through"
|
||||||
@ -731,6 +737,7 @@ Rectangle {
|
|||||||
onTriggered: wrapSelection("~~")
|
onTriggered: wrapSelection("~~")
|
||||||
//% "Strikethrough"
|
//% "Strikethrough"
|
||||||
text: qsTrId("strikethrough")
|
text: qsTrId("strikethrough")
|
||||||
|
checked: textFormatMenu.surroundedBy("~~")
|
||||||
}
|
}
|
||||||
Action {
|
Action {
|
||||||
icon.name: "format-text-code"
|
icon.name: "format-text-code"
|
||||||
@ -739,6 +746,7 @@ Rectangle {
|
|||||||
onTriggered: wrapSelection("`")
|
onTriggered: wrapSelection("`")
|
||||||
//% "Code"
|
//% "Code"
|
||||||
text: qsTrId("code")
|
text: qsTrId("code")
|
||||||
|
checked: textFormatMenu.surroundedBy("`")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -65,6 +65,7 @@ Menu {
|
|||||||
icon.width: menuItem.action.icon.width
|
icon.width: menuItem.action.icon.width
|
||||||
icon.height: menuItem.action.icon.height
|
icon.height: menuItem.action.icon.height
|
||||||
onClicked: menuItem.action.trigger()
|
onClicked: menuItem.action.trigger()
|
||||||
|
highlighted: menuItem.action.checked
|
||||||
StatusToolTip {
|
StatusToolTip {
|
||||||
visible: parent.hovered
|
visible: parent.hovered
|
||||||
text: menuItem.action.text
|
text: menuItem.action.text
|
||||||
|
Loading…
x
Reference in New Issue
Block a user