First commit
There was history before but now there is no more.
This commit is contained in:
commit
8d57bfb1ae
35 changed files with 2231 additions and 0 deletions
27
Fields/Bool.qml
Normal file
27
Fields/Bool.qml
Normal file
|
@ -0,0 +1,27 @@
|
|||
// SPDX-License-Identifier: Unlicense
|
||||
|
||||
import QtQuick 2.12
|
||||
import QtQuick.Controls 2.13
|
||||
|
||||
Row {
|
||||
id: control
|
||||
width: parent.width
|
||||
|
||||
property var definition
|
||||
property alias value: input.checked
|
||||
|
||||
Keys.onPressed: {
|
||||
if (event.text === definition.key) {
|
||||
value = !value
|
||||
event.accepted = true
|
||||
}
|
||||
}
|
||||
function set(val) { value = val || false }
|
||||
|
||||
CheckBox {
|
||||
id: input
|
||||
focusPolicy: Qt.NoFocus
|
||||
padding: 0
|
||||
font.capitalization: Font.SmallCaps
|
||||
}
|
||||
}
|
59
Fields/Enum.qml
Normal file
59
Fields/Enum.qml
Normal file
|
@ -0,0 +1,59 @@
|
|||
// SPDX-License-Identifier: Unlicense
|
||||
|
||||
import QtQuick 2.12
|
||||
import QtQuick.Controls 2.13
|
||||
|
||||
import '../util.js' as Util
|
||||
|
||||
Column {
|
||||
id: control
|
||||
|
||||
property var definition
|
||||
property int index: -1
|
||||
readonly property string value: index >= 0 ? definition.values.get(index).name : ''
|
||||
|
||||
function set(val) {
|
||||
for (var i = 0; i < definition.values.count; i++) {
|
||||
if (definition.values.get(i).name === val) {
|
||||
index = i
|
||||
return true
|
||||
}
|
||||
}
|
||||
index = -1
|
||||
}
|
||||
|
||||
Keys.onPressed: {
|
||||
for (var i = 0; i < definition.values.count; i++) {
|
||||
if (definition.values.get(i).key === event.text) {
|
||||
index = (index === i ? -1 : i)
|
||||
event.accepted = true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Flow {
|
||||
spacing: 5
|
||||
width: parent.width
|
||||
|
||||
ButtonGroup { id: buttons }
|
||||
|
||||
Repeater {
|
||||
model: definition.values
|
||||
delegate: Button {
|
||||
ButtonGroup.group: buttons
|
||||
checkable: true
|
||||
checked: control.index === index
|
||||
focusPolicy: Qt.NoFocus
|
||||
|
||||
implicitWidth: implicitContentWidth + leftPadding + rightPadding
|
||||
padding: 0
|
||||
leftPadding: 5
|
||||
rightPadding: leftPadding
|
||||
|
||||
onClicked: control.index = (control.index === index ? -1 : index)
|
||||
text: Util.addShortcut(name, key)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
50
Fields/Text.qml
Normal file
50
Fields/Text.qml
Normal file
|
@ -0,0 +1,50 @@
|
|||
// SPDX-License-Identifier: Unlicense
|
||||
|
||||
import QtQuick 2.12
|
||||
import QtQuick.Controls 2.13
|
||||
|
||||
Label {
|
||||
id: control
|
||||
|
||||
property var definition
|
||||
property alias value: control.text
|
||||
|
||||
Keys.onPressed: {
|
||||
if (event.text === definition.key) {
|
||||
popup.open()
|
||||
event.accepted = true
|
||||
}
|
||||
}
|
||||
|
||||
function set(val) { value = val || '' }
|
||||
|
||||
elide: Text.ElideRight
|
||||
|
||||
Popup {
|
||||
id: popup
|
||||
|
||||
width: control.width
|
||||
height: control.height
|
||||
padding: 0
|
||||
|
||||
onOpened: {
|
||||
input.text = value
|
||||
input.forceActiveFocus()
|
||||
}
|
||||
|
||||
TextInput {
|
||||
id: input
|
||||
|
||||
clip: true
|
||||
padding: 2
|
||||
topPadding: 0
|
||||
bottomPadding: 0
|
||||
width: parent.width
|
||||
|
||||
onAccepted: {
|
||||
value = input.text.trim()
|
||||
popup.close()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
54
Fields/TextArea.qml
Normal file
54
Fields/TextArea.qml
Normal file
|
@ -0,0 +1,54 @@
|
|||
// SPDX-License-Identifier: Unlicense
|
||||
|
||||
import QtQuick 2.12
|
||||
import QtQuick.Controls 2.13
|
||||
|
||||
Label {
|
||||
id: control
|
||||
|
||||
property var definition
|
||||
property alias value: control.text
|
||||
|
||||
Keys.onPressed: {
|
||||
if (event.text === definition.key) {
|
||||
popup.open()
|
||||
event.accepted = true
|
||||
}
|
||||
}
|
||||
|
||||
function set(val) { value = (val || '').trim() }
|
||||
|
||||
wrapMode: Text.Wrap
|
||||
|
||||
Popup {
|
||||
id: popup
|
||||
|
||||
width: control.width
|
||||
height: input.height
|
||||
padding: 0
|
||||
|
||||
onOpened: {
|
||||
input.text = value
|
||||
input.forceActiveFocus()
|
||||
}
|
||||
|
||||
TextArea {
|
||||
id: input
|
||||
|
||||
padding: 2
|
||||
topPadding: 0
|
||||
bottomPadding: 0
|
||||
width: parent.width
|
||||
wrapMode: TextEdit.Wrap
|
||||
|
||||
Keys.onPressed: {
|
||||
if (event.modifiers === Qt.NoModifier) {
|
||||
if (event.key === Qt.Key_Return || event.key === Qt.Key_Enter) {
|
||||
value = input.text.trim()
|
||||
popup.close()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue