miqt-uic: implement all connections

This commit is contained in:
mappu 2025-05-28 18:36:45 +12:00
parent ef674bda2f
commit 5e66acd936
2 changed files with 18 additions and 7 deletions

View File

@ -26,12 +26,13 @@ func NewDialogUi() *DialogUi {
ui.buttonBox.SetGeometry(qt.NewQRect(30, 240, 341, 32))
ui.buttonBox.SetOrientation(qt.Horizontal)
ui.buttonBox.SetStandardButtons(qt.QDialogButtonBox__Cancel | qt.QDialogButtonBox__Ok)
ui.buttonBox.OnAccepted(ui.Dialog.Accept)
ui.buttonBox.OnRejected(ui.Dialog.Reject)
ui.label = qt.NewQLabel(ui.Dialog.QWidget)
ui.label.SetObjectName("label")
ui.label.SetGeometry(qt.NewQRect(20, 20, 171, 31))
ui.buttonBox.OnAccepted(ui.Dialog.Accept)
ui.buttonBox.OnRejected(ui.Dialog.Reject)
ui.Retranslate()
return ui

View File

@ -688,13 +688,16 @@ func (gs *generateState) generateWidget(w UiWidget, parentName string, parentCla
}
}
if w.Class == "QDialogButtonBox" {
// TODO make this using a native connection instead of a C++ -> Go -> C++ roundtrip
ret.WriteString(`ui.` + w.Name + `.OnAccepted(` + gs.RootWindowName + ".Accept)\n")
ret.WriteString(`ui.` + w.Name + `.OnRejected(` + gs.RootWindowName + ".Reject)\n")
return ret.String(), nil
}
func normalizeSignalName(s string) string {
if s == "" {
return ""
}
return ret.String(), nil
s = strings.TrimSuffix(s, `()`)
return strings.ToUpper(string(s[0])) + s[1:]
}
func generate(packageName string, goGenerateArgs string, u UiFile, useQt6 bool) ([]byte, error) {
@ -760,6 +763,13 @@ func New` + u.Class + `Ui() *` + u.Class + `Ui {
}
}
// Connections
for _, c := range u.Connections.Connections {
// TODO make this using a native connection instead of a C++ -> Go -> C++ roundtrip
ret.WriteString(`ui.` + c.Sender + `.On` + normalizeSignalName(c.Signal) + `(ui.` + c.Receiver + "." + normalizeSignalName(c.Slot) + ")\n")
}
ret.WriteString("\nui.Retranslate()\n\n")
for _, sci := range setCurrentIndex {