-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
94 lines (82 loc) · 2.43 KB
/
main.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
package main
import (
"github.com/therecipe/qt/core"
"github.com/therecipe/qt/gui"
"github.com/therecipe/qt/qml"
"github.com/therecipe/qt/quickcontrols2"
"os"
"path/filepath"
"sexy-filter/bridge"
"sexy-filter/configure"
"sexy-filter/js"
kLog "sexy-filter/log"
)
func main() {
configure.Init(os.Args[0])
js.InitSingle()
if e := js.InitDB(); e != nil {
os.Exit(-1)
return
}
app := gui.NewQGuiApplication(len(os.Args), os.Args)
app.SetAttribute(core.Qt__AA_EnableHighDpiScaling, true)
gui.QGuiApplication_SetWindowIcon(gui.NewQIcon5(":/views/images/sexy.ico"))
app.SetOrganizationName("cerberus")
app.SetOrganizationDomain("doc.king011.com")
app.SetApplicationName("go-qt-sexy-filter")
s := core.NewQSettings5(nil)
//初始 語言 配置
local := s.Value("locale", core.NewQVariant14("zh_TW")).ToString()
configure.InitLocale(local)
local = configure.GetLocale()
//初始 界面 配置
style := s.Value("style", core.NewQVariant7(0)).ToInt(false)
configure.InitStyle(style)
style = configure.GetStyle()
if local == "zh_TW" {
translator := core.NewQTranslator(nil)
if translator.Load2(core.NewQLocale(), "zh_TW", "_", ":/locale", ".qm") {
core.QCoreApplication_InstallTranslator(translator)
} else {
if kLog.Warn != nil {
kLog.Warn.Println("cannot load translator", core.QLocale_System().Name())
}
}
} else {
dir, e := filepath.Abs(os.Args[0])
if e == nil {
dir = filepath.Dir(dir) + "/locale"
} else {
dir = "lolcale"
if kLog.Warn != nil {
kLog.Warn.Println(e)
}
}
translator := core.NewQTranslator(nil)
if translator.Load2(core.NewQLocale(), configure.GetLocale(), "_", dir, ".qm") {
core.QCoreApplication_InstallTranslator(translator)
} else {
if kLog.Warn != nil {
kLog.Warn.Println(dir)
kLog.Warn.Println("cannot load translator", core.QLocale_System().Name())
}
if translator.Load2(core.NewQLocale(), "zh_TW", "_", ":/locale", ".qm") {
core.QCoreApplication_InstallTranslator(translator)
} else {
if kLog.Warn != nil {
kLog.Warn.Println("cannot load translator", core.QLocale_System().Name())
}
}
}
}
if style < 2 {
quickcontrols2.QQuickStyle_SetStyle("Material")
} else {
quickcontrols2.QQuickStyle_SetStyle("Universal")
}
engine := qml.NewQQmlApplicationEngine(nil)
bridge.Init(engine.RootContext())
engine.Load(core.NewQUrl3("qrc:/views/main.qml", 0))
//engine.Load(core.NewQUrl3("views/main.qml", 0))
gui.QGuiApplication_Exec()
}