MauiKit Controls

InputDialog.qml
1import QtQuick
2import QtQuick.Controls
3import QtQuick.Layouts
4
5import org.mauikit.controls 1.3 as Maui
6
7/**
8 * @inherit InfoDialog
9 * @brief An InfoDialog with a text entry field.
10 *
11 * This control inherits from MauiKit InfoDialog, to checkout its inherited properties refer to docs.
12 *
13 * This dialog can have information labels and icon/image, any number of children, and more. Refer to the structure of the Info Dialog.
14 * @see InfoDialog::structure Structure
15 *
16 * @image html Misc/inputdialog.png
17 *
18 * @code
19 * Maui.InputDialog
20 * {
21 * id: _dialog
22 * title: "Hello"
23 * message: "An input dialog that request some information ot be entered."
24 *
25 * template.iconSource: "dialog-question"
26 * textEntry.placeholderText: "Give me a name."
27 *
28 * onRejected: close()
29 * onFinished: (text) => console.log(text)
30 * }
31 * @endcode
32 *
33 * <a href="https://invent.kde.org/maui/mauikit/-/blob/qt6-2/examples/InputDialog.qml">You can find a more complete example at this link.</a>
34 */
35Maui.InfoDialog
36{
37 id: control
38
39 /**
40 * @brief An alias to acces the entry field handled by a QQC2 TextField control.
41 * @note See Qt documentation on TextField for further information on its properties.
42 * @property TextField InputDialog::textEntry
43 */
44 property alias textEntry: _textEntry
45
46 /**
47 * @brief Emitted when the dialog has been accepted.
48 * This will depend on keeping the `standardButtons` as they are, or setting one that triggers the accepted role.
49 * @note For more information on the standard buttons ad their roles, checkout Qt Dialog docs.
50 * @param The text entered in the text entry field.
51 */
52 signal finished(string text)
53
54 standardButtons: Dialog.Ok | Dialog.Cancel
55
56 TextField
57 {
58 id: _textEntry
59 Layout.fillWidth: true
60 onAccepted: control.standardButton(Dialog.Ok).forceActiveFocus()
61 }
62
63 onAccepted:
64 {
65 finished(textEntry.text)
66 textEntry.clear()
67 close()
68 }
69
70 onRejected:
71 {
72 textEntry.clear()
73 control.close()
74 }
75
76 onOpened:
77 {
78 textEntry.forceActiveFocus()
79 textEntry.selectAll()
80 }
81}
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 17 2024 11:56:16 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.