mirror of
https://github.com/mappu/miqt.git
synced 2025-05-30 23:00:26 +00:00
miqt-uic: implement all connections
This commit is contained in:
parent
ef674bda2f
commit
5e66acd936
@ -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
|
||||
|
@ -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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user