removed projection.qml
using gflw instead qml cant detect if there are multiple monitors both packages appear to be compatible with eachother
This commit is contained in:
parent
d26d6e08b2
commit
5410aac4d4
50
main.go
50
main.go
@ -4,9 +4,12 @@ package main
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
//"image"
|
//"image"
|
||||||
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"runtime"
|
||||||
|
|
||||||
|
"github.com/go-gl/glfw/v3.1/glfw"
|
||||||
"github.com/kardianos/osext"
|
"github.com/kardianos/osext"
|
||||||
"gopkg.in/qml.v1"
|
"gopkg.in/qml.v1"
|
||||||
)
|
)
|
||||||
@ -26,31 +29,50 @@ var (
|
|||||||
window *qml.Window
|
window *qml.Window
|
||||||
slides slide
|
slides slide
|
||||||
err error
|
err error
|
||||||
|
monitors []*glfw.Monitor
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
if err := glfw.Init(); err != nil {
|
||||||
|
log.Fatalln("failed to initialize glfw:", err)
|
||||||
|
}
|
||||||
|
checkMon()
|
||||||
|
|
||||||
if err := qml.Run(run); err != nil {
|
if err := qml.Run(run); err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "error: %v\n", err)
|
fmt.Fprintf(os.Stderr, "error: %v\n", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
glfw.Terminate()
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
// GLFW event handling must run on the main OS thread
|
||||||
|
runtime.LockOSThread()
|
||||||
}
|
}
|
||||||
|
|
||||||
func run() error {
|
func run() error {
|
||||||
engine := qml.NewEngine()
|
engine := qml.NewEngine()
|
||||||
path, err = osext.ExecutableFolder()
|
path, err = osext.ExecutableFolder()
|
||||||
path = filepath.Clean(path + "/../src/github.com/lordwelch/PresentationApp/")
|
path = filepath.Clean(path + "/../src/github.com/lordwelch/PresentationApp/")
|
||||||
fmt.Println(path)
|
//fmt.Println(path)
|
||||||
mainQml, err := engine.LoadFile(path + "/main.qml")
|
mainQml, err := engine.LoadFile(path + "/main.qml")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*projQml, err := engine.LoadFile(path + "/qml/projection.qml")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}*/
|
||||||
|
|
||||||
cellQml, err = engine.LoadFile(path + "/qml/cell.qml")
|
cellQml, err = engine.LoadFile(path + "/qml/cell.qml")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
window = mainQml.CreateWindow(nil)
|
window = mainQml.CreateWindow(nil)
|
||||||
|
//created(projQml)
|
||||||
textEdit = window.ObjectByName("textEdit")
|
textEdit = window.ObjectByName("textEdit")
|
||||||
slides.addCell()
|
slides.addCell()
|
||||||
|
|
||||||
@ -59,6 +81,25 @@ func run() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func checkMon() {
|
||||||
|
monitors = glfw.GetMonitors()
|
||||||
|
if i := len(monitors); i < 2 {
|
||||||
|
fmt.Println("You only have 1 monitor!!!!!!!!!!! :-P")
|
||||||
|
} else {
|
||||||
|
fmt.Printf("You have %d monitors\n", i)
|
||||||
|
}
|
||||||
|
monitorInfo()
|
||||||
|
}
|
||||||
|
|
||||||
|
func monitorInfo() {
|
||||||
|
for _, mon := range monitors {
|
||||||
|
fmt.Printf("monitor name: %s\n", mon.GetName())
|
||||||
|
i, t := mon.GetPos()
|
||||||
|
fmt.Printf("position X: %d Y: %d\n", i, t)
|
||||||
|
//fmt.Println(mon.)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (cl *cell) setSignals() {
|
func (cl *cell) setSignals() {
|
||||||
cl.qmlcell.ObjectByName("cellMouse").On("doubleClicked", func() {
|
cl.qmlcell.ObjectByName("cellMouse").On("doubleClicked", func() {
|
||||||
cellText := cl.qmlcell.ObjectByName("cellText")
|
cellText := cl.qmlcell.ObjectByName("cellText")
|
||||||
@ -81,7 +122,7 @@ func (cl *cell) setSignals() {
|
|||||||
str string
|
str string
|
||||||
cel cell
|
cel cell
|
||||||
)
|
)
|
||||||
fmt.Printf("focusChanged: focus: %t\n", focus)
|
//fmt.Printf("focusChanged: focus: %t\n", focus)
|
||||||
if !focus {
|
if !focus {
|
||||||
str = textEdit.ObjectByName("textEdit1").String("text")
|
str = textEdit.ObjectByName("textEdit1").String("text")
|
||||||
cel = slides[textEdit.Int("cell")]
|
cel = slides[textEdit.Int("cell")]
|
||||||
@ -98,17 +139,18 @@ func (sl *slide) addCell( /*cl *cell*/ ) {
|
|||||||
cl.qmlcell.Set("parent", window.ObjectByName("data1"))
|
cl.qmlcell.Set("parent", window.ObjectByName("data1"))
|
||||||
|
|
||||||
cl.index = len(*sl)
|
cl.index = len(*sl)
|
||||||
|
|
||||||
cl.text = "testing 1... 2... 3..."
|
cl.text = "testing 1... 2... 3..."
|
||||||
cl.qmlcell.ObjectByName("cellText").Set("text", cl.text)
|
cl.qmlcell.ObjectByName("cellText").Set("text", cl.text)
|
||||||
*sl = append(*sl, cl)
|
*sl = append(*sl, cl)
|
||||||
|
|
||||||
cl.setSignals()
|
cl.setSignals()
|
||||||
|
|
||||||
fmt.Print((*sl)[len(*sl)-1])
|
//fmt.Print((*sl)[cl.index])
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cl cell) String() string {
|
func (cl cell) String() string {
|
||||||
return fmt.Sprintf("Index: %T \nText: %T\n", cl.index, cl.text)
|
return fmt.Sprintf("Index: %d \nText: %s\n", cl.index, cl.text)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cl cell) GoString() string {
|
func (cl cell) GoString() string {
|
||||||
|
7
main.qml
7
main.qml
@ -1,7 +1,6 @@
|
|||||||
import QtQuick 2.5
|
import QtQuick 2.4
|
||||||
import QtQuick.Controls 1.3
|
import QtQuick.Controls 1.3
|
||||||
import QtQuick.Dialogs 1.1
|
import QtQuick.Window 2.0
|
||||||
import QtQuick.Layouts 1.0
|
|
||||||
import "qml"
|
import "qml"
|
||||||
|
|
||||||
ApplicationWindow {
|
ApplicationWindow {
|
||||||
@ -13,6 +12,7 @@ ApplicationWindow {
|
|||||||
minimumHeight: 500
|
minimumHeight: 500
|
||||||
width: 1000
|
width: 1000
|
||||||
height: 600
|
height: 600
|
||||||
|
Screen.objectName: "Screen1"
|
||||||
AboutDialog { id: aboutDialog }
|
AboutDialog { id: aboutDialog }
|
||||||
|
|
||||||
Action {
|
Action {
|
||||||
@ -25,7 +25,6 @@ ApplicationWindow {
|
|||||||
Menu {
|
Menu {
|
||||||
title: "&File"
|
title: "&File"
|
||||||
MenuItem {
|
MenuItem {
|
||||||
|
|
||||||
}
|
}
|
||||||
MenuItem {
|
MenuItem {
|
||||||
text: "Close"
|
text: "Close"
|
||||||
|
@ -1,5 +0,0 @@
|
|||||||
import QtQuick 2.0
|
|
||||||
|
|
||||||
Item {
|
|
||||||
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user