Warning, /maui/index-fm/src/widgets/views/HomeView.qml is written in an unsupported language. File is not indexed.

0001 // Copyright 2018-2020 Camilo Higuita <milo.h@aol.com>
0002 // Copyright 2018-2020 Slike Latinoamericana S.C.
0003 //
0004 // SPDX-License-Identifier: GPL-3.0-or-later
0005 
0006 
0007 import QtQuick 2.14
0008 import QtQuick.Controls 2.14
0009 import QtQuick.Layouts 1.3
0010 
0011 import org.mauikit.controls 1.3 as Maui
0012 import org.mauikit.filebrowsing 1.0 as FB
0013 import Qt.labs.platform 1.1
0014 
0015 import org.maui.index 1.0 as Index
0016 
0017 import "home"
0018 
0019 Maui.Page
0020 {
0021     id: control
0022 
0023     Maui.Theme.colorSet: Maui.Theme.View
0024     Maui.Theme.inherit: false
0025     headBar.forceCenterMiddleContent: false
0026     altHeader: Maui.Handy.isMobile
0027 
0028     Maui.ContextualMenu
0029     {
0030         id: _fileItemMenu
0031         property url url
0032 
0033         MenuItem
0034         {
0035             text: i18n("Open")
0036             onTriggered: currentBrowser.openFile(_fileItemMenu.url)
0037         }
0038 
0039         MenuItem
0040         {
0041             text: i18n("Open with")
0042             onTriggered: openWith([_fileItemMenu.url])
0043         }
0044 
0045         MenuItem
0046         {
0047             text: i18n("Share")
0048             onTriggered: shareFiles([_fileItemMenu.url])
0049         }
0050 
0051         MenuItem
0052         {
0053             text: i18n("Open folder")
0054             onTriggered: openTab(FB.FM.fileDir(_fileItemMenu.url))
0055         }
0056     }
0057 
0058     headBar.middleContent: Maui.SearchField
0059     {
0060         id: _searchField
0061         Layout.fillWidth: true
0062         Layout.minimumWidth: 100
0063         Layout.maximumWidth: 500
0064         Layout.alignment: Qt.AlignCenter
0065         placeholderText: i18n("Search for files")
0066         onAccepted:
0067         {
0068             currentBrowser.search(text)
0069         }
0070     }
0071 
0072     headBar.farLeftContent: ToolButton
0073     {
0074         icon.name: "go-previous"
0075         text: i18n("Browser")
0076         display: isWide ? ToolButton.TextBesideIcon : ToolButton.IconOnly
0077         visible: _stackView.depth === 2
0078         onClicked: _stackView.pop()
0079     }
0080 
0081     ScrollView
0082     {
0083         anchors.fill: parent
0084         contentHeight: _layout.implicitHeight
0085         contentWidth: availableWidth
0086 
0087         background: null
0088         padding: Maui.Style.space.medium
0089 
0090         property int itemWidth : Math.min(140, _layout.width * 0.3)
0091 
0092         Flickable
0093         {
0094             boundsBehavior: Flickable.StopAtBounds
0095             boundsMovement: Flickable.StopAtBounds
0096 
0097             ColumnLayout
0098             {
0099                 id: _layout
0100                 width: parent.width
0101                 spacing: Maui.Style.space.huge
0102 
0103                 Loader
0104                 {
0105                     Layout.fillWidth: true
0106                     asynchronous: true
0107 
0108                     sourceComponent: PlacesSection
0109                     {
0110                     }
0111                 }
0112 
0113                 Loader
0114                 {
0115                     Layout.fillWidth: true
0116                     asynchronous: true
0117 
0118                     sourceComponent: FavoritesSection
0119                     {
0120                     }
0121                 }
0122 
0123                 Loader
0124                 {
0125                     asynchronous: true
0126 
0127                     Layout.fillWidth: true
0128 
0129                     sourceComponent: RecentSection
0130                     {
0131                         id: _recentGrid
0132                         title: i18n("Downloads")
0133                         description: i18n("Your most recent downloaded files")
0134 
0135                         list.url: StandardPaths.writableLocation(StandardPaths.DownloadLocation)
0136 
0137 
0138                         browser.delegate:  Item
0139                         {
0140                             height: GridView.view.cellHeight
0141                             width: GridView.view.cellWidth
0142 
0143                             Maui.ListBrowserDelegate
0144                             {
0145                                 anchors.fill: parent
0146                                 anchors.margins: Maui.Style.space.small
0147                                 iconVisible: true
0148                                 label1.text: model.label
0149                                 iconSource: model.icon
0150                                 imageSource: model.thumbnail
0151                                 template.fillMode: Image.PreserveAspectFit
0152                                 iconSizeHint: height * 0.5
0153                                 checkable: selectionMode
0154 
0155                                 onClicked: (index) =>
0156                                 {
0157                                     _recentGrid.currentIndex = index
0158                                     openPreview(_recentGrid.baseModel, index)
0159                                 }
0160                             }
0161                         }
0162                     }
0163                 }
0164 
0165 
0166                 Loader
0167                 {
0168                     Layout.fillWidth: true
0169                     asynchronous: true
0170                     sourceComponent: RecentSection
0171                     {
0172                         id: _recentMusic
0173                         title: i18n("Music")
0174                         description: i18n("Your most recent music files")
0175 
0176                         list.url: StandardPaths.writableLocation(StandardPaths.MusicLocation)
0177                         list.filters: FB.FM.nameFilters(FB.FMList.AUDIO)
0178 
0179                         browser.delegate: Item
0180                         {
0181                             height: GridView.view.cellHeight
0182                             width: GridView.view.cellWidth
0183 
0184                             AudioCard
0185                             {
0186                                 anchors.fill: parent
0187                                 anchors.margins: Maui.Style.space.small
0188                                 iconSource: model.icon
0189                                 iconSizeHint: Maui.Style.iconSizes.big
0190                                 imageSource: model.thumbnail
0191                                 player.source: model.url
0192                                 isCurrentItem: parent.ListView.isCurrentItem
0193 
0194 
0195                                 label1.text: player.metaData.title && player.metaData.title.length ? player.metaData.title :  model.name
0196                                 label2.text: player.metaData.albumArtist || player.metaData.albumTitle
0197                                 onClicked: (index) =>
0198                                 {
0199                                     _recentMusic.currentIndex = index
0200                                     openPreview(_recentMusic.baseModel, index)
0201                                 }
0202                             }
0203                         }
0204                     }
0205                 }
0206 
0207                 Loader
0208                 {
0209                     Layout.fillWidth: true
0210                     asynchronous: true
0211                     sourceComponent: RecentSection
0212                     {
0213                         id: _recentPics
0214                         title: i18n("Images")
0215                         description: i18n("Your most recent image files")
0216 
0217                         browser.itemSize: 180
0218                         browser.itemHeight: 180
0219                         browser.implicitHeight: 180
0220 
0221                         list.url: StandardPaths.writableLocation(StandardPaths.PicturesLocation)
0222                         list.filters: FB.FM.nameFilters(FB.FMList.IMAGE)
0223 
0224                         //                        url: inx.screenshotsPath()
0225                         //                        filters: FB.FM.nameFilters(FB.FMList.IMAGE)
0226 
0227                         browser.delegate: Item
0228                         {
0229                             height: GridView.view.cellHeight
0230                             width: GridView.view.cellWidth
0231 
0232                             ImageCard
0233                             {
0234                                 anchors.fill: parent
0235                                 anchors.margins: Maui.Style.space.small
0236                                 imageSource: model.thumbnail
0237                                 isCurrentItem: parent.ListView.isCurrentItem
0238                                 onClicked: (index) =>
0239                                 {
0240                                     _recentPics.currentIndex = index
0241                                     openPreview(_recentPics.baseModel, index)
0242                                 }
0243                             }
0244                         }
0245                     }
0246                 }
0247 
0248                 Loader
0249                 {
0250                     Layout.fillWidth: true
0251                     asynchronous: true
0252                     sourceComponent:  DisksSection
0253                     {
0254                         id: _disksSection
0255                     }
0256                 }
0257             }
0258         }
0259     }
0260 }