add qlobal qml var for songEdit.qml

This commit is contained in:
lordwelch 2016-05-09 09:11:56 -07:00
parent 5531714b99
commit 7fe593a4ef
4 changed files with 36 additions and 26 deletions

View File

@ -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 {

View File

@ -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

12
qml.go
View File

@ -21,12 +21,19 @@ 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)
@ -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)
}

View File

@ -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")