Warning, /maui/mauikit/src/controls.6/InfoDialog.qml is written in an unsupported language. File is not indexed.

0001 import QtQuick
0002 import QtQuick.Controls
0003 import QtQuick.Layouts
0004 import org.mauikit.controls 1.3 as Maui
0005 
0006 /**
0007  * @inherit QtQuick.Controls.Dialog
0008  * @brief A Dialog with a built-in template container for displaying information, with a title, image and message body.
0009  * 
0010  * <a href="https://doc.qt.io/qt-6/qml-qtquick-controls-dialog.html">This controls inherits from QQC2 Dialog, to checkout its inherited properties refer to the Qt Docs.</a>
0011  * 
0012  *  @image html Misc/infodialog.png
0013  * 
0014  * @section structure Structure
0015  * The dialog container is handled by a MauiKit ScrollColumn - which by default is flickable - so any contents added as children of this dialog will be put inside of it and become scrollable/flickable.
0016  * 
0017  * @note For the scrollable behaviour to work correctly the child element needs to have an `implicitHeight` size set, and further positioning options should use the Layout attached properties: for filling the with use `Layout.fillWidth: true`.
0018  * 
0019  * The InfoDialog uses the ListItemTemplate control to display the information labels and image/icon, this  is exposed via the `template` property for further tweaking.
0020  * @see template
0021  * 
0022  * To set the title use the `title` property. For the message body use the exposed alias property `message`, or the `template.text2` property, which are the same. To set an icon or image use the alias `template` property, for example `template.iconSource: "dialog-warning"`.
0023  * @see ListItemTemplate
0024  * 
0025  * @attention By default the only action button is set to `standardButtons: Dialog.Close`. To know more about other standard button types checkout the Dialog documentation on Qt page.
0026  * 
0027  * And finally, the dialog can display an inline notification alert upon request via the `alert()` function.
0028  * 
0029  * @remark This alert message is positioned at the bottom part and colored according to the emergency level set.
0030  * This is useful when the dialog needs to warn the user about certain action.
0031  * @see alert
0032  * 
0033  * @image html Misc/infodialog2.png
0034  * 
0035  * @code
0036  * Maui.InfoDialog
0037  * {
0038  *    id: _dialog
0039  *    title: "Hello"
0040  *    message: "Information about some important action to be reviewed, or just plain information."
0041  * 
0042  *    template.iconSource: "dialog-warning"
0043  * 
0044  *    standardButtons: Dialog.Close | Dialog.Apply
0045  * 
0046  *    onRejected: close()
0047  *    onApplied: alert("Are you sure? Alert example.", 2)
0048  * 
0049  *    Rectangle //an extra child element
0050  *    {
0051  *        color: "yellow"
0052  *        Layout.fillWidth: true
0053  *        implicitHeight: 68
0054  *    }
0055  * }
0056  * @endcode
0057  * 
0058  * <a href="https://invent.kde.org/maui/mauikit/-/blob/qt6-2/examples/InfoDialog.qml">You can find a more complete example at this link.</a> 
0059  */
0060 Dialog
0061 {
0062     id: control
0063     
0064     /**
0065      * @brief The default content of the dialog. The children elements of this control will be positioned inside a Mauikit ScrollColumn. 
0066      * @note To position child elements use the Layout attached properties.
0067      * @see InfoDialog#structure
0068      * @property list<QtObject> InfoDialog::content
0069      */
0070     default property alias content: _content.content
0071         
0072         /**
0073          * @brief The message body.
0074          * @property string InfoDialog::message
0075          */ 
0076         property alias message : _template.label2.text
0077         
0078         /**
0079          * @brief The templated item used for the default dialog message, holding the icon emblem and the message body. 
0080          * This property gives access to the template for more detailed tweaking, by adding items or changing its properties.
0081          * @property ListItemTemplate InfoDialog::template
0082          */
0083         property alias template : _template
0084         
0085         standardButtons: Dialog.Close
0086         
0087         contentItem: Maui.ScrollColumn
0088         {
0089             id: _content
0090             clip: true
0091             spacing: control.spacing
0092             
0093             Maui.ListItemTemplate
0094             {
0095                 id: _template
0096                 visible: control.message.length
0097                 Layout.fillWidth: true
0098                 label2.textFormat : TextEdit.AutoText
0099                 label2.wrapMode: TextEdit.WordWrap
0100                 iconVisible: control.width > Maui.Style.units.gridUnit * 10
0101                 
0102                 iconSizeHint: Maui.Style.iconSizes.large
0103                 spacing: Maui.Style.space.big
0104                 
0105                 leftLabels.spacing: control.spacing
0106             }
0107             
0108             Maui.Chip
0109             {
0110                 id: _alertMessage
0111                 
0112                 visible: text.length > 0
0113                 
0114                 property int level : 0
0115                 
0116                 Layout.fillWidth: true
0117                 
0118                 color: switch(level)
0119                 {
0120                     case 0: return Maui.Theme.positiveBackgroundColor
0121                     case 1: return Maui.Theme.neutralBackgroundColor
0122                     case 2: return Maui.Theme.negativeBackgroundColor
0123                 }
0124                 
0125                 SequentialAnimation on x
0126                 {
0127                     id: _alertAnim
0128                     // Animations on properties start running by default
0129                     running: false
0130                     loops: 3
0131                     NumberAnimation { from: 0; to: -10; duration: 100; easing.type: Easing.InOutQuad }
0132                     NumberAnimation { from: -10; to: 0; duration: 100; easing.type: Easing.InOutQuad }
0133                     PauseAnimation { duration: 50 } // This puts a bit of time between the loop
0134                 }
0135                 
0136                 function reset()
0137                 {
0138                     _alertMessage.text = ""
0139                     _alertMessage.level = 0
0140                 }            
0141             }
0142         }
0143         
0144         onClosed: _alertMessage.reset()
0145         
0146         /**
0147          * @brief Sends an inline alert notification that is displayed in the dialog.
0148          * @param message The text for the message. Keep it short if possible.
0149          * @param level Depending on the level the color may differ. The levels are:
0150          * - 0 positive
0151          * - 1 neutral
0152          * - 2 negative
0153          */
0154         function alert(message, level)
0155         {
0156             _alertMessage.text = message
0157             _alertMessage.level = level
0158         }
0159 }