summaryrefslogtreecommitdiff
path: root/Tags.qml
diff options
context:
space:
mode:
Diffstat (limited to 'Tags.qml')
-rw-r--r--Tags.qml47
1 files changed, 47 insertions, 0 deletions
diff --git a/Tags.qml b/Tags.qml
new file mode 100644
index 0000000..7d3f0ce
--- /dev/null
+++ b/Tags.qml
@@ -0,0 +1,47 @@
+// SPDX-License-Identifier: Unlicense
+
+import QtQuick 2.12
+import QtQuick.Controls 2.13
+import QtQuick.Layouts 1.6
+
+import 'util.js' as Util
+
+// Tag list.
+Page {
+ id: control
+
+ property alias model: tags.model
+
+ signal clicked(string tag, var fields)
+
+ Keys.enabled: enabled
+ Keys.onPressed: {
+ for (var i = 0; i < model.length; i++) {
+ const tag = model[i]
+ if (tag.key === event.text) {
+ clicked(tag.tag, tag.fields)
+ return
+ }
+ }
+ event.accepted = false
+ }
+
+ RowLayout {
+ width: parent.width
+
+ Flow {
+ spacing: 5
+ Layout.fillWidth: true
+
+ Repeater {
+ id: tags
+ delegate: Button {
+ text: Util.addShortcut(modelData.tag, modelData.key)
+ onClicked: control.clicked(modelData.tag, modelData.fields)
+ focusPolicy: Qt.NoFocus
+ implicitWidth: implicitContentWidth + 2*padding
+ }
+ }
+ }
+ }
+}