-
Notifications
You must be signed in to change notification settings - Fork 4
/
main.go
75 lines (60 loc) · 1.66 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
package main
import (
"github.com/WolfgangMau/chamgo-qt/config"
"github.com/therecipe/qt/widgets"
"log"
"os"
)
//Global Variables - StateStorage
var AppName = "Chamgo-QT"
var Cfg config.Config
var Statusbar *widgets.QStatusBar
var DeviceActions config.DeviceActions
var MyTabs *widgets.QTabWidget
var TagA QTbytes
var TagB QTbytes
func initcfg() {
if _, err := getSerialPorts(); err != nil {
log.Println(err)
}
Cfg.Load()
dn := Cfg.Device[SelectedDeviceId].Name
DeviceActions.Load(Cfg.Device[SelectedDeviceId].CmdSet, dn)
}
func main() {
var f *os.File
log.SetFlags(log.LstdFlags | log.Lshortfile)
f, err := os.OpenFile(config.Apppath()+string(os.PathSeparator)+"chamgo-qt.log", os.O_RDWR|os.O_CREATE|os.O_APPEND, 0644)
if err != nil {
log.Printf("error opening file: %v", err)
}
defer f.Close()
log.SetOutput(f)
initcfg()
AppName = Cfg.Gui.Title
log.SetFlags(log.LstdFlags | log.Lshortfile)
Connected = false
app := widgets.NewQApplication(len(os.Args), os.Args)
window := widgets.NewQMainWindow(nil, 0)
window.SetWindowTitle(AppName)
window.SetFixedSize2(1100, 600)
mainlayout := widgets.NewQVBoxLayout()
MyTabs = widgets.NewQTabWidget(nil)
MyTabs.AddTab(allSlots(), "Tags")
MyTabs.AddTab(serialTab(), "Device")
MyTabs.AddTab(dataTab(), "Data")
MyTabs.SetCurrentIndex(2)
mainlayout.AddWidget(MyTabs, 0, 0x0020)
mainlayout.SetAlign(33)
mainWidget := widgets.NewQWidget(nil, 0)
mainWidget.SetLayout(mainlayout)
window.SetCentralWidget(mainWidget)
Statusbar = widgets.NewQStatusBar(window)
Statusbar.ShowMessage("not Connected", 0)
window.SetStatusBar(Statusbar)
checkForDevices()
// Show the window
window.Show()
// Execute app
app.Exec()
}