Warning, /maui/index-fm/src/widgets/views/PathBar.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 import QtGraphicalEffects 1.0
0024 
0025 import org.mauikit.controls 1.3 as Maui
0026 
0027 import org.maui.index 1.0 as Index
0028 
0029 Item
0030 {
0031     id: control
0032 
0033     property int preferredWidth: visible ? Math.max(500, item.implicitWidth): 0
0034 
0035     Behavior on preferredWidth
0036     {
0037         NumberAnimation
0038         {
0039             duration: Maui.Style.units.shortDuration
0040         }
0041     }
0042 
0043     implicitHeight: _loader.item.implicitHeight
0044     implicitWidth: preferredWidth
0045     /**
0046       * url : string
0047       */
0048     property url url
0049 
0050     /**
0051       * pathEntry : bool
0052       */
0053     property bool pathEntry: false
0054 
0055     /**
0056       * item : Item
0057       */
0058     readonly property alias item : _loader.item
0059 
0060     /**
0061       * pathChanged :
0062       */
0063     signal pathChanged(string path)
0064 
0065     /**
0066       * homeClicked :
0067       */
0068     signal homeClicked()
0069 
0070     /**
0071       * placeClicked :
0072       */
0073     signal placeClicked(string path)
0074 
0075     signal menuClicked()
0076 
0077     /**
0078       * placeRightClicked :
0079       */
0080     signal placeRightClicked(string path)
0081 
0082     Loader
0083     {
0084         id: _loader
0085         anchors.fill: parent
0086         asynchronous: true
0087         sourceComponent: Item
0088         {
0089             implicitWidth: _layout.implicitWidth
0090             implicitHeight: _layout.implicitHeight           
0091 
0092             TextField
0093             {
0094                 id: entry
0095                 anchors.fill: parent
0096                 visible: pathEntry
0097                 enabled: visible
0098                 text: control.url
0099                 inputMethodHints: Qt.ImhUrlCharactersOnly | Qt.ImhNoAutoUppercase
0100                 implicitWidth: 500
0101                 horizontalAlignment: Qt.AlignLeft
0102                 onAccepted:
0103                 {
0104                     pathChanged(text)
0105                 }
0106 
0107                 onActiveFocusChanged:
0108                 {
0109                     if(!activeFocus)
0110                     {
0111                         control.pathEntry = false
0112                     }
0113                 }
0114 
0115                 actions: Action
0116                 {
0117                     icon.name: "go-next"
0118                     icon.color: control.Maui.Theme.textColor
0119                     onTriggered:
0120                     {
0121                         entry.accepted()
0122                     }
0123                 }
0124 
0125                 onVisibleChanged:
0126                 {
0127                     if(visible)
0128                     {
0129                         entry.forceActiveFocus()
0130                         entry.selectAll()
0131                     }
0132                 }
0133 
0134                 Keys.enabled: true
0135                 Keys.onEscapePressed: control.pathEntry = false
0136             }
0137 
0138             ScrollView
0139             {
0140                 id: _layout
0141                 visible: !pathEntry
0142                 anchors.fill: parent
0143 
0144                 orientation: Qt.Horizontal
0145                 implicitWidth: contentWidth + leftPadding + rightPadding
0146 
0147                 ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
0148                 ScrollBar.vertical.policy: ScrollBar.AlwaysOff
0149 
0150                 implicitHeight: _listView.currentItem ? _listView.currentItem.implicitHeight + topPadding + bottomPadding : 48
0151                 contentHeight: availableHeight
0152                 leftPadding: 8
0153 
0154                 background: Rectangle
0155                 {
0156                     radius: Maui.Style.radiusV
0157                     color : Maui.Theme.alternateBackgroundColor
0158                 }
0159 
0160                 ListView
0161                 {
0162                     id: _listView
0163 
0164                     Maui.Theme.colorSet: control.Maui.Theme.colorSet
0165                     Maui.Theme.inherit: false
0166 
0167                     orientation: ListView.Horizontal
0168                     clip: true
0169                     spacing: -6
0170                     currentIndex: _pathList.count - 1
0171                     focus: true
0172                     interactive: Maui.Handy.isTouch
0173                     highlightFollowsCurrentItem: true
0174                     snapMode: ListView.NoSnap
0175 
0176                     boundsBehavior: Flickable.StopAtBounds
0177                     boundsMovement :Flickable.StopAtBounds
0178 
0179                     ListView.onAdd: _listView.positionViewAtEnd()
0180                     ListView.onRemove: _listView.positionViewAtEnd()
0181 
0182                     footerPositioning: ListView.OverlayFooter
0183                     footer: ToolButton
0184                     {
0185                         height: parent.height
0186                         flat: true
0187                         icon.name: "filename-space-amarok"
0188                         onClicked:  control.showEntryBar()
0189                     }
0190 
0191                     MouseArea
0192                     {
0193                          z: -1
0194                         anchors.fill: parent
0195                         preventStealing: true
0196                         onClicked:
0197                         {
0198                             console.log("PATHBAR CLICKED")
0199                             control.showEntryBar()
0200                         }
0201                     }
0202 
0203                     model: Maui.BaseModel
0204                     {
0205                         id: _pathModel
0206                         list: Index.PathList
0207                         {
0208                             id: _pathList
0209                             path: control.url
0210                         }
0211                     }
0212 
0213                     delegate: PathBarDelegate
0214                     {
0215                         id: delegate
0216 
0217 //                        height: ListView.view.height
0218                         width: Math.max(Maui.Style.iconSizes.medium * 2, delegate.implicitWidth)
0219 
0220                         onClicked:
0221                         {
0222                             control.placeClicked(model.path)
0223                         }
0224 
0225                         onRightClicked:
0226                         {
0227                             control.placeRightClicked(model.path)
0228                         }
0229 
0230                         onPressAndHold:
0231                         {
0232                             control.placeRightClicked(model.path)
0233                         }
0234                     }
0235                 }
0236             }
0237         }
0238     }
0239 
0240     /**
0241       *
0242       */
0243     function showEntryBar()
0244     {
0245         control.pathEntry = !control.pathEntry
0246 
0247     }
0248 }