uic: support enum-set properties

This commit is contained in:
mappu 2024-10-05 17:48:58 +13:00
parent 7e320004f5
commit 1a4d34185f
2 changed files with 16 additions and 0 deletions

View File

@ -80,6 +80,7 @@ type UiProperty struct {
EnumVal *string `xml:"enum,omitempty"`
RectVal *UiRect `xml:"rect,omitempty"`
IconVal *UiIcon `xml:"iconset,omitempty"`
SetVal *string `xml:"set,omitempty"`
}
type UiActionReference struct {

View File

@ -162,6 +162,21 @@ func renderProperties(properties []UiProperty, ret *strings.Builder, targetName,
// detect the case and convert it to match
ret.WriteString(`ui.` + targetName + setterFunc + `(` + normalizeEnumName(*prop.EnumVal) + ")\n")
} else if prop.SetVal != nil {
// QDialogButtonBox::"standardButtons"
// <set>QDialogButtonBox::Cancel|QDialogButtonBox::Save</set>
parts := strings.Split(*prop.SetVal, `|`)
for i, p := range parts {
parts[i] = normalizeEnumName(p)
}
emit := "0"
if len(parts) > 0 {
emit = strings.Join(parts, `|`)
}
ret.WriteString(`ui.` + targetName + setterFunc + `(` + emit + ")\n")
} else if prop.IconVal != nil {
iconName := renderIcon(prop.IconVal, ret)
ret.WriteString(`ui.` + targetName + setterFunc + `(` + iconName + ")\n")