cutego/sailfish/sailfish.go
therecipe 3738bb9320 greatly extend the Go <-> Qml/JS interoperability
These changes introduce two new functions called (*qml.QJSEngine).NewGoType and (*qml.QJSEngine).ToGoType, that can be used (similiar to how core.NewQVariant1 and (*core.QVariant).ToGoType can be used) to convert Go objects and functions to *qml.QJSValues and vice versa.
This allows for a more natural communication between Go and Qml/JS and makes it possible to simply pass a Go structs to Qml/JS and then call Go methods on that object.
For this to work, the object passed to Qml/JS needs to implement the `Pointer() unsafe.Pointer` and `SetPointer(unsafe.Pointer)` functions atm.
Which means, since all Qt classes already implement these functions, that you can now use the whole binding from Qml/JS as well and theoretically create a full Qt application inside an QJSEngine as well. A few example applications almost entirely written in JS can be found here: https://github.com/therecipe/examples/tree/master/js/
Furthermore, the `widgets_playground` example (https://github.com/therecipe/widgets_playground) now fully works on desktop and mobile targets as well.

other changes:
* core.NewQVariant1 and (*core.QVariant).ToGoType now recognize json tags
* workaround for qtmoc issue related to named imports
* speed-up go module android docker deployments
* fix webengine related qtdeploy bug on macOS
* fix int overflow issue for arm docker images
* fix js docker images
2019-11-17 18:05:18 +01:00

119 lines
2.2 KiB
Go

// +build !sailfish,!sailfish_emulator
package sailfish
import (
"github.com/therecipe/qt"
"github.com/therecipe/qt/core"
"github.com/therecipe/qt/gui"
"github.com/therecipe/qt/quick"
"strings"
"unsafe"
)
func unpackStringList(s string) []string {
if len(s) == 0 {
return make([]string, 0)
}
return strings.Split(s, "¡¦!")
}
type SailfishApp struct {
ptr unsafe.Pointer
}
type SailfishApp_ITF interface {
SailfishApp_PTR() *SailfishApp
}
func (ptr *SailfishApp) SailfishApp_PTR() *SailfishApp {
return ptr
}
func (ptr *SailfishApp) Pointer() unsafe.Pointer {
if ptr != nil {
return ptr.ptr
}
return nil
}
func (ptr *SailfishApp) SetPointer(p unsafe.Pointer) {
if ptr != nil {
ptr.ptr = p
}
}
func PointerFromSailfishApp(ptr SailfishApp_ITF) unsafe.Pointer {
if ptr != nil {
return ptr.SailfishApp_PTR().Pointer()
}
return nil
}
func NewSailfishAppFromPointer(ptr unsafe.Pointer) (n *SailfishApp) {
n = new(SailfishApp)
n.SetPointer(ptr)
return
}
func (ptr *SailfishApp) DestroySailfishApp() {}
func SailfishApp_Application(argc int, argv []string) *gui.QGuiApplication {
return nil
}
func (ptr *SailfishApp) Application(argc int, argv []string) *gui.QGuiApplication {
return nil
}
func SailfishApp_Main(argc int, argv []string) int {
return 0
}
func (ptr *SailfishApp) Main(argc int, argv []string) int {
return 0
}
func SailfishApp_CreateView() *quick.QQuickView {
return nil
}
func (ptr *SailfishApp) CreateView() *quick.QQuickView {
return nil
}
func SailfishApp_PathTo(filename string) *core.QUrl {
return nil
}
func (ptr *SailfishApp) PathTo(filename string) *core.QUrl {
return nil
}
func SailfishApp_PathToMainQml() *core.QUrl {
return nil
}
func (ptr *SailfishApp) PathToMainQml() *core.QUrl {
return nil
}
func init() {
qt.ItfMap["sailfish.SailfishApp_ITF"] = SailfishApp{}
qt.FuncMap["sailfish.SailfishApp_Application"] = SailfishApp_Application
qt.FuncMap["sailfish.SailfishApp_Main"] = SailfishApp_Main
qt.FuncMap["sailfish.SailfishApp_CreateView"] = SailfishApp_CreateView
qt.FuncMap["sailfish.SailfishApp_PathTo"] = SailfishApp_PathTo
qt.FuncMap["sailfish.SailfishApp_PathToMainQml"] = SailfishApp_PathToMainQml
}