Merge branch 'master' of github.com:/lordwelch/PresentationApp

This commit is contained in:
lordwelch 2016-03-23 10:37:54 -07:00
commit c351d10cb9
5 changed files with 103 additions and 83 deletions

View File

@ -4,13 +4,16 @@ package main
import (
"image"
"strconv"
"strings"
)
var imgready = false
func imgProvider(id string, width, height int) image.Image {
if imgready {
i, _ := strconv.Atoi(id)
if imgready && (len(id) > 0) {
//fmt.Println("source (provider): ", id)
i1 := strings.Index(id, `;`)
i, _ := strconv.Atoi(id[:i1])
return slides[i].getImage(width, height)
} else {

35
main.go
View File

@ -8,7 +8,9 @@ import (
"os"
"path/filepath"
"runtime/debug"
"strings"
"strings"
"strconv"
"github.com/go-gl/gl/v2.1/gl"
"github.com/go-gl/glfw/v3.1/glfw"
@ -306,9 +308,9 @@ func (cl *cell) setSignal() {
} else {
selSlide = cl.qmlcell.Int("index")
cl.qmlcell.ObjectByName("cellMouse").Set("focus", true)
cl.img.FlipImage()
setupScene()
}
cl.clearcache()
})
cl.qmlcell.ObjectByName("cellMouse").On("focusChanged", func(focus bool) {
@ -321,14 +323,12 @@ func (cl *cell) setSignal() {
window.ObjectByName("imgpicker").On("accepted", func() {
//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.ReadImage(url)
fmt.Println(url)
setupScene()
fmt.Println(window.ObjectByName("imgpicker").String("fileUrl"))
slides[rhtClkCell].img.Clear()
slides[rhtClkCell].img.ReadImage(url)
setupScene()
cl.clearcache()
})
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*/ ) {
var cl cell
@ -368,8 +380,11 @@ func (sl *slide) addCell( /*cl *cell*/ ) {
cl.setSignal()
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("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("index", cl.index)

119
main.qml
View File

@ -16,10 +16,10 @@ ApplicationWindow {
height: 600
property bool cls: false
/*function getFileDialogUrl() {
return
}*/
/*function getFileDialogUrl() {
return
}*/
onClosing: if (!cls) {
close.accepted = false
}
@ -64,17 +64,15 @@ ApplicationWindow {
}
}
Menu {
objectName: "mnuCtx"
title: "new image..."
MenuItem {
objectName: "mnuImgPick"
text: "new Image..."
onTriggered: imgpicker.open()
}
Menu {
objectName: "mnuCtx"
title: "new image..."
MenuItem {
objectName: "mnuImgPick"
text: "new Image..."
onTriggered: imgpicker.open()
}
}
SplitView {
id: mainSlider
@ -124,58 +122,58 @@ ApplicationWindow {
color: "#00000000"
transformOrigin: Item.TopLeft
border.width: 0
Rectangle {
id: textEdit
property int cell
x: 232
y: 622
objectName: "textEdit"
width: 200
height: 200
color: "#ffffff"
visible: false
property bool txt: true
Keys.onPressed: {
if ((event.key == Qt.Key_Return)
&& (event.modifiers & Qt.ControlModifier)) {
txt = true
Rectangle {
id: textEdit
property int cell
x: 232
y: 622
objectName: "textEdit"
width: 200
height: 200
color: "#ffffff"
visible: false
property bool txt: true
Keys.onPressed: {
if ((event.key == Qt.Key_Return)
&& (event.modifiers & Qt.ControlModifier)) {
txt = true
x = -100
y = -100
visible = false
focus = true
enabled = false
opacity = 0
textEdit1.focus = false
x = -100
y = -100
visible = false
focus = true
enabled = false
opacity = 0
textEdit1.focus = false
event.accepted = true
}
event.accepted = true
}
if (event.key == Qt.Key_Escape) {
txt = false
x = -100
y = -100
visible = false
focus = true
enabled = false
opacity = 0
textEdit1.focus = false
if (event.key == Qt.Key_Escape) {
txt = false
x = -100
y = -100
visible = false
focus = true
enabled = false
opacity = 0
textEdit1.focus = false
event.accepted = true
}
}
event.accepted = true
}
}
TextArea {
id: textEdit1
objectName: "textEdit1"
anchors.fill: parent
clip: true
textFormat: Text.AutoText
visible: true
font.pixelSize: 12
z: 99
}
}
TextArea {
id: textEdit1
objectName: "textEdit1"
anchors.fill: parent
clip: true
textFormat: Text.AutoText
visible: true
font.pixelSize: 12
z: 99
}
}
Column {
id: data1
@ -241,5 +239,4 @@ ApplicationWindow {
}
}
}
}

View File

@ -30,26 +30,32 @@ Rectangle {
anchors.fill: parent
acceptedButtons: Qt.AllButtons
onMouseXChanged: if (containsMouse) {
parent.parent.border.color = "skyblue"
parent.parent.color = "darkblue"
parent.color = "white"
} else if (focus) {
parent.color = "black"
}
onMouseXChanged: cellHover()
onExited: focusChanged(focus)
function cellHover() {
if (containsMouse) {
parent.parent.border.color = "skyblue"
parent.parent.color = "darkblue"
parent.color = "white"
} else if (focus) {
parent.color = "black"
}
}
function notSelected() {
parent.parent.border.color = "black"
parent.parent.color = "white"
parent.color = "black"
cellHover()
}
function selected() {
parent.parent.border.color = "blue"
parent.color = "black"
parent.parent.color = "gainsboro"
cellHover()
}
}
}

View File

@ -11,6 +11,5 @@ Image {
fillMode: Image.PreserveAspectFit
anchors.right: parent.right
anchors.left: parent.left
//cache: false
}