From b4ad828af405ffe8310c167dce316c2681930900 Mon Sep 17 00:00:00 2001 From: lordwelch Date: Thu, 18 Feb 2016 15:12:22 -0800 Subject: [PATCH] add highliting for the selected cell add button to add a cell --- main.go | 7 ++++++- main.qml | 16 ++++++++++++---- qml/AboutDialog.qml | 2 +- qml/cell.qml | 42 +++++++++++++++++++++++++----------------- 4 files changed, 44 insertions(+), 23 deletions(-) diff --git a/main.go b/main.go index 8b3c083..b37aed8 100644 --- a/main.go +++ b/main.go @@ -235,6 +235,10 @@ func glInit() { } func setSignals() { + window.ObjectByName("btnAdd").On("clicked", func() { + slides.addCell() + }) + window.On("closing", func() { fmt.Println(window.Bool("cls")) win.Hide() @@ -242,6 +246,7 @@ func setSignals() { window.Set("cls", true) }) + textEdit.ObjectByName("textEdit1").On("focusChanged", func(focus bool) { var ( str string @@ -294,7 +299,7 @@ func (sl *slide) addCell( /*cl *cell*/ ) { cl.text = "testing 1... 2... 3..." cl.qmlcell.ObjectByName("cellText").Set("text", cl.text) *sl = append(*sl, &cl) - + //fmt.Println("add Cell!!!!! :-P") cl.setSignal() } diff --git a/main.qml b/main.qml index 4300bd9..da1f5bb 100644 --- a/main.qml +++ b/main.qml @@ -13,7 +13,7 @@ ApplicationWindow { width: 1000 height: 600 property bool cls: false - //Screen.objectName: "Screen1" + onClosing: if (!cls) { close.accepted = false } @@ -63,8 +63,6 @@ ApplicationWindow { objectName: "gridRect" width: 300 color: "#00000000" - radius: 1 - border.color: "#000000" border.width: 4 anchors.left: parent.left anchors.leftMargin: 0 @@ -110,6 +108,7 @@ ApplicationWindow { Column { id: data2 + spacing: 1 objectName: "data2" anchors.fill: parent } @@ -119,6 +118,7 @@ ApplicationWindow { Rectangle { id: mainView + border.width: 0 objectName: "mainView" anchors.right: parent.right anchors.rightMargin: 0 @@ -129,6 +129,15 @@ ApplicationWindow { z: 1 clip: false visible: true + + Button { + id: button1 + objectName: "btnAdd" + x: 8 + y: 8 + text: qsTr("Button") + + } } } @@ -177,7 +186,6 @@ ApplicationWindow { TextArea { id: textEdit1 objectName: "textEdit1" - text: "Text Edit" anchors.fill: parent clip: true textFormat: Text.AutoText diff --git a/qml/AboutDialog.qml b/qml/AboutDialog.qml index f375d1c..77f6efa 100644 --- a/qml/AboutDialog.qml +++ b/qml/AboutDialog.qml @@ -43,6 +43,6 @@ import QtQuick.Dialogs 1.1 MessageDialog { icon: StandardIcon.Information text: "Presentation App for use in a church service" - detailedText: "made in 2016 by Timmy Welch" + detailedText: "Made in 2016 by Timmy Welch." title: "About" } diff --git a/qml/cell.qml b/qml/cell.qml index bbf0c5d..0e30ec4 100644 --- a/qml/cell.qml +++ b/qml/cell.qml @@ -9,10 +9,6 @@ Rectangle { border.width: 2 anchors.right: parent.right anchors.left: parent.left - onFocusChanged: if (focus) { - border.color = "gainsboro" - color = "blue" - } Text { id: cellText @@ -25,11 +21,7 @@ Rectangle { anchors.right: parent.right anchors.rightMargin: 0 anchors.left: parent.left - anchors.leftMargin: 0 - onFocusChanged: if (focus) { - parent.border.color = "gainsboro" - parent.color = "blue" - } + anchors.leftMargin: 2 MouseArea { id: cellMouse @@ -38,19 +30,35 @@ Rectangle { objectName: "cellMouse" anchors.fill: parent onFocusChanged: if (focus) { - parent.parent.border.color = "gainsboro" - parent.parent.color = "blue" + selected() } - onClicked: focus = true - onEntered: if (containsMouse) { - parent.parent.border.color = "skyblue" - parent.parent.color = "darkblue" - parent.color = "white" - } + + onClicked: { + focus = true + selected() + mouseXChanged(mouse) + } + + onMouseXChanged: if (containsMouse) { + parent.parent.border.color = "skyblue" + parent.parent.color = "darkblue" + parent.color = "white" + } else if (focus) { + parent.color = "black" + } + onExited: { parent.parent.border.color = "white" parent.parent.color = "white" parent.color = "black" + if (focus) { + focusChanged(focus) + } + } + + function selected() { + parent.parent.border.color = "blue" + parent.parent.color = "gainsboro" } } }