fixed cellqml and add a textbox for editing slide text

This commit is contained in:
lordwelch 2016-01-19 21:12:11 -08:00
parent a8aca389b4
commit e53b352a63
3 changed files with 106 additions and 18 deletions

View File

@ -6,13 +6,14 @@ Rectangle {
property int index: 0
width: 100
height: 100
/*anchors.right: parent
anchors.left: parent*/
color: "#00000000"
anchors.right: parent.right
anchors.left: parent.left
Text {
id: cellText
enabled: true
objectName: "celltext"
objectName: "cellText"
height: 75
text: "hello this is text\nhaha\nhdsjfklfhaskjd"
textFormat: Text.AutoText

52
main.go
View File

@ -24,6 +24,7 @@ var (
cellQml qml.Object
window *qml.Window
slides slide
err error
)
func main() {
@ -35,7 +36,7 @@ func main() {
func run() error {
engine := qml.NewEngine()
path, err := osext.ExecutableFolder()
path, err = osext.ExecutableFolder()
path = filepath.Clean(path + "/../src/github.com/lordwelch/PresentationApp/")
fmt.Println(path)
mainQml, err := engine.LoadFile(path + "/main.qml")
@ -43,34 +44,59 @@ func run() error {
return err
}
cellQml, err := engine.LoadFile(path + "/cell.qml")
cellQml, err = engine.LoadFile(path + "/cell.qml")
if err != nil {
return err
}
fmt.Println("ignore", cellQml)
qml.RunMain(slides.addCell())
window = mainQml.CreateWindow(nil)
slides.addCell()
window.Show()
window.Wait()
return nil
}
func (cl *cell) setSignals() {
cl.qmlcell.ObjectByName("cellMouse").On("doubleClicked", func() {
cellText := cl.qmlcell.ObjectByName("cellText")
textEdit := window.ObjectByName("textEdit")
textEdit.Set("x", cellText.Int("x")+4)
textEdit.Set("y", cellText.Int("y")+4)
textEdit.Set("width", cellText.Int("width"))
textEdit.Set("height", cellText.Int("height"))
textEdit.Set("opacity", 100)
textEdit.Set("visible", true)
textEdit.Set("focus", true)
textEdit.Set("enabled", true) /*
fmt.Println(textEdit.Int("x"))
fmt.Println(textEdit.Int("y"))
fmt.Println(textEdit.Int("width"))
fmt.Println(textEdit.Int("height"))*/
})
}
func (sl *slide) addCell( /*cl *cell*/ ) {
var cl cell
cl.index = len(*sl)
fmt.Println("index: ", cl.index)
cl.qmlcell = cellQml.Create(nil)
fmt.Println("index: ", cl.index)
fmt.Println(cl.qmlcell.ObjectByName("celltext").Property("text"))
cl.qmlcell.Set("objectName", fmt.Sprintf("cellRect&d", cl.index))
cl.qmlcell.Set("parent", window.ObjectByName("data1"))
cl.index = len(*sl)
cl.text = "testing 1... 2... 3..."
fmt.Println(cl)
//*sl = append(*sl, *cl)
//*sl[0] //.qmlcell.Set("parent", window.ObjectByName("data1"))
cl.qmlcell.ObjectByName("cellText").Set("text", cl.text)
*sl = append(*sl, cl)
cl.setSignals()
fmt.Print((*sl)[len(*sl)-1])
}
func (cl *cell) String() string {
return fmt.Sprint("Index: %T \nText: %T", cl.index, cl.text)
func (cl cell) String() string {
return fmt.Sprintf("Index: %T \nText: %T\n", cl.index, cl.text)
}
func (cl cell) GoString() string {
return cl.String()
}

View File

@ -8,9 +8,40 @@ ApplicationWindow {
objectName: "applicationWindow1"
minimumWidth: 500
minimumHeight: 500
property int globalForJs: 10
width: 1000
height: 600
menuBar: MenuBar {
Menu {
title: "&File"
MenuItem {
}
MenuItem {
text: "Close"
shortcut: StandardKey.Quit
}
}
Menu {
title: "&Edit"
MenuItem {
//action: cutAction
}
MenuItem {
//action: copyAction
}
MenuItem {
//action: pasteAction
}
}
Menu {
title: "&Help"
MenuItem {
//action: aboutAction
}
}
}
SplitView {
id: mainSlider
objectName: "mainSlider"
@ -66,7 +97,6 @@ ApplicationWindow {
anchors.top: parent.top
anchors.left: parent.left
//onAdded: children.width = data1.width
}
}
@ -99,4 +129,35 @@ ApplicationWindow {
visible: true
}
}
Rectangle {
id: textEdit
x: 448
y: 151
objectName: "textEdit"
width: 200
height: 200
color: "#ffffff"
visible: false
Keys.onEscapePressed: {
x = -100
y = -100
visible = false
focus = false
enabled = false
opacity = 0
}
TextArea {
id: textEdit1
objectName: "textEdit1"
text: qsTr("Text Edit")
anchors.fill: parent
clip: true
textFormat: Text.AutoText
visible: true
font.pixelSize: 12
z: 99
}
}
}