Initial but not really

This commit is contained in:
Bel LaPointe
2019-02-26 17:56:07 -07:00
commit c8318d45ac
16 changed files with 771 additions and 0 deletions

1
testdata/quick/build vendored Normal file
View File

@@ -0,0 +1 @@
qtdeploy test desktop ${PWD#${GOPATH}/src/}

20
testdata/quick/main.go vendored Normal file
View File

@@ -0,0 +1,20 @@
package main
import (
"os"
"github.com/therecipe/qt/core"
"github.com/therecipe/qt/gui"
"github.com/therecipe/qt/qml"
)
func main() {
core.QCoreApplication_SetAttribute(core.Qt__AA_EnableHighDpiScaling, true)
gui.NewQGuiApplication(len(os.Args), os.Args)
var app = qml.NewQQmlApplicationEngine(nil)
app.Load(core.NewQUrl3("qrc:/qml/application.qml", 0))
gui.QGuiApplication_Exec()
}

148
testdata/quick/qml/application.qml vendored Normal file
View File

@@ -0,0 +1,148 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the examples 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 The Qt Company Ltd 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$
**
****************************************************************************/
//Slightly edited the original code for a scrollable TextArea and Qt Quick 2 controls
import QtQuick 2.2
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.3
ApplicationWindow {
visible: true
title: "Basic layouts"
property int margin: 11
minimumWidth: 600
minimumHeight: 450
ColumnLayout {
id: mainLayout
anchors.fill: parent
anchors.margins: margin
GroupBox {
id: rowBox
title: "Row layout"
Layout.fillWidth: true
RowLayout {
id: rowLayout
anchors.fill: parent
TextField {
placeholderText: "This wants to grow horizontally"
Layout.fillWidth: true
}
Button {
text: "Button"
}
}
}
GroupBox {
id: gridBox
title: "Grid layout"
Layout.fillWidth: true
GridLayout {
id: gridLayout
rows: 3
flow: GridLayout.TopToBottom
anchors.fill: parent
Label { text: "Line 1" }
Label { text: "Line 2" }
Label { text: "Line 3" }
TextField { }
TextField { id: textField }
TextField { }
Flickable {
anchors {
top: parent.top
left: textField.right
right: parent.right
bottom: parent.bottom
}
contentHeight: textid.width
contentWidth: textid.height
TextArea.flickable: TextArea {
id: textid
text: "This widget spans over three rows in the GridLayout.\n"
+ "All items in the GridLayout are implicitly positioned from top to bottom."
wrapMode: TextArea.Wrap
}
ScrollBar.vertical: ScrollBar { }
}
}
}
TextArea {
id: t3
text: "This fills the whole cell"
Layout.minimumHeight: 30
Layout.fillHeight: true
Layout.fillWidth: true
}
GroupBox {
id: stackBox
title: "Stack layout"
implicitWidth: 200
implicitHeight: 60
Layout.fillWidth: true
Layout.fillHeight: true
StackLayout {
id: stackLayout
anchors.fill: parent
function advance() { currentIndex = (currentIndex + 1) % count }
Repeater {
id: stackRepeater
model: 5
Rectangle {
color: Qt.hsla((0.5 + index)/stackRepeater.count, 0.3, 0.7, 1)
Button { anchors.centerIn: parent; text: "Page " + (index + 1); onClicked: { stackLayout.advance() } }
}
}
}
}
}
}

1
testdata/widget/build vendored Normal file
View File

@@ -0,0 +1 @@
qtdeploy test desktop ${PWD#${GOPATH}/src/}

218
testdata/widget/main.go vendored Normal file
View File

@@ -0,0 +1,218 @@
//source: http://doc.qt.io/qt-5/qtwidgets-widgets-lineedits-example.html
package main
import (
"os"
"github.com/therecipe/qt/core"
"github.com/therecipe/qt/gui"
"github.com/therecipe/qt/widgets"
)
func main() {
widgets.NewQApplication(len(os.Args), os.Args)
var (
echoGroup = widgets.NewQGroupBox2("Echo", nil)
echoLabel = widgets.NewQLabel2("Mode:", nil, 0)
echoComboBox = widgets.NewQComboBox(nil)
echoLineEdit = widgets.NewQLineEdit(nil)
)
echoComboBox.AddItems([]string{"Normal", "Password", "PasswordEchoOnEdit", "No Echo"})
echoLineEdit.SetPlaceholderText("Placeholder Text")
var (
validatorGroup = widgets.NewQGroupBox2("Validator", nil)
validatorLabel = widgets.NewQLabel2("Type:", nil, 0)
validatorComboBox = widgets.NewQComboBox(nil)
validatorLineEdit = widgets.NewQLineEdit(nil)
)
validatorComboBox.AddItems([]string{"No validator", "Integer validator", "Double validator"})
validatorLineEdit.SetPlaceholderText("Placeholder Text")
var (
alignmentGroup = widgets.NewQGroupBox2("Alignment", nil)
alignmentLabel = widgets.NewQLabel2("Type:", nil, 0)
alignmentComboBox = widgets.NewQComboBox(nil)
alignmentLineEdit = widgets.NewQLineEdit(nil)
)
alignmentComboBox.AddItems([]string{"Left", "Centered", "Right"})
alignmentLineEdit.SetPlaceholderText("Placeholder Text")
var (
inputMaskGroup = widgets.NewQGroupBox2("Input mask", nil)
inputMaskLabel = widgets.NewQLabel2("Type:", nil, 0)
inputMaskComboBox = widgets.NewQComboBox(nil)
inputMaskLineEdit = widgets.NewQLineEdit(nil)
)
inputMaskComboBox.AddItems([]string{"No mask", "Phone number", "ISO date", "License key"})
inputMaskLineEdit.SetPlaceholderText("Placeholder Text")
var (
accessGroup = widgets.NewQGroupBox2("Access", nil)
accessLabel = widgets.NewQLabel2("Read-only:", nil, 0)
accessComboBox = widgets.NewQComboBox(nil)
accessLineEdit = widgets.NewQLineEdit(nil)
)
accessComboBox.AddItems([]string{"False", "True"})
accessLineEdit.SetPlaceholderText("Placeholder Text")
echoComboBox.ConnectCurrentIndexChanged(func(index int) { echoChanged(echoLineEdit, index) })
validatorComboBox.ConnectCurrentIndexChanged(func(index int) { validatorChanged(validatorLineEdit, index) })
alignmentComboBox.ConnectCurrentIndexChanged(func(index int) { alignmentChanged(alignmentLineEdit, index) })
inputMaskComboBox.ConnectCurrentIndexChanged(func(index int) { inputMaskChanged(inputMaskLineEdit, index) })
accessComboBox.ConnectCurrentIndexChanged(func(index int) { accessChanged(accessLineEdit, index) })
var echoLayout = widgets.NewQGridLayout2()
echoLayout.AddWidget(echoLabel, 0, 0, 0)
echoLayout.AddWidget(echoComboBox, 0, 1, 0)
echoLayout.AddWidget3(echoLineEdit, 1, 0, 1, 2, 0)
echoGroup.SetLayout(echoLayout)
var validatorLayout = widgets.NewQGridLayout2()
validatorLayout.AddWidget(validatorLabel, 0, 0, 0)
validatorLayout.AddWidget(validatorComboBox, 0, 1, 0)
validatorLayout.AddWidget3(validatorLineEdit, 1, 0, 1, 2, 0)
validatorGroup.SetLayout(validatorLayout)
var alignmentLayout = widgets.NewQGridLayout2()
alignmentLayout.AddWidget(alignmentLabel, 0, 0, 0)
alignmentLayout.AddWidget(alignmentComboBox, 0, 1, 0)
alignmentLayout.AddWidget3(alignmentLineEdit, 1, 0, 1, 2, 0)
alignmentGroup.SetLayout(alignmentLayout)
var inputMaskLayout = widgets.NewQGridLayout2()
inputMaskLayout.AddWidget(inputMaskLabel, 0, 0, 0)
inputMaskLayout.AddWidget(inputMaskComboBox, 0, 1, 0)
inputMaskLayout.AddWidget3(inputMaskLineEdit, 1, 0, 1, 2, 0)
inputMaskGroup.SetLayout(inputMaskLayout)
var accessLayout = widgets.NewQGridLayout2()
accessLayout.AddWidget(accessLabel, 0, 0, 0)
accessLayout.AddWidget(accessComboBox, 0, 1, 0)
accessLayout.AddWidget3(accessLineEdit, 1, 0, 1, 2, 0)
accessGroup.SetLayout(accessLayout)
var layout = widgets.NewQGridLayout2()
layout.AddWidget(echoGroup, 0, 0, 0)
layout.AddWidget(validatorGroup, 1, 0, 0)
layout.AddWidget(alignmentGroup, 2, 0, 0)
layout.AddWidget(inputMaskGroup, 0, 1, 0)
layout.AddWidget(accessGroup, 1, 1, 0)
var window = widgets.NewQMainWindow(nil, 0)
window.SetWindowTitle("Line Edits")
var centralWidget = widgets.NewQWidget(window, 0)
centralWidget.SetLayout(layout)
window.SetCentralWidget(centralWidget)
window.Show()
widgets.QApplication_Exec()
}
func echoChanged(echoLineEdit *widgets.QLineEdit, index int) {
switch index {
case 0:
{
echoLineEdit.SetEchoMode(widgets.QLineEdit__Normal)
}
case 1:
{
echoLineEdit.SetEchoMode(widgets.QLineEdit__Password)
}
case 2:
{
echoLineEdit.SetEchoMode(widgets.QLineEdit__PasswordEchoOnEdit)
}
case 3:
{
echoLineEdit.SetEchoMode(widgets.QLineEdit__NoEcho)
}
}
}
func validatorChanged(validatorLineEdit *widgets.QLineEdit, index int) {
switch index {
case 0:
{
validatorLineEdit.SetValidator(nil)
}
case 1:
{
validatorLineEdit.SetValidator(gui.NewQIntValidator(validatorLineEdit))
}
case 2:
{
validatorLineEdit.SetValidator(gui.NewQDoubleValidator2(-999.0, 999.0, 2, validatorLineEdit))
}
}
validatorLineEdit.Clear()
}
func alignmentChanged(alignmentLineEdit *widgets.QLineEdit, index int) {
switch index {
case 0:
{
alignmentLineEdit.SetAlignment(core.Qt__AlignLeft)
}
case 1:
{
alignmentLineEdit.SetAlignment(core.Qt__AlignCenter)
}
case 2:
{
alignmentLineEdit.SetAlignment(core.Qt__AlignRight)
}
}
}
func inputMaskChanged(inputMaskLineEdit *widgets.QLineEdit, index int) {
switch index {
case 0:
{
inputMaskLineEdit.SetInputMask("")
}
case 1:
{
inputMaskLineEdit.SetInputMask("+99 99 99 99 99;_")
}
case 2:
{
inputMaskLineEdit.SetInputMask("0000-00-00")
inputMaskLineEdit.SetText("00000000")
inputMaskLineEdit.SetCursorPosition(0)
}
case 3:
{
inputMaskLineEdit.SetInputMask(">AAAAA-AAAAA-AAAAA-AAAAA-AAAAA;#")
}
}
}
func accessChanged(accessLineEdit *widgets.QLineEdit, index int) {
switch index {
case 0:
{
accessLineEdit.SetReadOnly(false)
}
case 1:
{
accessLineEdit.SetReadOnly(true)
}
}
}