diff --git a/main.go b/main.go index 212a589..d80b630 100644 --- a/main.go +++ b/main.go @@ -20,11 +20,12 @@ type cell struct { type slide []cell var ( - path string - cellQml qml.Object - window *qml.Window - slides slide - err error + path string + textEdit qml.Object + cellQml qml.Object + window *qml.Window + slides slide + err error ) func main() { @@ -44,12 +45,13 @@ func run() error { return err } - cellQml, err = engine.LoadFile(path + "/cell.qml") + cellQml, err = engine.LoadFile(path + "/qml/cell.qml") if err != nil { return err } window = mainQml.CreateWindow(nil) + textEdit = window.ObjectByName("textEdit") slides.addCell() window.Show() @@ -60,27 +62,39 @@ func run() error { func (cl *cell) setSignals() { cl.qmlcell.ObjectByName("cellMouse").On("doubleClicked", func() { cellText := cl.qmlcell.ObjectByName("cellText") - textEdit := window.ObjectByName("textEdit") + textEdit.Set("cell", cl.index) textEdit.Set("x", cellText.Int("x")+4) textEdit.Set("y", cellText.Int("y")+4) textEdit.Set("width", cellText.Int("width")) textEdit.Set("height", cellText.Int("height")) textEdit.Set("opacity", 100) textEdit.Set("visible", true) - textEdit.Set("focus", true) + textEdit.ObjectByName("textEdit1").Set("focus", true) textEdit.Set("enabled", true) /* fmt.Println(textEdit.Int("x")) fmt.Println(textEdit.Int("y")) fmt.Println(textEdit.Int("width")) fmt.Println(textEdit.Int("height"))*/ }) + textEdit.ObjectByName("textEdit1").On("focusChanged", func(focus bool) { + var ( + str string + cel cell + ) + fmt.Printf("focusChanged: focus: %t\n", focus) + if !focus { + str = textEdit.ObjectByName("textEdit1").String("text") + cel = slides[textEdit.Int("cell")] + cel.qmlcell.ObjectByName("cellText").Set("text", str) + } + }) } func (sl *slide) addCell( /*cl *cell*/ ) { var cl cell cl.qmlcell = cellQml.Create(nil) - cl.qmlcell.Set("objectName", fmt.Sprintf("cellRect&d", cl.index)) + cl.qmlcell.Set("objectName", fmt.Sprintf("cellRect%d", cl.index)) cl.qmlcell.Set("parent", window.ObjectByName("data1")) cl.index = len(*sl) diff --git a/main.qml b/main.qml index 63b7bce..b05439d 100644 --- a/main.qml +++ b/main.qml @@ -1,5 +1,8 @@ import QtQuick 2.5 import QtQuick.Controls 1.3 +import QtQuick.Dialogs 1.1 +import QtQuick.Layouts 1.0 +import "qml" ApplicationWindow { id: applicationWindow1 @@ -10,6 +13,13 @@ ApplicationWindow { minimumHeight: 500 width: 1000 height: 600 + AboutDialog { id: aboutDialog } + + Action { + id: aboutAction + text: "About" + onTriggered: aboutDialog.open() + } menuBar: MenuBar { Menu { @@ -22,22 +32,10 @@ ApplicationWindow { shortcut: StandardKey.Quit } } - Menu { - title: "&Edit" - MenuItem { - //action: cutAction - } - MenuItem { - //action: copyAction - } - MenuItem { - //action: pasteAction - } - } Menu { title: "&Help" MenuItem { - //action: aboutAction + action: aboutAction } } } @@ -132,6 +130,7 @@ ApplicationWindow { Rectangle { id: textEdit + property int cell x: 448 y: 151 objectName: "textEdit" @@ -143,15 +142,16 @@ ApplicationWindow { x = -100 y = -100 visible = false - focus = false + focus = true enabled = false opacity = 0 + textEdit1.focus = false } TextArea { id: textEdit1 objectName: "textEdit1" - text: qsTr("Text Edit") + text: "Text Edit" anchors.fill: parent clip: true textFormat: Text.AutoText diff --git a/qml/AboutDialog.qml b/qml/AboutDialog.qml new file mode 100644 index 0000000..f375d1c --- /dev/null +++ b/qml/AboutDialog.qml @@ -0,0 +1,48 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Quick Controls module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.2 +import QtQuick.Dialogs 1.1 + +MessageDialog { + icon: StandardIcon.Information + text: "Presentation App for use in a church service" + detailedText: "made in 2016 by Timmy Welch" + title: "About" +} diff --git a/cell.qml b/qml/cell.qml similarity index 100% rename from cell.qml rename to qml/cell.qml diff --git a/qml/projection.qml b/qml/projection.qml new file mode 100644 index 0000000..9c36e13 --- /dev/null +++ b/qml/projection.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +Item { + +}