Window
This commit is contained in:
parent
cbdd329161
commit
788a623b01
31
main.go
31
main.go
|
@ -11,12 +11,11 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"git.openprivacy.ca/openprivacy/libricochet-go/connectivity"
|
"git.openprivacy.ca/openprivacy/libricochet-go/connectivity"
|
||||||
"git.openprivacy.ca/openprivacy/libricochet-go/log"
|
"git.openprivacy.ca/openprivacy/libricochet-go/log"
|
||||||
|
"github.com/therecipe/qt/gui"
|
||||||
"github.com/therecipe/qt/core"
|
"github.com/therecipe/qt/core"
|
||||||
"github.com/therecipe/qt/network"
|
"github.com/therecipe/qt/network"
|
||||||
"github.com/therecipe/qt/qml"
|
"github.com/therecipe/qt/qml"
|
||||||
"github.com/therecipe/qt/quick"
|
|
||||||
"github.com/therecipe/qt/quickcontrols2"
|
"github.com/therecipe/qt/quickcontrols2"
|
||||||
"github.com/therecipe/qt/widgets"
|
|
||||||
"os"
|
"os"
|
||||||
"os/user"
|
"os/user"
|
||||||
"path"
|
"path"
|
||||||
|
@ -47,14 +46,16 @@ func main() {
|
||||||
qmlSource = core.NewQUrl3("qrc:/qml/main.qml", 0)
|
qmlSource = core.NewQUrl3("qrc:/qml/main.qml", 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
app := gui.NewQGuiApplication(len(os.Args), os.Args)
|
||||||
|
app.SetWindowIcon(gui.NewQIcon5(":/qml/images/cwtch-icon.png"))
|
||||||
|
|
||||||
// window construction boilerplate
|
// window construction boilerplate
|
||||||
view := initializeQtView()
|
view := initializeQtView(qmlSource)
|
||||||
|
|
||||||
// variables we want to access from inside qml
|
// variables we want to access from inside qml
|
||||||
view.RootContext().SetContextProperty("gcd", gcd)
|
view.RootContext().SetContextProperty("gcd", gcd)
|
||||||
|
|
||||||
// this actually loads the qml
|
|
||||||
view.SetSource(qmlSource)
|
|
||||||
|
|
||||||
acn, err := connectivity.StartTor(the.CwtchDir, "")
|
acn, err := connectivity.StartTor(the.CwtchDir, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -84,26 +85,18 @@ func main() {
|
||||||
//})
|
//})
|
||||||
return nam
|
return nam
|
||||||
})
|
})
|
||||||
view.Engine().SetNetworkAccessManagerFactory(factory)
|
view.SetNetworkAccessManagerFactory(factory)
|
||||||
|
app.Exec()
|
||||||
// here we go!
|
|
||||||
view.Show()
|
|
||||||
widgets.QApplication_Exec()
|
|
||||||
acn.Close()
|
acn.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
// window construction boilerplate
|
// window construction boilerplate
|
||||||
func initializeQtView() *quick.QQuickView {
|
func initializeQtView(source *core.QUrl) *qml.QQmlApplicationEngine {
|
||||||
core.QCoreApplication_SetAttribute(core.Qt__AA_EnableHighDpiScaling, true)
|
core.QCoreApplication_SetAttribute(core.Qt__AA_EnableHighDpiScaling, true)
|
||||||
widgets.NewQApplication(len(os.Args), os.Args)
|
|
||||||
quickcontrols2.QQuickStyle_SetStyle("Universe")
|
quickcontrols2.QQuickStyle_SetStyle("Universe")
|
||||||
view := quick.NewQQuickView(nil)
|
engine := qml.NewQQmlApplicationEngine(nil)
|
||||||
view.SetResizeMode(quick.QQuickView__SizeRootObjectToView)
|
engine.Load(source)
|
||||||
//view.SetMinimumHeight(800) // these end up getting overridden by main.qml
|
return engine
|
||||||
//view.SetMinimumWidth(1200)
|
|
||||||
view.SetTitle("cwtch")
|
|
||||||
|
|
||||||
return view
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// this is mostly going to get factored out when we add profile support
|
// this is mostly going to get factored out when we add profile support
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 4.0 KiB |
|
@ -11,10 +11,15 @@ import "panes"
|
||||||
import "widgets"
|
import "widgets"
|
||||||
import "utils.js" as Utils
|
import "utils.js" as Utils
|
||||||
|
|
||||||
Item {
|
|
||||||
|
ApplicationWindow {
|
||||||
id: windowItem
|
id: windowItem
|
||||||
width: 1200
|
width: 1200
|
||||||
height: 800
|
height: 800
|
||||||
|
visible: true
|
||||||
|
title: "cwtch" + ""
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
readonly property real ratio: height / width
|
readonly property real ratio: height / width
|
||||||
|
|
||||||
|
|
Reference in New Issue