allow change of image via rightclick. not finished

This commit is contained in:
lordwelch 2016-03-18 10:21:14 -07:00
parent ca47264f51
commit ba3ed7375b
3 changed files with 55 additions and 21 deletions

51
main.go
View File

@ -26,19 +26,19 @@ type cell struct {
type slide []*cell type slide []*cell
var ( var (
x0, y0, selSlide int x0, y0, selSlide, rhtClkCell int
path string path string
qimg qml.Object qimg qml.Object
textEdit qml.Object textEdit qml.Object
cellQml qml.Object cellQml qml.Object
window *qml.Window window *qml.Window
win *glfw.Window win *glfw.Window
slides slide slides slide
err error err error
monitors []*glfw.Monitor monitors []*glfw.Monitor
projMonitor *glfw.Monitor projMonitor *glfw.Monitor
tex1 uint32 tex1 uint32
texDel = false texDel = false
) )
func main() { func main() {
@ -244,8 +244,10 @@ func setSignals() {
}) })
window.On("closing", func() { window.On("closing", func() {
win.SetShouldClose(true) if false == window.Property("cls") {
window.Set("cls", true) win.SetShouldClose(true)
window.Set("cls", true)
}
}) })
@ -301,10 +303,21 @@ func (cl *cell) setSignal() {
} }
}) })
cl.qmlcell.ObjectByName("cellMouse").On("Clicked", func() { window.ObjectByName("mnuImgPick").On("triggered", func() {
cl.qmlcell.ObjectByName("cellMouse").Set("focus", true) url := window.Call("openFileDialog")
cl.qmlcell.ObjectByName("cellMouse").Call("selected") slides[rhtClkCell].img.Clear
}) slides[rhtClkCell].img.ReadImage(url)
})
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")
}
})
cl.qmlcell.ObjectByName("cellMouse").On("doubleClicked", func() { cl.qmlcell.ObjectByName("cellMouse").On("doubleClicked", func() {

View File

@ -16,10 +16,21 @@ ApplicationWindow {
height: 600 height: 600
property bool cls: false property bool cls: false
function openFileDialog() {
imgpicker.open()
return imgpicker.fileUrl
}
onClosing: if (!cls) { onClosing: if (!cls) {
close.accepted = false close.accepted = false
} }
FileDialog {
id: imgpicker
title: "Choose an image for this slide"
folder: shortcuts.pictures
}
AboutDialog { AboutDialog {
id: aboutDialog id: aboutDialog
} }
@ -48,6 +59,17 @@ ApplicationWindow {
} }
} }
Menu {
objectName: "mnuCtx"
title: "new image..."
MenuItem {
objectName: "mnuImgPick"
text: "new Image..."
}
}
SplitView { SplitView {
id: mainSlider id: mainSlider
objectName: "mainSlider" objectName: "mainSlider"

View File

@ -28,6 +28,7 @@ Rectangle {
enabled: true enabled: true
objectName: "cellMouse" objectName: "cellMouse"
anchors.fill: parent anchors.fill: parent
acceptedButtons: Qt.AllButtons
onMouseXChanged: if (containsMouse) { onMouseXChanged: if (containsMouse) {
parent.parent.border.color = "skyblue" parent.parent.border.color = "skyblue"
@ -44,13 +45,11 @@ Rectangle {
parent.parent.border.color = "black" parent.parent.border.color = "black"
parent.parent.color = "white" parent.parent.color = "white"
parent.color = "black" parent.color = "black"
MouseXChanged(mouse)
} }
function selected() { function selected() {
parent.parent.border.color = "blue" parent.parent.border.color = "blue"
parent.parent.color = "gainsboro" parent.parent.color = "gainsboro"
MouseXChanged(mouse)
} }
} }
} }