mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 04:44:11 +02:00
show checkbox or radiobutton dependently on exclusiveGroup presence
This commit is contained in:
parent
cbbe03cee7
commit
a0a43ebf26
4 changed files with 36 additions and 17 deletions
|
@ -58,14 +58,12 @@ FocusScope {
|
|||
|
||||
function addExclusionGroup(menuItem, exclusionGroup)
|
||||
{
|
||||
console.debug('entering Desktop::addExclusionGroup: menuItem = ', menuItem, 'exclusionGroup = ', exclusionGroup);
|
||||
exclusionGroupsByMenuItem.append(
|
||||
{
|
||||
'menuItem' : menuItem.toString(),
|
||||
'exclusionGroup' : exclusionGroup.toString()
|
||||
}
|
||||
);
|
||||
console.debug('Desktop::addExclusionGroup: ', exclusionGroup, 'rootMenu: ', this);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -26,24 +26,48 @@ Item {
|
|||
visible: source.visible
|
||||
width: parent.width
|
||||
|
||||
CheckBox {
|
||||
Item {
|
||||
id: check
|
||||
// FIXME: Should use radio buttons if source.exclusiveGroup.
|
||||
|
||||
anchors {
|
||||
left: parent.left
|
||||
leftMargin: hifi.dimensions.menuPadding.x + 15
|
||||
verticalCenter: label.verticalCenter
|
||||
}
|
||||
width: 20
|
||||
visible: source.visible && source.type === 1 && source.checkable
|
||||
checked: setChecked()
|
||||
function setChecked() {
|
||||
if (!source || source.type !== 1 || !source.checkable) {
|
||||
return false;
|
||||
|
||||
width: checkbox.visible ? checkbox.width : radiobutton.width
|
||||
height: checkbox.visible ? checkbox.height : radiobutton.height
|
||||
|
||||
CheckBox {
|
||||
id: checkbox
|
||||
// FIXME: Should use radio buttons if source.exclusiveGroup.
|
||||
width: 20
|
||||
visible: source.visible && source.type === 1 && source.checkable && !source.exclusiveGroup
|
||||
checked: setChecked()
|
||||
function setChecked() {
|
||||
if (!source || source.type !== 1 || !source.checkable) {
|
||||
return false;
|
||||
}
|
||||
// FIXME this works for native QML menus but I don't think it will
|
||||
// for proxied QML menus
|
||||
return source.checked;
|
||||
}
|
||||
}
|
||||
|
||||
RadioButton {
|
||||
id: radiobutton
|
||||
// FIXME: Should use radio buttons if source.exclusiveGroup.
|
||||
width: 20
|
||||
visible: source.visible && source.type === 1 && source.checkable && source.exclusiveGroup
|
||||
checked: setChecked()
|
||||
function setChecked() {
|
||||
if (!source || source.type !== 1 || !source.checkable) {
|
||||
return false;
|
||||
}
|
||||
// FIXME this works for native QML menus but I don't think it will
|
||||
// for proxied QML menus
|
||||
return source.checked;
|
||||
}
|
||||
// FIXME this works for native QML menus but I don't think it will
|
||||
// for proxied QML menus
|
||||
return source.checked;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -159,9 +159,6 @@ Item {
|
|||
|
||||
property Component exclusiveGroupMaker: Component {
|
||||
ExclusiveGroup {
|
||||
Component.onDestruction: {
|
||||
console.debug('ExclusionGroup destroyed: ', this)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ public:
|
|||
_from->removeEventFilter(this);
|
||||
}
|
||||
protected:
|
||||
bool eventFilter(QObject* o, QEvent* e) {
|
||||
virtual bool eventFilter(QObject* o, QEvent* e) override {
|
||||
if (e->type() == QEvent::DynamicPropertyChange) {
|
||||
QDynamicPropertyChangeEvent* dpc = static_cast<QDynamicPropertyChangeEvent*>(e);
|
||||
if (dpc->propertyName() == "exclusionGroup")
|
||||
|
|
Loading…
Reference in a new issue