-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
73 lines (58 loc) · 1.56 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
package main
import (
"fmt"
"os"
"path/filepath"
"github.com/averrin/norp_toolkit/modules/customspeak"
"github.com/averrin/norp_toolkit/modules/dicespy"
"github.com/averrin/norp_toolkit/plugin"
"github.com/therecipe/qt/core"
"github.com/therecipe/qt/gui"
"github.com/therecipe/qt/qml"
)
var plugins []plugin.PluginInterface
var root string
const pluginDir = "modules"
func main() {
fmt.Println("Starting NoRP Toolkit")
fmt.Println("")
root, _ = filepath.Abs(filepath.Dir(os.Args[0]))
dc := dicespy.NewPlugin()
cs := customspeak.NewPlugin()
plugins = []plugin.PluginInterface{
dc,
cs,
}
model := NewPluginModel(nil)
for _, plugin := range plugins {
n := plugin.GetName()
err := plugin.Init()
if err == nil {
var pl = NewPlugin(nil)
pl.SetTitle(n)
pl.SetUisource(fmt.Sprintf("qrc:/qml/%v.qml", n))
pl.SetIcon(fmt.Sprintf("file:%v/%v/%v/icon.png", root, pluginDir, n))
model.AddPlugin(pl)
}
}
startUI(model)
}
func startUI(model *PluginModel) {
core.QCoreApplication_SetAttribute(core.Qt__AA_EnableHighDpiScaling, true)
app := gui.NewQGuiApplication(len(os.Args), os.Args)
app.SetQuitOnLastWindowClosed(true)
app.ConnectLastWindowClosed(func() {
fmt.Println("Closing…")
for _, plugin := range plugins {
plugin.Close()
}
})
// quickcontrols2.QQuickStyle_SetStyle("universal")
view := qml.NewQQmlApplicationEngine(nil)
view.RootContext().SetContextProperty("PluginModel", model)
view.Load(core.NewQUrl3("qrc:/qml/main.qml", 0))
for _, plugin := range plugins {
plugin.StartUI(view)
}
gui.QGuiApplication_Exec()
}