-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmain_shared.go
52 lines (37 loc) · 966 Bytes
/
main_shared.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package main
import (
"runtime"
"time"
"github.com/therecipe/qt/core"
"github.com/therecipe/qt/widgets"
)
var (
app *widgets.QApplication
isInsideBrowser = (runtime.GOARCH == "js" || runtime.GOARCH == "wasm")
isBrowserJSEngine = runtime.GOARCH == "js"
mainThreadHelperInstance *mainThreadHelper
isDev bool
wasDev bool
skipBoot bool
parsedFlags bool
lastWindowGeo []int
isTesting bool
isTestingVisible bool
)
//TODO: support arguments
func runSync(f func()) { f() }
func runAsync(f func(), r func()) { go func() { f(); mainThreadHelperInstance.RunOnMain(r) }() }
func sleep(msec int) {
time.Sleep(time.Duration(msec) * time.Millisecond)
}
func setInterval(f func(), msec int, p *core.QObject) {
t := core.NewQTimer(p)
t.ConnectTimeout(f)
t.Start(msec)
}
//
type mainThreadHelper struct {
core.QObject
_ func(f func()) `slot:"runOnMain,auto"`
}
func (*mainThreadHelper) runOnMain(f func()) { f() }