mirror of
https://github.com/mappu/miqt.git
synced 2025-05-13 07:00:21 +00:00
miqt-uic: support SizePolicy
This commit is contained in:
parent
9d4cabc099
commit
d802e345fe
@ -74,6 +74,13 @@ type UiIcon struct {
|
|||||||
Base string `xml:",chardata"`
|
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 {
|
type UiProperty struct {
|
||||||
Name string `xml:"name,attr"`
|
Name string `xml:"name,attr"`
|
||||||
StringVal *UiString `xml:"string,omitempty"`
|
StringVal *UiString `xml:"string,omitempty"`
|
||||||
@ -83,6 +90,7 @@ type UiProperty struct {
|
|||||||
RectVal *UiRect `xml:"rect,omitempty"`
|
RectVal *UiRect `xml:"rect,omitempty"`
|
||||||
IconVal *UiIcon `xml:"iconset,omitempty"`
|
IconVal *UiIcon `xml:"iconset,omitempty"`
|
||||||
SetVal *string `xml:"set,omitempty"`
|
SetVal *string `xml:"set,omitempty"`
|
||||||
|
SizePolicyVal *UiSizePolicy `xml:"sizepolicy,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type UiActionReference struct {
|
type UiActionReference struct {
|
||||||
|
@ -182,6 +182,17 @@ func renderProperties(properties []UiProperty, ret *strings.Builder, targetName,
|
|||||||
iconName := renderIcon(prop.IconVal, ret)
|
iconName := renderIcon(prop.IconVal, ret)
|
||||||
ret.WriteString(`ui.` + targetName + setterFunc + `(` + iconName + ")\n")
|
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 {
|
} else {
|
||||||
ret.WriteString("/* miqt-uic: no handler for " + targetName + " property '" + prop.Name + "' */\n")
|
ret.WriteString("/* miqt-uic: no handler for " + targetName + " property '" + prop.Name + "' */\n")
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user