Warning, /maui/index-fm/src/widgets/views/PlacesSideBar.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 Nitrux Latinoamericana S.C.
0003 //
0004 // SPDX-License-Identifier: GPL-3.0-or-later
0005 
0006 
0007 import QtQuick 2.14
0008 import QtQml 2.14
0009 
0010 import QtQuick.Controls 2.14
0011 import QtQuick.Layouts 1.12
0012 
0013 import org.mauikit.controls 1.3 as Maui
0014 import org.mauikit.filebrowsing 1.0 as FB
0015 
0016 Loader
0017 {
0018     id: control
0019     asynchronous: true
0020     active: (control.enabled && control.visible) || item
0021 
0022     readonly property var list: item.list
0023 
0024     sourceComponent: Maui.ListBrowser
0025     {
0026         id: _listBrowser
0027         topPadding: 0
0028         bottomPadding: 0
0029         verticalScrollBarPolicy: ScrollBar.AlwaysOff
0030 
0031         readonly property alias list : placesList
0032 
0033         signal placeClicked (string path, var mouse)
0034 
0035         holder.visible: count === 0
0036         holder.title: i18n("Bookmarks!")
0037         holder.body: i18n("Your bookmarks will be listed here")
0038 
0039         Binding on currentIndex
0040         {
0041             value: placesList.indexOfPath(currentBrowser.currentPath)
0042             restoreMode: Binding.RestoreBindingOrValue
0043         }
0044 
0045         onPlaceClicked: (path, mouse) =>
0046                         {
0047                             if(mouse.modifiers & Qt.ControlModifier)
0048                             {
0049                                 openTab(path)
0050                             }else if(mouse.modifiers & Qt.AltModifier)
0051                             {
0052                                 currentTab.split(path)
0053                             }
0054                             else
0055                             {
0056                                 currentBrowser.openFolder(path)
0057                             }
0058 
0059                             if(_sideBarView.sideBar.collapsed)
0060                             _sideBarView.sideBar.close()
0061 
0062                             if(_stackView.depth === 2)
0063                             _stackView.pop()
0064 
0065                             if(control.collapsed)
0066                             control.close()
0067                         }
0068 
0069         //    onContentDropped:
0070         //    {
0071         //        placesList.addPlace(drop.text)
0072         //    }
0073 
0074         Loader
0075         {
0076             id: _menuLoader
0077 
0078             asynchronous: true
0079             sourceComponent: Maui.ContextualMenu
0080             {
0081                 id: _menu
0082 
0083                 property string path
0084                 property int bookmarkIndex : -1
0085 
0086                 onClosed: _menu.bookmarkIndex = -1
0087 
0088                 MenuItem
0089                 {
0090                     text: i18n("Open in New Tab")
0091                     icon.name: "tab-new"
0092                     onTriggered: openTab(_menu.path)
0093                 }
0094 
0095                 MenuItem
0096                 {
0097                     enabled: control.isDir && Maui.Handy.isLinux
0098                     text: i18n("Open in New Window")
0099                     icon.name: "window-new"
0100                     onTriggered: inx.openNewWindow(_menu.path)
0101                 }
0102 
0103                 MenuItem
0104                 {
0105                     enabled: root.currentTab.count === 1
0106                     text: i18n("Open in Split View")
0107                     icon.name: "view-split-left-right"
0108                     onTriggered: currentTab.split(_menu.path, Qt.Horizontal)
0109                 }
0110 
0111                 MenuSeparator{}
0112 
0113                 MenuItem
0114                 {
0115                     enabled: _menu.bookmarkIndex >= 0
0116                     text: i18n("Remove")
0117                     icon.name: "edit-delete"
0118                     Maui.Theme.textColor: Maui.Theme.negativeTextColor
0119                     onTriggered: placesList.removePlace(_menu.bookmarkIndex)
0120                 }
0121             }
0122         }
0123 
0124         flickable.topMargin: Maui.Style.contentMargins
0125         flickable.bottomMargin: Maui.Style.contentMargins
0126         flickable.header: Loader
0127         {
0128             //            asynchronous: true
0129             width: parent.width
0130             //                height: item ? item.implicitHeight : 0
0131             active: appSettings.quickSidebarSection
0132             visible: active
0133 
0134             sourceComponent: Item
0135             {
0136                 implicitHeight: _quickSection.implicitHeight
0137 
0138                 GridLayout
0139                 {
0140                     id: _quickSection
0141                     width: Math.min(parent.width, 180)
0142                     anchors.centerIn: parent
0143                     rows: 3
0144                     columns: 3
0145                     columnSpacing: Maui.Style.space.small
0146                     rowSpacing: Maui.Style.space.small
0147 
0148                     Repeater
0149                     {
0150                         model: inx.quickPaths()
0151 
0152                         delegate: Maui.GridBrowserDelegate
0153                         {
0154                             Layout.preferredHeight: Math.min(50, width)
0155                             Layout.preferredWidth: 50
0156                             Layout.fillWidth: true
0157                             Layout.fillHeight: true
0158                             Layout.columnSpan: modelData.path === "overview:///" ? 2 : 1
0159 
0160                             isCurrentItem: modelData.path === "overview:///" ? _stackView.depth === 2 : (currentBrowser.currentPath === modelData.path && _stackView.depth === 1)
0161                             iconSource: modelData.icon +  (Qt.platform.os == "android" || Qt.platform.os == "osx" ? ("-sidebar") : "")
0162                             iconSizeHint: Maui.Style.iconSize
0163                             template.isMask: true
0164                             label1.text: modelData.label
0165                             labelsVisible: false
0166                             tooltipText: modelData.label
0167                             flat: false
0168                             onClicked:
0169                             {
0170                                 if(modelData.path === "overview:///")
0171                                 {
0172                                     _stackView.push(_homeViewComponent)
0173                                     if(control.collapsed)
0174                                         control.close()
0175                                     return
0176                                 }
0177 
0178                                 placeClicked(modelData.path, mouse)
0179                             }
0180 
0181                             onRightClicked:
0182                             {
0183                                 _menuLoader.item.path = modelData.path
0184                                 _menuLoader.item.show()
0185                             }
0186 
0187                             onPressAndHold:
0188                             {
0189                                 _menuLoader.item.path = modelData.path
0190                                 _menuLoader.item.show()
0191                             }
0192                         }
0193                     }
0194                 }
0195             }
0196         }
0197 
0198         model: Maui.BaseModel
0199         {
0200             id: placesModel
0201             list: FB.PlacesList
0202             {
0203                 id: placesList
0204                 groups: appSettings.sidebarSections
0205             }
0206         }
0207 
0208         Component.onCompleted:
0209         {
0210             _listBrowser.flickable.positionViewAtBeginning()
0211         }
0212 
0213         delegate: Maui.ListDelegate
0214         {
0215             isCurrentItem: ListView.isCurrentItem && _stackView.depth === 1
0216             width: ListView.view.width
0217 
0218             iconSize: Maui.Style.iconSize
0219             label: model.label
0220             iconName: model.icon +  (Qt.platform.os == "android" || Qt.platform.os == "osx" ? ("-sidebar") : "")
0221             iconVisible: true
0222             template.isMask: iconSize <= Maui.Style.iconSizes.medium
0223 
0224             template.content: ToolButton
0225             {
0226                 visible: placesList.isDevice(index) && placesList.setupNeeded(index)
0227                 icon.name: "media-mount"
0228                 flat: true
0229                 icon.height: Maui.Style.iconSizes.small
0230                 icon.width: Maui.Style.iconSizes.small
0231                 onClicked: placesList.requestSetup(index)
0232             }
0233 
0234             function mount()
0235             {
0236                 placesList.requestSetup(index);
0237             }
0238 
0239             onClicked:
0240             {
0241                 if( placesList.isDevice(index) && placesList.setupNeeded(index))
0242                 {
0243                     notify(model.icon, model.label, i18n("This device needs to be mounted before accessing it. Do you want to set up this device?"), mount, i18n("Mount"))
0244                 }
0245 
0246                 placeClicked(model.path, mouse)
0247             }
0248 
0249             onRightClicked:
0250             {
0251                 _menuLoader.item.path = model.path
0252                 _menuLoader.item.bookmarkIndex = index
0253                 _menuLoader.item.show()
0254             }
0255 
0256             onPressAndHold:
0257             {
0258                 _menuLoader.item.path = model.path
0259                 _menuLoader.item.bookmarkIndex = index
0260                 _menuLoader.item.show()
0261             }
0262         }
0263 
0264         section.property: "type"
0265         section.criteria: ViewSection.FullString
0266         section.delegate: Maui.LabelDelegate
0267         {
0268             width: ListView.view.width
0269             label: section
0270             isSection: true
0271             //                height: Maui.Style.toolBarHeightAlt
0272         }
0273     }
0274 }
0275 
0276