MauiKit File Browsing

NewTagDialog.qml
1import QtQuick
2import QtQuick.Layouts
3import QtQuick.Controls
4
5import org.mauikit.controls as Maui
6import org.mauikit.filebrowsing as FB
7
8/**
9 * @inherit org::mauikit::controls::InputDialog
10 * @brief An input dialog to create one or multiple new tags.
11 *
12 * This control inherits from MauiKit InputDialog, to checkout its inherited properties refer to docs.
13 *
14 * @note Multiple tags can be created at once by separating the entries by a comma.
15 *
16 *@image html newtagdialog.png
17 *
18 * @code
19 * Maui.Page
20 * {
21 * Maui.Controls.showCSD: true
22 * anchors.fill: parent
23 *
24 * Button
25 * {
26 * anchors.centerIn: parent
27 * text: "New tag"
28 * onClicked: _tagDialog.open()
29 * }
30 *
31 * FB.NewTagDialog
32 * {
33 * id: _tagDialog
34 * }
35 * }
36 * @endcode
37 *
38 * <a href="https://invent.kde.org/maui/mauikit-filebrowser/examples/NewTagDialog.qml">You can find a more complete example at this link.</a>
39 */
40Maui.InputDialog
41{
42 id: control
43
44 /**
45 * @brief The current colors picked for the new tags.
46 * @property color NewTagDialog::currentColor
47 */
48 readonly property alias currentColor : _colorsRow.currentColor
49
50 /**
51 * @brief The list of the default colors used for the Tagging system.
52 * `["#4DD0E1", "#9575CD", "#F06292", "#DCE775", "#FFD54F", "#FF8A65", "#90A4AE"]`
53 */
54 readonly property var defaultColors : ["#4DD0E1", "#9575CD", "#F06292", "#DCE775", "#FFD54F", "#FF8A65", "#90A4AE"]
55
56 title: i18nd("mauikitfilebrowsing", "New tags")
57 message: i18nd("mauikitfilebrowsing", "Create new tags to organize your files. You can create multiple tags separated by a comma.")
58
59 textEntry.placeholderText: i18n("New tags")
60
62 {
63 id: _colorsRow
64 Layout.fillWidth: true
65
66 colors: control.defaultColors
67 onColorPicked: (color) => currentColor = color
68 }
69
70 Flow
71 {
72 Layout.fillWidth: true
73
74 visible: control.textEntry.text.length
75 spacing: Maui.Style.defaultSpacing
76
77 Repeater
78 {
79 model: textEntry.text.split(",")
80
81 delegate: Maui.Chip
82 {
83 label.text: modelData
84 showCloseButton: false
85 color: control.currentColor
86 iconSource: "tag"
87 }
88 }
89 }
90
91 onFinished: (text) =>
92 {
93 for(var tag of text.split(","))
94 {
95 FB.Tagging.tag(tag, control.currentColor, "")
96 }
97 }
98
99 onClosed:
100 {
101 _colorsRow.currentColor = ""
102 }
103}
QString i18nd(const char *domain, const char *text, const TYPE &arg...)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 27 2024 11:48:47 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.