Style checkbox for menu items

This commit is contained in:
David Rowe 2016-03-11 15:51:27 +13:00
parent fb0f97264c
commit e175c19754
2 changed files with 12 additions and 18 deletions

View file

@ -26,31 +26,25 @@ Item {
visible: source.visible
width: parent.width
FontAwesome {
clip: true
CheckBox {
id: check
verticalAlignment: Text.AlignVCenter
// FIXME: Shouild use radio buttons if source.exclusiveGroup.
anchors {
verticalCenter: parent.verticalCenter
left: parent.left
leftMargin: hifi.dimensions.menuPadding.x
top: label.top
topMargin: 0
}
width: 1.5 * hifi.dimensions.menuPadding.x
color: label.color
text: checkText()
size: label.height
visible: source.visible
font.pixelSize: size
function checkText() {
width: 20
visible: source.visible && source.type === 1 && source.checkable
checked: setChecked()
function setChecked() {
if (!source || source.type !== 1 || !source.checkable) {
return ""
return false;
}
// FIXME this works for native QML menus but I don't think it will
// for proxied QML menus
if (source.exclusiveGroup) {
return source.checked ? "\uF05D" : "\uF10C"
}
return source.checked ? "\uF046" : "\uF096"
return source.checked;
}
}
@ -69,7 +63,7 @@ Item {
Item {
// Space for shortcut key or disclosure icon.
id: tail
width: 4 * hifi.dimensions.menuPadding.x
width: 48
anchors {
verticalCenter: parent.verticalCenter
right: parent.right

View file

@ -138,7 +138,7 @@ Item {
readonly property real modalDialogTitleHeight: 40
readonly property real controlLineHeight: 29 // Height of spinbox control on 1920 x 1080 monitor
readonly property real controlInterlineHeight: 22 // 75% of controlLineHeight
readonly property vector2d menuPadding: Qt.vector2d(12, 12)
readonly property vector2d menuPadding: Qt.vector2d(14, 12)
}
Item {