mirror of
https://github.com/mappu/miqt.git
synced 2025-05-12 06:30:22 +00:00
miqt-uic: support icon themes
This commit is contained in:
parent
2fc549206b
commit
b3b914ede8
@ -61,6 +61,7 @@ type UiString struct {
|
|||||||
|
|
||||||
type UiIcon struct {
|
type UiIcon struct {
|
||||||
ResourceFile string `xml:"resource,attr"`
|
ResourceFile string `xml:"resource,attr"`
|
||||||
|
Theme string `xml:"theme,attr"`
|
||||||
|
|
||||||
NormalOff *string `xml:"normaloff,omitempty"`
|
NormalOff *string `xml:"normaloff,omitempty"`
|
||||||
NormalOn *string `xml:"normalon,omitempty"`
|
NormalOn *string `xml:"normalon,omitempty"`
|
||||||
|
@ -75,13 +75,22 @@ func renderIcon(iconVal *UiIcon, ret *strings.Builder) string {
|
|||||||
iconName := fmt.Sprintf("icon%d", IconCounter)
|
iconName := fmt.Sprintf("icon%d", IconCounter)
|
||||||
IconCounter++
|
IconCounter++
|
||||||
|
|
||||||
ret.WriteString(iconName + " := qt.NewQIcon()\n")
|
if iconVal.Theme != "" {
|
||||||
|
ret.WriteString(iconName + ` := qt.QIcon_FromTheme(` + strconv.Quote(iconVal.Theme) + ")\n")
|
||||||
|
} else {
|
||||||
|
ret.WriteString(iconName + " := qt.NewQIcon()\n")
|
||||||
|
}
|
||||||
|
|
||||||
// A base entry is a synonym for NormalOff. Don't need them both
|
// A base entry is a synonym for NormalOff. Don't need them both
|
||||||
if iconVal.NormalOff != nil {
|
if iconVal.NormalOff != nil && *iconVal.NormalOff != "." {
|
||||||
ret.WriteString(iconName + ".AddFile4(" + strconv.Quote(*iconVal.NormalOff) + ", qt.NewQSize(), qt.QIcon__Normal, qt.QIcon__Off)\n")
|
ret.WriteString(iconName + ".AddFile4(" + strconv.Quote(*iconVal.NormalOff) + ", qt.NewQSize(), qt.QIcon__Normal, qt.QIcon__Off)\n")
|
||||||
} else {
|
} else {
|
||||||
ret.WriteString(iconName + ".AddFile(" + strconv.Quote(strings.TrimSpace(iconVal.Base)) + ")\n")
|
base := strings.TrimSpace(iconVal.Base)
|
||||||
|
if base == "" || base == "." {
|
||||||
|
// skip
|
||||||
|
} else {
|
||||||
|
ret.WriteString(iconName + ".AddFile(" + strconv.Quote(strings.TrimSpace(iconVal.Base)) + ")\n")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if iconVal.NormalOn != nil {
|
if iconVal.NormalOn != nil {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user