Warning, /maui/mauikit/src/controls.5/FileListingDialog.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 import QtQuick.Controls 2.14
0022 import QtQuick.Layouts 1.3
0023 
0024 import org.mauikit.controls 1.3 as Maui
0025 import org.mauikit.filebrowsing 1.3 as FB
0026 
0027 /*!
0028   \since org.mauikit.controls.labs 1.0
0029   \inqmlmodule org.mauikit.controls.labs
0030 */
0031 Maui.PopupPage
0032 {
0033     id: control
0034 
0035     default property alias content : _content.data
0036     property var urls: []
0037 
0038     property string message : ""
0039 
0040     readonly property var singleItem : FB.FM.getFileInfo(control.urls[0])
0041     property alias template : _template
0042 
0043     hint: 1
0044     maxWidth: 350
0045 
0046     headBar.visible: false
0047 
0048     Maui.ListItemTemplate
0049     {
0050         id: _template
0051         visible: control.message.length
0052         Layout.fillWidth: true
0053         label2.text: message
0054         label2.textFormat : TextEdit.AutoText
0055         label2.wrapMode: TextEdit.WordWrap
0056         iconVisible: control.width > Maui.Style.units.gridUnit * 10
0057 
0058         iconSizeHint: Maui.Style.iconSizes.large
0059         spacing: Maui.Style.space.big
0060 
0061         leftLabels.spacing: control.spacing
0062 
0063         headerSizeHint: template.iconSizeHint + Maui.Style.space.big
0064         iconSource: singleItem.icon
0065         imageSource: singleItem.thumbnail
0066         implicitHeight: Math.max(template.leftLabels.implicitHeight, 64)
0067 
0068 
0069         leftLabels.data: ColumnLayout
0070         {
0071             id: _content
0072             Layout.fillWidth: true
0073             spacing: control.spacing
0074         }
0075 
0076         iconComponent: Item
0077         {
0078             Item
0079             {
0080                 height: Math.min(parent.height, 120, width)
0081                 width: parent.width
0082                 anchors.centerIn: parent
0083                 layer.enabled: true
0084 
0085                 Rectangle
0086                 {
0087                     visible: control.urls ? control.urls.length > 1 : false
0088                     anchors.fill: parent
0089 
0090                     anchors.leftMargin: Maui.Style.space.small
0091                     anchors.rightMargin: Maui.Style.space.small
0092 
0093                     radius: Maui.Style.radiusV
0094                     color: Qt.tint(control.Maui.Theme.textColor, Qt.rgba(control.Maui.Theme.backgroundColor.r, control.Maui.Theme.backgroundColor.g, control.Maui.Theme.backgroundColor.b, 0.9))
0095                     border.color: Maui.Theme.backgroundColor
0096                 }
0097 
0098                 Rectangle
0099                 {
0100                     visible: control.urls ? control.urls.length > 1 : false
0101                     anchors.fill: parent
0102 
0103                     anchors.topMargin: Maui.Style.space.tiny
0104                     anchors.leftMargin: Maui.Style.space.tiny
0105                     anchors.rightMargin: Maui.Style.space.tiny
0106 
0107                     radius: Maui.Style.radiusV
0108                     color: Qt.tint(control.Maui.Theme.textColor, Qt.rgba(control.Maui.Theme.backgroundColor.r, control.Maui.Theme.backgroundColor.g, control.Maui.Theme.backgroundColor.b, 0.9))
0109                     border.color: Maui.Theme.backgroundColor
0110                 }
0111 
0112                 Rectangle
0113                 {
0114                     anchors.fill: parent
0115                     anchors.topMargin:  control.urls.length > 1 ? Maui.Style.space.small : 0
0116                     border.color: Maui.Theme.backgroundColor
0117 
0118                     radius: Maui.Style.radiusV
0119                     color: Qt.tint(control.Maui.Theme.textColor, Qt.rgba(control.Maui.Theme.backgroundColor.r, control.Maui.Theme.backgroundColor.g, control.Maui.Theme.backgroundColor.b, 0.9))
0120 
0121                     Maui.GridItemTemplate
0122                     {
0123                         anchors.fill: parent
0124                         anchors.margins: Maui.Style.space.tiny
0125                         iconSizeHint: Math.min(height, width)
0126 
0127                         iconSource: control.template.iconSource
0128                         imageSource:  control.template.imageSource
0129                     }
0130                 }
0131             }
0132         }
0133 
0134     }
0135 
0136     property Component listDelegate : Maui.ListItemTemplate
0137     {
0138         width: ListView.view.width
0139         height: Maui.Style.rowHeight
0140         property var item : FB.FM.getFileInfo(modelData)
0141         label1.text: item.label
0142         label3.text: Maui.Handy.formatSize(item.size)
0143         rightLabels.visible: true
0144         iconVisible: true
0145         iconSource: item.icon
0146         imageSource: item.thumbnail
0147         iconSizeHint: Maui.Style.iconSizes.medium
0148 
0149         ToolButton
0150         {
0151             //text: i18nd("mauikit", "Clear")
0152             icon.name: "edit-clear"
0153             icon.width: Maui.Style.iconSizes.small
0154             icon.height: Maui.Style.iconSizes.small
0155 
0156             onClicked:
0157             {
0158                 var array = control.urls
0159                 const index = array.indexOf(modelData);
0160                 if (index > -1) {
0161                     array.splice(index, 1);
0162                 }
0163 
0164                 if(array.length === 0)
0165                 {
0166                     control.close()
0167                     return
0168                 }
0169 
0170                 control.urls = array
0171             }
0172         }
0173     }
0174 
0175     Loader
0176     {
0177         id: _listViewLoader
0178 
0179         asynchronous: true
0180         active: control.urls.length > 0
0181         visible: active
0182 
0183         Layout.fillWidth: true
0184 
0185         sourceComponent: Maui.ListBrowser
0186         {
0187 clip: true
0188             implicitHeight: Math.min(contentHeight, 300)
0189             model: urls
0190             spacing: Maui.Style.defaultSpacing
0191             padding: 0
0192 
0193             delegate: control.listDelegate
0194         }
0195     }
0196 }