diff --git a/main.go b/main.go index ab6954b..f6e39df 100644 --- a/main.go +++ b/main.go @@ -8,6 +8,7 @@ import ( "os" "path/filepath" "runtime/debug" + "strings" "github.com/go-gl/gl/v2.1/gl" "github.com/go-gl/glfw/v3.1/glfw" @@ -39,8 +40,8 @@ var ( err error monitors []*glfw.Monitor projMonitor *glfw.Monitor - tex1 *uint32 - texDel, quickEdit Bool = false, false + tex1 *uint32 + texDel, quickEdit Bool = false, false ) func main() { @@ -300,7 +301,8 @@ func (cl *cell) setSignal() { cl.qmlcell.ObjectByName("cellMouse").On("clicked", func(musEvent qml.Object) { btn := musEvent.Property("button") if btn == 2 { - //cl.qmlcell.ObjectByName("cellMouse").Call("rightClicked") + window.ObjectByName("mnuCtx").Call("popup") + rhtClkCell = cl.index } else { selSlide = cl.qmlcell.Int("index") cl.qmlcell.ObjectByName("cellMouse").Set("focus", true) @@ -317,20 +319,16 @@ func (cl *cell) setSignal() { } }) - window.ObjectByName("mnuImgPick").On("triggered", func() { - url := window.Call("openFileDialog") - slides[rhtClkCell].img.Clear - slides[rhtClkCell].img.ReadImage(url) - }) + window.ObjectByName("imgpicker").On("accepted", func() { + //url := window.Call("getFileDialogUrl") + url := filepath.Clean(strings.Replace(window.ObjectByName("imgpicker").String("fileUrl"), "file:","",1)) - cl.qmlcell.ObjectByName("cellMouse").On("clicked", func(mouse qml.Object) { - if mouse.Property("button") == 2 { - window.ObjectByName("mnuCtx").Call("popup") - rhtell = cl.index - } else { - cl.qmlcell.ObjectByName("cellMouse").Set("focus", true) - cl.qmlcell.ObjectByName("cellMouse").Call("selected") - } + slides[rhtClkCell].img.Clear() + slides[rhtClkCell].img.ReadImage(url) + fmt.Println(url) + setupScene() + + fmt.Println(window.ObjectByName("imgpicker").String("fileUrl")) }) cl.qmlcell.ObjectByName("cellMouse").On("doubleClicked", func() { diff --git a/main.qml b/main.qml index 90e288f..48096d1 100644 --- a/main.qml +++ b/main.qml @@ -16,10 +16,9 @@ ApplicationWindow { height: 600 property bool cls: false - function openFileDialog() { - imgpicker.open() - return imgpicker.fileUrl - } + /*function getFileDialogUrl() { + return + }*/ onClosing: if (!cls) { close.accepted = false @@ -28,7 +27,7 @@ ApplicationWindow { FileDialog { id: imgpicker title: "Choose an image for this slide" - folder: shortcuts.pictures + objectName: "imgpicker" } AboutDialog { @@ -44,8 +43,6 @@ ApplicationWindow { menuBar: MenuBar { Menu { title: "&File" - MenuItem { - } MenuItem { text: "Close" shortcut: StandardKey.Quit @@ -74,6 +71,7 @@ ApplicationWindow { MenuItem { objectName: "mnuImgPick" text: "new Image..." + onTriggered: imgpicker.open() } }