mirror of
https://github.com/bluszcz/cutego.git
synced 2024-09-28 21:25:16 +03:00
fix qtmoc + new quick/hotreload example
This commit is contained in:
parent
11aa6b19de
commit
0b03390a53
5 changed files with 66 additions and 6 deletions
|
@ -124,12 +124,14 @@ func (c *Class) IsSubClassOf(class string) bool {
|
|||
func (c *Class) isSubClass() bool { return c.Fullname != "" }
|
||||
|
||||
func (c *Class) HasFunctionWithName(n string) bool {
|
||||
for _, f := range c.Functions {
|
||||
if strings.ToLower(f.Name) != strings.ToLower(n) {
|
||||
continue
|
||||
}
|
||||
return c.HasFunctionWithNameAndOverloadNumber(n, "")
|
||||
}
|
||||
|
||||
return true
|
||||
func (c *Class) HasFunctionWithNameAndOverloadNumber(n string, num string) bool {
|
||||
for _, f := range c.Functions {
|
||||
if strings.ToLower(f.Name) == strings.ToLower(n) && f.OverloadNumber == num {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
|
|
43
internal/examples/quick/hotreload/hotreload.go
Executable file
43
internal/examples/quick/hotreload/hotreload.go
Executable file
|
@ -0,0 +1,43 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/therecipe/qt/core"
|
||||
"github.com/therecipe/qt/quick"
|
||||
"github.com/therecipe/qt/widgets"
|
||||
)
|
||||
|
||||
func initQQuickView(path string) *quick.QQuickView {
|
||||
|
||||
var view = quick.NewQQuickView(nil)
|
||||
|
||||
var watcher = core.NewQFileSystemWatcher2([]string{filepath.Dir(path)}, nil)
|
||||
|
||||
var reload = func(p string) {
|
||||
println("changed:", p)
|
||||
view.SetSource(core.NewQUrl())
|
||||
view.Engine().ClearComponentCache()
|
||||
view.SetSource(core.NewQUrl3(path, 0))
|
||||
}
|
||||
|
||||
//watcher.ConnectFileChanged(reload)
|
||||
watcher.ConnectDirectoryChanged(reload)
|
||||
|
||||
return view
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
||||
var path = filepath.Join(os.Getenv("GOPATH"), "src", "github.com", "therecipe", "qt", "internal", "examples", "quick", "hotreload", "qml", "hotreload.qml")
|
||||
|
||||
widgets.NewQApplication(len(os.Args), os.Args)
|
||||
|
||||
var view = initQQuickView(path)
|
||||
view.SetSource(core.NewQUrl3(path, 0))
|
||||
view.SetResizeMode(quick.QQuickView__SizeRootObjectToView)
|
||||
view.Show()
|
||||
|
||||
widgets.QApplication_Exec()
|
||||
}
|
15
internal/examples/quick/hotreload/qml/hotreload.qml
Executable file
15
internal/examples/quick/hotreload/qml/hotreload.qml
Executable file
|
@ -0,0 +1,15 @@
|
|||
import QtQuick 2.0
|
||||
|
||||
Rectangle {
|
||||
id: page
|
||||
width: 320; height: 480
|
||||
color: "lightgray"
|
||||
|
||||
Text {
|
||||
id: helloText
|
||||
text: "Hello world!"
|
||||
y: 30
|
||||
anchors.horizontalCenter: page.horizontalCenter
|
||||
font.pointSize: 24; font.bold: true
|
||||
}
|
||||
}
|
|
@ -352,7 +352,7 @@ func (m *appMoc) generate() error {
|
|||
f.Name = strings.Replace(f.Name, bcf.ClassName(), c.Name, -1)
|
||||
f.Fullname = strings.Replace(f.Fullname, bcf.ClassName(), c.Name, -1)
|
||||
|
||||
if !c.HasFunctionWithName(f.Name) {
|
||||
if !c.HasFunctionWithNameAndOverloadNumber(f.Name, f.OverloadNumber) {
|
||||
c.Functions = append(c.Functions, &f)
|
||||
}
|
||||
}
|
||||
|
|
0
internal/utils/walk.go
Normal file → Executable file
0
internal/utils/walk.go
Normal file → Executable file
Loading…
Reference in a new issue