mirror of
https://github.com/mappu/miqt.git
synced 2025-05-12 14:40:32 +00:00
miqt-uic: support SizePolicy
This commit is contained in:
parent
9d4cabc099
commit
d802e345fe
@ -74,15 +74,23 @@ type UiIcon struct {
|
||||
Base string `xml:",chardata"`
|
||||
}
|
||||
|
||||
type UiSizePolicy struct {
|
||||
HSizeType string `xml:"hsizetype,attr"`
|
||||
VSizeType string `xml:"vsizetype,attr"`
|
||||
HStretch int `xml:"horstretch"`
|
||||
VStretch int `xml:"verstretch"`
|
||||
}
|
||||
|
||||
type UiProperty struct {
|
||||
Name string `xml:"name,attr"`
|
||||
StringVal *UiString `xml:"string,omitempty"`
|
||||
NumberVal *string `xml:"number,omitempty"` // Preserve as string literal
|
||||
BoolVal *bool `xml:"bool,omitempty"` // "true" or "false"
|
||||
EnumVal *string `xml:"enum,omitempty"`
|
||||
RectVal *UiRect `xml:"rect,omitempty"`
|
||||
IconVal *UiIcon `xml:"iconset,omitempty"`
|
||||
SetVal *string `xml:"set,omitempty"`
|
||||
Name string `xml:"name,attr"`
|
||||
StringVal *UiString `xml:"string,omitempty"`
|
||||
NumberVal *string `xml:"number,omitempty"` // Preserve as string literal
|
||||
BoolVal *bool `xml:"bool,omitempty"` // "true" or "false"
|
||||
EnumVal *string `xml:"enum,omitempty"`
|
||||
RectVal *UiRect `xml:"rect,omitempty"`
|
||||
IconVal *UiIcon `xml:"iconset,omitempty"`
|
||||
SetVal *string `xml:"set,omitempty"`
|
||||
SizePolicyVal *UiSizePolicy `xml:"sizepolicy,omitempty"`
|
||||
}
|
||||
|
||||
type UiActionReference struct {
|
||||
|
@ -182,6 +182,17 @@ func renderProperties(properties []UiProperty, ret *strings.Builder, targetName,
|
||||
iconName := renderIcon(prop.IconVal, ret)
|
||||
ret.WriteString(`ui.` + targetName + setterFunc + `(` + iconName + ")\n")
|
||||
|
||||
} else if prop.Name == "sizePolicy" {
|
||||
spn := targetName + "__sizePolicy"
|
||||
ret.WriteString(spn + " := qt.NewQSizePolicy()\n")
|
||||
ret.WriteString(spn + ".SetHorizontalPolicy(" + normalizeEnumName("QSizePolicy::"+prop.SizePolicyVal.HSizeType) + ")\n")
|
||||
ret.WriteString(spn + ".SetVerticalPolicy(" + normalizeEnumName("QSizePolicy::"+prop.SizePolicyVal.VSizeType) + ")\n")
|
||||
ret.WriteString(spn + ".SetHorizontalStretch(" + strconv.Itoa(prop.SizePolicyVal.HStretch) + ")\n")
|
||||
ret.WriteString(spn + ".SetVerticalStretch(" + strconv.Itoa(prop.SizePolicyVal.VStretch) + ")\n")
|
||||
ret.WriteString(spn + ".SetHeightForWidth(ui." + targetName + ".SizePolicy().HasHeightForWidth())\n")
|
||||
ret.WriteString("ui." + targetName + ".SetSizePolicy(*" + spn + ")\n")
|
||||
ret.WriteString(spn + ".Delete() // setter copies values\n")
|
||||
|
||||
} else {
|
||||
ret.WriteString("/* miqt-uic: no handler for " + targetName + " property '" + prop.Name + "' */\n")
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user