forked from fibercrypto/fibercryptowallet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
65 lines (54 loc) · 2.32 KB
/
Copy pathmain.go
File metadata and controls
65 lines (54 loc) · 2.32 KB
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
package main
import (
"os"
_ "github.com/fibercrypto/fibercryptowallet/src/coin/skycoin"
_ "github.com/fibercrypto/fibercryptowallet/src/models"
_ "github.com/fibercrypto/fibercryptowallet/src/models/addressBook"
_ "github.com/fibercrypto/fibercryptowallet/src/models/history"
_ "github.com/fibercrypto/fibercryptowallet/src/models/pending"
"github.com/therecipe/qt/core"
"github.com/therecipe/qt/gui"
"github.com/therecipe/qt/qml"
"github.com/therecipe/qt/widgets"
)
func main() {
// Enable High DPI scaling
core.QCoreApplication_SetAttribute(core.Qt__AA_EnableHighDpiScaling, true)
// Create a Qt Application
// On embedded devices, a `QGuiApplication` must be used instead
app := widgets.NewQApplication(len(os.Args), os.Args)
// Setup the splash screen
splashPixmap := gui.NewQPixmap3(":/images/resources/images/icons/appIcon/splash.png", "", core.Qt__AutoColor)
splash := widgets.NewQSplashScreen(splashPixmap, core.Qt__SplashScreen)
splash.Show()
// Process the pending `show` event
app.QCoreApplication.ProcessEvents(core.QEventLoop__AllEvents)
// Set the application information
app.SetOrganizationName("Simelo.Tech")
app.SetOrganizationDomain("simelo.tech")
app.SetApplicationName("FiberCryptoWallet")
app.SetApplicationVersion("0.27.0")
app.SetWindowIcon(gui.NewQIcon5(":/images/resources/images/icons/appIcon/appIcon.png"))
// Add this monospaced font
gui.QFontDatabase_AddApplicationFont(":/fonts/resources/fonts/code-new-roman/code-new-roman.otf")
engine := qml.NewQQmlApplicationEngine(nil)
// To speed up UI development, loading QML files from resources is disabled, but it must be re-enabled in order to make a release
// url := core.NewQUrl3("qrc:/ui/src/ui/main.qml", 0)
url := core.NewQUrl3("src/ui/main.qml", 0) // disable this to make a release
// TODO: Find a way to use a `core.Qt__QueuedConnection`, so we can remove the flag `allOk`
allOk := true
engine.ConnectObjectCreated(func(object *core.QObject, objUrl *core.QUrl) {
if object.Pointer() == nil && url.ToString(0) == objUrl.ToString(0) {
allOk = false
app.Exit(-1) // Ignored because we need a `core.Qt__QueuedConnection`
}
})
engine.Load(url)
splash.QWidget.Close()
// A `core.Qt__QueuedConnection` will allows us to remove the condition bellow, leaving only `app.Exec()`
if allOk == true {
app.Exec()
} else {
app.Exit(-1)
}
}