2021-04-21 18:18:52 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 2.13
|
|
|
|
|
|
|
|
Action {
|
|
|
|
property string wrapper
|
2021-12-08 21:20:43 +00:00
|
|
|
property string selectedTextWithFormationChars: ""
|
|
|
|
function surroundedBy(chars) {
|
|
|
|
if (selectedTextWithFormationChars === "") {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
const firstIndex = selectedTextWithFormationChars.indexOf(chars);
|
|
|
|
if (firstIndex === -1) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (selectedTextWithFormationChars.lastIndexOf(chars) > firstIndex);
|
|
|
|
}
|
2021-08-24 16:34:24 +00:00
|
|
|
// adding this signal due to a known limitation from Qt: Menu closes when Action is triggered
|
|
|
|
signal actionTriggered()
|
2021-04-21 18:18:52 +00:00
|
|
|
icon.width: 12
|
|
|
|
icon.height: 16
|
2021-12-08 21:20:43 +00:00
|
|
|
checked: surroundedBy(wrapper)
|
2021-04-21 18:18:52 +00:00
|
|
|
}
|