Merge branch 'master' of github.com:/lordwelch/PresentationApp
This commit is contained in:
commit
c351d10cb9
@ -4,13 +4,16 @@ package main
|
|||||||
import (
|
import (
|
||||||
"image"
|
"image"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
var imgready = false
|
var imgready = false
|
||||||
|
|
||||||
func imgProvider(id string, width, height int) image.Image {
|
func imgProvider(id string, width, height int) image.Image {
|
||||||
if imgready {
|
if imgready && (len(id) > 0) {
|
||||||
i, _ := strconv.Atoi(id)
|
//fmt.Println("source (provider): ", id)
|
||||||
|
i1 := strings.Index(id, `;`)
|
||||||
|
i, _ := strconv.Atoi(id[:i1])
|
||||||
return slides[i].getImage(width, height)
|
return slides[i].getImage(width, height)
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
27
main.go
27
main.go
@ -10,6 +10,8 @@ import (
|
|||||||
"runtime/debug"
|
"runtime/debug"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"strconv"
|
||||||
|
|
||||||
"github.com/go-gl/gl/v2.1/gl"
|
"github.com/go-gl/gl/v2.1/gl"
|
||||||
"github.com/go-gl/glfw/v3.1/glfw"
|
"github.com/go-gl/glfw/v3.1/glfw"
|
||||||
"github.com/kardianos/osext"
|
"github.com/kardianos/osext"
|
||||||
@ -306,9 +308,9 @@ func (cl *cell) setSignal() {
|
|||||||
} else {
|
} else {
|
||||||
selSlide = cl.qmlcell.Int("index")
|
selSlide = cl.qmlcell.Int("index")
|
||||||
cl.qmlcell.ObjectByName("cellMouse").Set("focus", true)
|
cl.qmlcell.ObjectByName("cellMouse").Set("focus", true)
|
||||||
cl.img.FlipImage()
|
|
||||||
setupScene()
|
setupScene()
|
||||||
}
|
}
|
||||||
|
cl.clearcache()
|
||||||
})
|
})
|
||||||
|
|
||||||
cl.qmlcell.ObjectByName("cellMouse").On("focusChanged", func(focus bool) {
|
cl.qmlcell.ObjectByName("cellMouse").On("focusChanged", func(focus bool) {
|
||||||
@ -321,14 +323,12 @@ func (cl *cell) setSignal() {
|
|||||||
|
|
||||||
window.ObjectByName("imgpicker").On("accepted", func() {
|
window.ObjectByName("imgpicker").On("accepted", func() {
|
||||||
//url := window.Call("getFileDialogUrl")
|
//url := window.Call("getFileDialogUrl")
|
||||||
url := filepath.Clean(strings.Replace(window.ObjectByName("imgpicker").String("fileUrl"), "file:","",1))
|
url := filepath.Clean(strings.Replace(window.ObjectByName("imgpicker").String("fileUrl"), "file:", "", 1))
|
||||||
|
|
||||||
slides[rhtClkCell].img.Clear()
|
slides[rhtClkCell].img.Clear()
|
||||||
slides[rhtClkCell].img.ReadImage(url)
|
slides[rhtClkCell].img.ReadImage(url)
|
||||||
fmt.Println(url)
|
|
||||||
setupScene()
|
setupScene()
|
||||||
|
cl.clearcache()
|
||||||
fmt.Println(window.ObjectByName("imgpicker").String("fileUrl"))
|
|
||||||
})
|
})
|
||||||
|
|
||||||
cl.qmlcell.ObjectByName("cellMouse").On("doubleClicked", func() {
|
cl.qmlcell.ObjectByName("cellMouse").On("doubleClicked", func() {
|
||||||
@ -349,6 +349,18 @@ func (cl *cell) setSignal() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (cl *cell) clearcache() {
|
||||||
|
str := cl.qmlimg.String("source")
|
||||||
|
//fmt.Println("source (click): ", str)
|
||||||
|
i := strings.Index(str, `;`)
|
||||||
|
str1 := str[:i]
|
||||||
|
//fmt.Println("ext (click): ", str1)
|
||||||
|
i1, _ := strconv.Atoi(str[i+1:])
|
||||||
|
str = str1 + `;` + strconv.Itoa(i1+1)
|
||||||
|
//fmt.Println("new source (click): ", str)
|
||||||
|
cl.qmlimg.Set("source", str)
|
||||||
|
}
|
||||||
|
|
||||||
func (sl *slide) addCell( /*cl *cell*/ ) {
|
func (sl *slide) addCell( /*cl *cell*/ ) {
|
||||||
var cl cell
|
var cl cell
|
||||||
|
|
||||||
@ -368,8 +380,11 @@ func (sl *slide) addCell( /*cl *cell*/ ) {
|
|||||||
cl.setSignal()
|
cl.setSignal()
|
||||||
|
|
||||||
cl.qmlimg = qimg.Create(nil)
|
cl.qmlimg = qimg.Create(nil)
|
||||||
|
fmt.Println("index", cl.index)
|
||||||
|
fmt.Printf("objectName: %s\n", fmt.Sprintf("cellImg%d", cl.index))
|
||||||
cl.qmlimg.Set("objectName", fmt.Sprintf("cellImg%d", cl.index))
|
cl.qmlimg.Set("objectName", fmt.Sprintf("cellImg%d", cl.index))
|
||||||
cl.qmlimg.Set("source", fmt.Sprintf("image://images/%d", cl.index))
|
cl.qmlimg.Set("source", fmt.Sprintf("image://images/%d"+`;`+"0", cl.index))
|
||||||
|
fmt.Println("source: ", cl.qmlimg.String("source"))
|
||||||
cl.qmlimg.Set("parent", window.ObjectByName("data2"))
|
cl.qmlimg.Set("parent", window.ObjectByName("data2"))
|
||||||
cl.qmlimg.Set("index", cl.index)
|
cl.qmlimg.Set("index", cl.index)
|
||||||
|
|
||||||
|
5
main.qml
5
main.qml
@ -16,10 +16,10 @@ ApplicationWindow {
|
|||||||
height: 600
|
height: 600
|
||||||
property bool cls: false
|
property bool cls: false
|
||||||
|
|
||||||
|
|
||||||
/*function getFileDialogUrl() {
|
/*function getFileDialogUrl() {
|
||||||
return
|
return
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
onClosing: if (!cls) {
|
onClosing: if (!cls) {
|
||||||
close.accepted = false
|
close.accepted = false
|
||||||
}
|
}
|
||||||
@ -64,7 +64,6 @@ ApplicationWindow {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Menu {
|
Menu {
|
||||||
objectName: "mnuCtx"
|
objectName: "mnuCtx"
|
||||||
title: "new image..."
|
title: "new image..."
|
||||||
@ -75,7 +74,6 @@ ApplicationWindow {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SplitView {
|
SplitView {
|
||||||
id: mainSlider
|
id: mainSlider
|
||||||
objectName: "mainSlider"
|
objectName: "mainSlider"
|
||||||
@ -241,5 +239,4 @@ ApplicationWindow {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
12
qml/cell.qml
12
qml/cell.qml
@ -30,26 +30,32 @@ Rectangle {
|
|||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
acceptedButtons: Qt.AllButtons
|
acceptedButtons: Qt.AllButtons
|
||||||
|
|
||||||
onMouseXChanged: if (containsMouse) {
|
onMouseXChanged: cellHover()
|
||||||
|
onExited: focusChanged(focus)
|
||||||
|
|
||||||
|
function cellHover() {
|
||||||
|
if (containsMouse) {
|
||||||
parent.parent.border.color = "skyblue"
|
parent.parent.border.color = "skyblue"
|
||||||
parent.parent.color = "darkblue"
|
parent.parent.color = "darkblue"
|
||||||
parent.color = "white"
|
parent.color = "white"
|
||||||
} else if (focus) {
|
} else if (focus) {
|
||||||
parent.color = "black"
|
parent.color = "black"
|
||||||
}
|
}
|
||||||
|
}
|
||||||
onExited: focusChanged(focus)
|
|
||||||
|
|
||||||
function notSelected() {
|
function notSelected() {
|
||||||
|
|
||||||
parent.parent.border.color = "black"
|
parent.parent.border.color = "black"
|
||||||
parent.parent.color = "white"
|
parent.parent.color = "white"
|
||||||
parent.color = "black"
|
parent.color = "black"
|
||||||
|
cellHover()
|
||||||
}
|
}
|
||||||
|
|
||||||
function selected() {
|
function selected() {
|
||||||
parent.parent.border.color = "blue"
|
parent.parent.border.color = "blue"
|
||||||
|
parent.color = "black"
|
||||||
parent.parent.color = "gainsboro"
|
parent.parent.color = "gainsboro"
|
||||||
|
cellHover()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,5 @@ Image {
|
|||||||
fillMode: Image.PreserveAspectFit
|
fillMode: Image.PreserveAspectFit
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
|
//cache: false
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user