From 7fe593a4ef3988ee088380284739be684b68d826 Mon Sep 17 00:00:00 2001 From: lordwelch Date: Mon, 9 May 2016 09:11:56 -0700 Subject: [PATCH] add qlobal qml var for songEdit.qml --- imagick.go | 3 ++- main.go | 8 ++++---- qml.go | 20 +++++++++++++------- qml/songEdit.qml | 31 +++++++++++++++++-------------- 4 files changed, 36 insertions(+), 26 deletions(-) diff --git a/imagick.go b/imagick.go index ebf3264..3579916 100644 --- a/imagick.go +++ b/imagick.go @@ -160,7 +160,8 @@ func findfonts() { if err != nil { log.Print(err) } - fontlst = strings.Split(out.String(), "\n") + QML.FontList = strings.Split(out.String(), "\n") + QML.FontLen = len(QML.FontList) } func round(a float64) int { diff --git a/main.go b/main.go index a349ff8..2995511 100644 --- a/main.go +++ b/main.go @@ -63,9 +63,11 @@ func main() { func run() error { imagick.Initialize() - findfonts() engine = qml.NewEngine() + QML = &qmlVar{} + engine.Context().SetVar("go", QML) + findfonts() engine.AddImageProvider("images", imgProvider) //path for qml files TODO: change to somewhere else path, err = osext.ExecutableFolder() @@ -92,7 +94,7 @@ func run() error { } window = mainQml.CreateWindow(engine.Context()) - window2 := edtQml.CreateWindow(engine.Context()) + window2 = edtQml.CreateWindow(engine.Context()) textEdit = window.ObjectByName("textEdit") //signals for whole qml @@ -100,8 +102,6 @@ func run() error { slides.add() //var from GO to qml - QML = &qmlVar{} - engine.Context().SetVar("GO", QML) //image is ready for imageprovider imgready = true diff --git a/qml.go b/qml.go index d80812d..10bda7f 100644 --- a/qml.go +++ b/qml.go @@ -21,17 +21,24 @@ var ( edtQml qml.Object textEdit qml.Object window *qml.Window + window2 *qml.Window engine *qml.Engine quickEdit Bool = false imgready Bool = false - QML qmlVar + QML *qmlVar ) +func initQML() { + window2.ObjectByName("textClrDialog").On("accepted", func() { + window2.ObjectByName("textClrDialog").Color("color") + }) +} + func (qv *qmlVar) Changed() { - qml.Changed(qv,qv.VerseLen) - qml.Changed(qv,qv.OrderLen) - qml.Changed(qv,qv.ImgLen) - qml.Changed(qv,qv.FontLen) + qml.Changed(qv, qv.VerseLen) + qml.Changed(qv, qv.OrderLen) + qml.Changed(qv, qv.ImgLen) + qml.Changed(qv, qv.FontLen) } //signals for the cell and image in qml @@ -164,8 +171,7 @@ func setSignals() { } func edtQmlShow() { - var slc *[]string - edtQml.Common.ObjectByName("fontPicker").List("model").Convert(slc) + slc := window2.ObjectByName("fontPicker").Property("model") fmt.Println(slc) } diff --git a/qml/songEdit.qml b/qml/songEdit.qml index e2da5e6..ccf6e89 100644 --- a/qml/songEdit.qml +++ b/qml/songEdit.qml @@ -82,7 +82,8 @@ ApplicationWindow { Layout.alignment: Qt.AlignLeft | Qt.AlignTop } ListView { - id: listView1 + id: lstVerses + objectName: "lstVerses" clip: true highlight: Rectangle { color: "lightsteelblue" @@ -94,7 +95,7 @@ ApplicationWindow { focus: true keyNavigationWraps: true boundsBehavior: Flickable.StopAtBounds - model: GO.verseLen + model: go.verseLen delegate: Item { x: 5 @@ -102,7 +103,7 @@ ApplicationWindow { height: 40 Text { - text: GO.verses(index) + text: go.verses(index) anchors.verticalCenter: parent.verticalCenter font.bold: true } @@ -121,7 +122,8 @@ ApplicationWindow { Layout.alignment: Qt.AlignLeft | Qt.AlignTop } ListView { - id: listView2 + id: lstOrder + objectName: "lstOrder" clip: true highlight: Rectangle { color: "lightsteelblue" @@ -131,14 +133,14 @@ ApplicationWindow { Layout.fillHeight: true Layout.alignment: Qt.AlignLeft | Qt.AlignTop boundsBehavior: Flickable.StopAtBounds - model: GO.orderLen + model: go.orderLen delegate: Item { x: 5 width: 80 height: 40 Text { - text: GO.verseOrder(index) + text: go.verseOrder(index) anchors.verticalCenter: parent.verticalCenter font.bold: true } @@ -181,18 +183,18 @@ ApplicationWindow { id: fontPicker objectName: "fontPicker" Layout.alignment: Qt.AlignLeft | Qt.AlignTop - model: GO.fontLen + model: go.fontLen // @disable-check M16 /*delegate:Text { - text: GO.fontList(index) + text: go.fontList(index) }*/ } SpinBox { id: fontSize - Layout.alignment: Qt.AlignLeft | Qt.AlignTop objectName: "fontSize" + Layout.alignment: Qt.AlignLeft | Qt.AlignTop maximumValue: 1000 value: 1 suffix: "Pt" @@ -220,24 +222,25 @@ ApplicationWindow { ComboBox { id: versePicker objectName: "versePicker" - model: GO.verseLen + model: go.verseLen // @disable-check M16 /* delegate: Text { - text: GO.verses(index) + text: go.verses(index) }*/ } ComboBox { id: imgPicker objectName: "imgPicker" - model: GO.imgLen + model: go.imgLen // @disable-check M16 /*delegate: Text { - text: GO.img(index) + text: go.img(index) }*/ } TextArea { - id: textEdit1 + id: txtVerse + objectName: "txtVerse" width: 80 height: 20 text: qsTr("Text Edit")