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

View File

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

View File

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