diff --git a/main.go b/main.go index 6bfd1de..c151903 100644 --- a/main.go +++ b/main.go @@ -11,12 +11,11 @@ import ( "fmt" "git.openprivacy.ca/openprivacy/libricochet-go/connectivity" "git.openprivacy.ca/openprivacy/libricochet-go/log" + "github.com/therecipe/qt/gui" "github.com/therecipe/qt/core" "github.com/therecipe/qt/network" "github.com/therecipe/qt/qml" - "github.com/therecipe/qt/quick" "github.com/therecipe/qt/quickcontrols2" - "github.com/therecipe/qt/widgets" "os" "os/user" "path" @@ -47,14 +46,16 @@ func main() { 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 - view := initializeQtView() + view := initializeQtView(qmlSource) // variables we want to access from inside qml view.RootContext().SetContextProperty("gcd", gcd) - // this actually loads the qml - view.SetSource(qmlSource) acn, err := connectivity.StartTor(the.CwtchDir, "") if err != nil { @@ -84,26 +85,18 @@ func main() { //}) return nam }) - view.Engine().SetNetworkAccessManagerFactory(factory) - - // here we go! - view.Show() - widgets.QApplication_Exec() + view.SetNetworkAccessManagerFactory(factory) + app.Exec() acn.Close() } // window construction boilerplate -func initializeQtView() *quick.QQuickView { +func initializeQtView(source *core.QUrl) *qml.QQmlApplicationEngine { core.QCoreApplication_SetAttribute(core.Qt__AA_EnableHighDpiScaling, true) - widgets.NewQApplication(len(os.Args), os.Args) quickcontrols2.QQuickStyle_SetStyle("Universe") - view := quick.NewQQuickView(nil) - view.SetResizeMode(quick.QQuickView__SizeRootObjectToView) - //view.SetMinimumHeight(800) // these end up getting overridden by main.qml - //view.SetMinimumWidth(1200) - view.SetTitle("cwtch") - - return view + engine := qml.NewQQmlApplicationEngine(nil) + engine.Load(source) + return engine } // this is mostly going to get factored out when we add profile support diff --git a/qml/images/cwtch-icon.png b/qml/images/cwtch-icon.png new file mode 100644 index 0000000..37bcf0f Binary files /dev/null and b/qml/images/cwtch-icon.png differ diff --git a/qml/main.qml b/qml/main.qml index 6f3f312..a07ef67 100644 --- a/qml/main.qml +++ b/qml/main.qml @@ -11,10 +11,15 @@ import "panes" import "widgets" import "utils.js" as Utils -Item { + +ApplicationWindow { id: windowItem width: 1200 height: 800 + visible: true + title: "cwtch" + "" + + readonly property real ratio: height / width