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

0001 /*
0002  *   Copyright 2018 Camilo Higuita <milo.h@aol.com>
0003  *
0004  *   This program is free software; you can redistribute it and/or modify
0005  *   it under the terms of the GNU Library General Public License as
0006  *   published by the Free Software Foundation; either version 2, or
0007  *   (at your option) any later version.
0008  *
0009  *   This program is distributed in the hope that it will be useful,
0010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
0011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0012  *   GNU General Public License for more details
0013  *
0014  *   You should have received a copy of the GNU Library General Public
0015  *   License along with this program; if not, write to the
0016  *   Free Software Foundation, Inc.,
0017  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
0018  */
0019 
0020 import QtQuick 2.14
0021 
0022 import QtQuick.Controls 2.14
0023 import QtQuick.Layouts 1.3
0024 
0025 import org.mauikit.controls 1.3 as Maui
0026 
0027 
0028 Dialog
0029 {
0030     id: control
0031 
0032     default property alias content: _content.content
0033 
0034     /*!
0035      *    Default message text inside the scrollable layout.
0036      */
0037     property string message : ""
0038 
0039     /*!
0040      *    \qmlproperty ListItemTemplate ApplicationWindow::template
0041      *
0042      *    The templated item used for the default dialog message, holding the icon emblem and the message body.
0043      *    This property gives access to the template for more detailed tweaking, by adding items or changing its properties.
0044      */
0045     property alias template : _template
0046 
0047     standardButtons: Dialog.Close
0048 
0049     contentItem: Maui.ScrollColumn
0050     {
0051         id: _content
0052         clip: true
0053         spacing: control.spacing
0054 
0055         Maui.ListItemTemplate
0056         {
0057             id: _template
0058             visible: control.message.length
0059             Layout.fillWidth: true
0060             label2.text: message
0061             label2.textFormat : TextEdit.AutoText
0062             label2.wrapMode: TextEdit.WordWrap
0063             iconVisible: control.width > Maui.Style.units.gridUnit * 10
0064 
0065             iconSizeHint: Maui.Style.iconSizes.large
0066             spacing: Maui.Style.space.big
0067 
0068             leftLabels.spacing: control.spacing
0069         }
0070 
0071         Maui.Chip
0072         {
0073             id: _alertMessage
0074 
0075             visible: text.length > 0
0076 
0077             property int level : 0
0078 
0079             Layout.fillWidth: true
0080 
0081             color: switch(level)
0082                    {
0083                    case 0: return Maui.Theme.positiveBackgroundColor
0084                    case 1: return Maui.Theme.neutralBackgroundColor
0085                    case 2: return Maui.Theme.negativeBackgroundColor
0086                    }
0087 
0088             SequentialAnimation on x
0089             {
0090                 id: _alertAnim
0091                 // Animations on properties start running by default
0092                 running: false
0093                 loops: 3
0094                 NumberAnimation { from: 0; to: -10; duration: 100; easing.type: Easing.InOutQuad }
0095                 NumberAnimation { from: -10; to: 0; duration: 100; easing.type: Easing.InOutQuad }
0096                 PauseAnimation { duration: 50 } // This puts a bit of time between the loop
0097             }
0098         }
0099     }
0100 
0101     /**
0102      * Send an alert message that is shown inline in the dialog.
0103      * Depending on the level the color may differ.
0104      */
0105     function alert(message, level)
0106     {
0107         _alertMessage.text = message
0108         _alertMessage.level = level
0109     }
0110 }