Commit ed5afdfc authored by Black Hat's avatar Black Hat

Move UI into a package.

parent 77c3fedd
package db
type Controller struct {
}
...@@ -6,6 +6,7 @@ import ( ...@@ -6,6 +6,7 @@ import (
"github.com/therecipe/qt/core" "github.com/therecipe/qt/core"
"github.com/therecipe/qt/gui" "github.com/therecipe/qt/gui"
"github.com/therecipe/qt/qml" "github.com/therecipe/qt/qml"
"matrique/ui"
) )
func main() { func main() {
...@@ -14,14 +15,14 @@ func main() { ...@@ -14,14 +15,14 @@ func main() {
gui.NewQGuiApplication(len(os.Args), os.Args) gui.NewQGuiApplication(len(os.Args), os.Args)
Controller_QmlRegisterType2("Matrique", 0, 1, "Controller") ui.Controller_QmlRegisterType2("Matrique", 0, 1, "Controller")
RoomListModel_QmlRegisterType2("Matrique", 0, 1, "RoomListModel") ui.RoomListModel_QmlRegisterType2("Matrique", 0, 1, "RoomListModel")
var app = qml.NewQQmlApplicationEngine(nil) var app = qml.NewQQmlApplicationEngine(nil)
pro := NewImageProvider(nil) pro := ui.NewImageProvider(nil)
pro.Init() pro.Init()
app.AddImageProvider("mxc", pro.provider) app.AddImageProvider("mxc", pro.GetProvider())
app.RootContext().SetContextProperty("imageProvider", pro) app.RootContext().SetContextProperty("imageProvider", pro)
......
package main package ui
import ( import (
"fmt" "fmt"
......
package main package ui
import ( import (
"fmt" "fmt"
...@@ -83,3 +83,7 @@ func (ip *ImageProvider) Init() { ...@@ -83,3 +83,7 @@ func (ip *ImageProvider) Init() {
func (ip *ImageProvider) setServerAddr(addr string) { func (ip *ImageProvider) setServerAddr(addr string) {
ip.serverAddr = addr ip.serverAddr = addr
} }
func (ip *ImageProvider) GetProvider() *quick.QQuickImageProvider {
return ip.provider
}
package main package ui
import ( import (
"github.com/therecipe/qt/core" "github.com/therecipe/qt/core"
......
package main package ui
import ( import (
"github.com/therecipe/qt/core" "github.com/therecipe/qt/core"
......
package main package ui
func checkErr(err error) { func checkErr(err error) {
if err != nil { if err != nil {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment