Warning, /maui/booth/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 QtQuick.Controls 2.14
0009 import QtQuick.Layouts 1.3
0010 import org.kde.mauikit 1.2 as Maui
0011 import org.kde.kirigami 2.6 as Kirigami
0012 
0013 Maui.SideBar
0014 {
0015     id: control
0016 
0017     property alias list : placesList
0018 
0019     signal placeClicked (string path)
0020 
0021     collapsible: true
0022     collapsedSize: stick ?  Maui.Style.iconSizes.medium + (Maui.Style.space.medium*4) - Maui.Style.space.tiny : 0
0023     collapsed : !root.isWide
0024     stick: Maui.FM.loadSettings("STICK_SIDEBAR", "UI", true)
0025     preferredWidth: Math.min(Kirigami.Units.gridUnit * (Maui.Handy.isWindows ?  15 : 11), root.width)
0026     iconSize: privateProperties.isCollapsed && stick ? Maui.Style.iconSizes.medium : Maui.Style.iconSizes.small
0027 
0028     Behavior on iconSize
0029     {
0030         NumberAnimation
0031         {
0032             duration: Kirigami.Units.shortDuration
0033             easing.type: Easing.InOutQuad
0034         }
0035     }
0036 
0037     onPlaceClicked:
0038     {
0039         currentBrowser.openFolder(path)
0040         if(placesSidebar.modal)
0041             placesSidebar.collapse()
0042     }
0043 
0044     model: Maui.BaseModel
0045     {
0046         list:  Maui.PlacesList
0047         {
0048             id: placesList
0049 
0050             groups: [
0051                     Maui.FMList.QUICK_PATH,
0052                     Maui.FMList.PLACES_PATH,
0053                     Maui.FMList.REMOTE_PATH,
0054                     Maui.FMList.REMOVABLE_PATH,
0055                     Maui.FMList.DRIVES_PATH]
0056 
0057             onBookmarksChanged:
0058             {
0059                 syncSidebar(currentPath)
0060             }
0061         }
0062     }
0063 
0064     delegate: Maui.ListDelegate
0065     {
0066         id: itemDelegate
0067         width: ListView.view.width
0068         iconSize: control.iconSize
0069         labelVisible: control.showLabels
0070         label: model.label
0071         count: model.count > 0 ? model.count : ""
0072         iconName: model.icon +  (Qt.platform.os == "android" || Qt.platform.os == "osx" ? ("-sidebar") : "")
0073         iconVisible: true
0074 //        template.leftMargin: privateProperties.isCollapsed && stick ? 0 : Maui.Style.space.medium
0075 
0076         onClicked:
0077         {
0078             control.currentIndex = index
0079             placesList.clearBadgeCount(index)
0080 
0081             placeClicked(model.path)
0082             if(control.collapsed)
0083                 control.collapse()
0084         }
0085 
0086         onRightClicked:
0087         {
0088             control.currentIndex = index
0089             _menu.popup()
0090         }
0091 
0092         onPressAndHold:
0093         {
0094             control.currentIndex = index
0095             _menu.popup()
0096         }
0097     }
0098 
0099     section.property: !showLabels ? "" : "type"
0100     section.criteria: ViewSection.FullString
0101     section.delegate: Maui.LabelDelegate
0102     {
0103         id: delegate
0104         width: control.width
0105         label: section
0106         labelTxt.font.pointSize: Maui.Style.fontSizes.big
0107         isSection: true
0108         height: Maui.Style.toolBarHeightAlt
0109 
0110         onClicked:
0111         {
0112             placesList.toggleSection(Maui.FMList.QUICK_PATH)
0113         }
0114     }
0115 
0116     onContentDropped:
0117     {
0118         placesList.addPlace(drop.text)
0119     }
0120 
0121     Menu
0122     {
0123         id: _menu
0124 
0125         MenuItem
0126         {
0127             text: i18n("Open in new tab")
0128             icon.name: "tab-new"
0129             onTriggered: openTab(control.model.get(placesSidebar.currentIndex).path)
0130         }
0131 
0132         MenuItem
0133         {
0134             visible: root.currentTab.count === 1 && root.supportSplit
0135             text: i18n("Open in split view")
0136             icon.name: "view-split-left-right"
0137             onTriggered: currentTab.split(control.model.get(placesSidebar.currentIndex).path, Qt.Horizontal)
0138         }
0139 
0140         MenuSeparator{}
0141 
0142         MenuItem
0143         {
0144             text: i18n("Remove")
0145             Kirigami.Theme.textColor: Kirigami.Theme.negativeTextColor
0146             onTriggered: list.removePlace(control.currentIndex)
0147         }
0148     }
0149 }