2016-01-11 09:10:52 -08:00
|
|
|
// PresentationApp project main.go
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2016-01-14 22:25:53 -08:00
|
|
|
//"image"
|
2016-01-14 15:30:14 -08:00
|
|
|
"os"
|
2016-01-14 18:42:52 -08:00
|
|
|
"path/filepath"
|
2016-01-14 15:30:14 -08:00
|
|
|
|
|
|
|
"github.com/kardianos/osext"
|
|
|
|
"gopkg.in/qml.v1"
|
2016-01-11 09:10:52 -08:00
|
|
|
)
|
|
|
|
|
2016-01-14 22:25:53 -08:00
|
|
|
type cell struct {
|
|
|
|
text string
|
|
|
|
//img image.Image
|
|
|
|
qmlcell qml.Object
|
|
|
|
index int
|
|
|
|
}
|
|
|
|
|
2016-01-14 18:42:52 -08:00
|
|
|
var (
|
2016-01-14 22:25:53 -08:00
|
|
|
path string
|
|
|
|
cellQml qml.Object
|
|
|
|
window *qml.Window
|
|
|
|
slides []cell
|
2016-01-14 18:42:52 -08:00
|
|
|
)
|
|
|
|
|
2016-01-11 09:10:52 -08:00
|
|
|
func main() {
|
2016-01-14 15:30:14 -08:00
|
|
|
if err := qml.Run(run); err != nil {
|
|
|
|
fmt.Fprintf(os.Stderr, "error: %v\n", err)
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func run() error {
|
|
|
|
engine := qml.NewEngine()
|
|
|
|
path, err := osext.ExecutableFolder()
|
2016-01-14 18:42:52 -08:00
|
|
|
path = filepath.Clean(path + "/../src/github.com/lordwelch/PresentationApp/")
|
|
|
|
fmt.Println(path)
|
|
|
|
mainQml, err := engine.LoadFile(path + "/main.qml")
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
cellQml, err := engine.LoadFile(path + "/cell.qml")
|
2016-01-14 15:30:14 -08:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2016-01-14 22:25:53 -08:00
|
|
|
window = mainQml.CreateWindow(nil)
|
2016-01-14 15:30:14 -08:00
|
|
|
|
|
|
|
window.Show()
|
|
|
|
window.Wait()
|
|
|
|
return nil
|
2016-01-11 09:10:52 -08:00
|
|
|
}
|
2016-01-14 22:25:53 -08:00
|
|
|
|
|
|
|
func (cl *cell) addCell() {
|
|
|
|
cl.index = len(slides)
|
|
|
|
cl.qmlcell = cellQml.Create(nil)
|
|
|
|
fmt.Println(cl.qmlcell.ObjectByName("celltext").Property("text"))
|
|
|
|
cl.text = "testing 1... 2... 3..."
|
|
|
|
fmt.Println(cl)
|
|
|
|
slides = append(slides, *cl)
|
|
|
|
slides[cl.index].qmlcell.Set("parent", window.ObjectByName("data1"))
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
func (cl *cell) String() string {
|
|
|
|
return fmt.Sprint("Index: %T \nText: %T", cl.index, cl.text)
|
|
|
|
}
|