uic: support standard button connections in dialogs

This commit is contained in:
mappu 2024-10-05 17:49:21 +13:00
parent b64d48a974
commit 3fffa86823

View File

@ -8,6 +8,7 @@ import (
) )
var ( var (
RootWindowName = ""
DefaultGridMargin = 11 DefaultGridMargin = 11
DefaultSpacing = 6 DefaultSpacing = 6
IconCounter = 0 IconCounter = 0
@ -208,6 +209,9 @@ func generateWidget(w UiWidget, parentName string, parentClass string) (string,
ui.` + w.Name + ` = qt.` + ctor + `(` + qwidgetName(parentName, parentClass) + `) ui.` + w.Name + ` = qt.` + ctor + `(` + qwidgetName(parentName, parentClass) + `)
ui.` + w.Name + `.SetObjectName(` + strconv.Quote(w.Name) + `) ui.` + w.Name + `.SetObjectName(` + strconv.Quote(w.Name) + `)
`) `)
if RootWindowName == "" {
RootWindowName = `ui.` + w.Name
}
// Properties // Properties
@ -450,6 +454,7 @@ func generateWidget(w UiWidget, parentName string, parentClass string) (string,
ret.WriteString(`ui.` + w.Name + `.AddTab(` + qwidgetName(`ui.`+child.Name, child.Class) + `, "")` + "\n") ret.WriteString(`ui.` + w.Name + `.AddTab(` + qwidgetName(`ui.`+child.Name, child.Class) + `, "")` + "\n")
} }
} }
} }
// AddActions // AddActions
@ -476,6 +481,12 @@ func generateWidget(w UiWidget, parentName string, parentClass string) (string,
} }
} }
if w.Class == "QDialogButtonBox" {
// TODO make this using a native connection instead of a C++ -> Go -> C++ roundtrip
ret.WriteString(`ui.` + w.Name + `.OnAccepted(` + RootWindowName + ".Accept)\n")
ret.WriteString(`ui.` + w.Name + `.OnRejected(` + RootWindowName + ".Reject)\n")
}
return ret.String(), nil return ret.String(), nil
} }