From 8d57bfb1aef3b71557bc408154ee028751fd688e Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Mon, 14 Jun 2021 19:09:53 +0200 Subject: First commit There was history before but now there is no more. --- Tags.qml | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 Tags.qml (limited to 'Tags.qml') 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 + } + } + } + } +} -- cgit v1.3