diff --git a/src/controls/PathBar.qml b/src/controls/PathBar.qml index 7e9b16c..01a86e2 100644 --- a/src/controls/PathBar.qml +++ b/src/controls/PathBar.qml @@ -1,254 +1,254 @@ /* * Copyright 2018 Camilo Higuita * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import QtQuick 2.9 import QtQuick.Controls 2.2 import QtQuick.Layouts 1.3 import org.kde.kirigami 2.7 as Kirigami import org.kde.mauikit 1.0 as Maui import "private" Item { id: control implicitHeight: Maui.Style.rowHeight property string url : "" property bool pathEntry: false property alias list : _pathList property alias model : _pathModel property alias item : _loader.item signal pathChanged(string path) signal homeClicked() signal placeClicked(string path) signal placeRightClicked(string path) onUrlChanged: append() Kirigami.Theme.colorSet: Kirigami.Theme.View Kirigami.Theme.inherit: false Rectangle { id: pathBarBG anchors.fill: parent color: pathEntry ? Kirigami.Theme.backgroundColor : Kirigami.Theme.backgroundColor radius: Maui.Style.radiusV opacity: 1 border.color: Qt.tint(Kirigami.Theme.textColor, Qt.rgba(Kirigami.Theme.backgroundColor.r, Kirigami.Theme.backgroundColor.g, Kirigami.Theme.backgroundColor.b, 0.7)) border.width: Maui.Style.unit } Loader { id: _loader anchors.fill: parent sourceComponent: pathEntry ? _pathEntryComponent : _pathCrumbsComponent onLoaded: { if(sourceComponent === _pathCrumbsComponent) control.append() } } Maui.BaseModel { id: _pathModel list: _pathList } Maui.PathList { id: _pathList } Component { id: _pathEntryComponent Maui.TextField { id: entry anchors.fill: parent text: control.url Kirigami.Theme.textColor: control.Kirigami.Theme.textColor Kirigami.Theme.backgroundColor: "transparent" horizontalAlignment: Qt.AlignLeft onAccepted: { pathChanged(text) showEntryBar() } background: Rectangle { color: "transparent" } actions.data: ToolButton { icon.name: "go-next" icon.color: control.Kirigami.Theme.textColor onClicked: { pathChanged(entry.text) showEntryBar() } } } } Component { id: _pathCrumbsComponent RowLayout { anchors.fill: parent property alias listView: _listView spacing: 0 clip: true MouseArea { Layout.fillHeight: true Layout.preferredWidth: control.height onClicked: control.homeClicked() hoverEnabled: true Rectangle { anchors.fill: parent radius: Maui.Style.radiusV color: parent.containsMouse ? Qt.rgba(Kirigami.Theme.highlightColor.r, Kirigami.Theme.highlightColor.g, Kirigami.Theme.highlightColor.b, 0.2) : "transparent" Kirigami.Icon { anchors.centerIn: parent - source: Kirigami.Settings.isMobile ? "user-home-sidebar" : "user-home" + source: Qt.platform.os == "android" ? "user-home-sidebar" : "user-home" color: control.Kirigami.Theme.textColor width: Maui.Style.iconSizes.medium height: width } } } Kirigami.Separator { Layout.fillHeight: true color: pathBarBG.border.color } ListView { id: _listView Layout.fillHeight: true Layout.fillWidth: true orientation: ListView.Horizontal clip: true spacing: 0 focus: true interactive: true boundsBehavior: Kirigami.Settings.isMobile ? Flickable.DragOverBounds : Flickable.StopAtBounds model: _pathModel delegate: PathBarDelegate { id: delegate height: parent.height width: Math.max(Maui.Style.iconSizes.medium * 2, implicitWidth) Connections { target: delegate onClicked: { listView.currentIndex = index control.placeClicked(_pathList.get(index).path) } onRightClicked: { control.placeRightClicked(_pathList.get(index).path) } onPressAndHold: { control.placeRightClicked(_pathList.get(index).path) } } } MouseArea { anchors.fill: parent onClicked: showEntryBar() z: -1 } } MouseArea { Layout.fillHeight: true Layout.preferredWidth: control.height onClicked: control.showEntryBar() hoverEnabled: true Rectangle { anchors.fill: parent radius: Maui.Style.radiusV color: parent.containsMouse ? Qt.rgba(Kirigami.Theme.highlightColor.r, Kirigami.Theme.highlightColor.g, Kirigami.Theme.highlightColor.b, 0.2) : "transparent" Kirigami.Icon { anchors.centerIn: parent source: "filename-space-amarok" color: control.Kirigami.Theme.textColor width: Maui.Style.iconSizes.medium height: width } } } } } Component.onCompleted: control.append() function append() { _pathList.path = control.url if(_loader.sourceComponent !== _pathCrumbsComponent) return _loader.item.listView.currentIndex = _loader.item.listView.count-1 _loader.item.listView.positionViewAtEnd() } function showEntryBar() { control.pathEntry = !control.pathEntry } } diff --git a/src/controls/SideBar.qml b/src/controls/SideBar.qml index 849ec76..7ed0b89 100644 --- a/src/controls/SideBar.qml +++ b/src/controls/SideBar.qml @@ -1,267 +1,267 @@ /* * Copyright 2018 Camilo Higuita * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import QtQuick 2.12 import QtQuick.Controls 2.12 import QtQuick.Layouts 1.3 import org.kde.kirigami 2.7 as Kirigami import org.kde.mauikit 1.0 as Maui import "private" Maui.AbstractSideBar { id: control implicitWidth: privateProperties.isCollapsed && collapsed && collapsible ? collapsedSize : preferredWidth width: implicitWidth modal: false position: 1 interactive: false default property alias content : _content.data property alias model : _listBrowser.model property alias count : _listBrowser.count property alias section : _listBrowser.section property alias currentIndex: _listBrowser.currentIndex property int iconSize : Maui.Style.iconSizes.small property bool showLabels: control.width > collapsedSize property QtObject privateProperties : QtObject { property bool isCollapsed: control.collapsed } signal itemClicked(int index) signal itemRightClicked(int index) // Connections // { // target: control.Overlay.overlay // onPressed: control.collapse() // } onModalChanged: visible = true visible: true onCollapsedChanged : { if(!collapsible) return if(!collapsed && modal) { modal = false } if(!modal && !collapsed) { privateProperties.isCollapsed = false } if(collapsed && !modal) { privateProperties.isCollapsed = true } } ColumnLayout { id: _content anchors.fill: parent spacing: 0 Maui.ListBrowser { id: _listBrowser Layout.fillHeight: true Layout.fillWidth: true Layout.topMargin: Maui.Style.space.tiny Layout.bottomMargin: Maui.Style.space.tiny Layout.margins: Maui.Style.unit listView.flickableDirection: Flickable.VerticalFlick verticalScrollBarPolicy: Qt.ScrollBarAlwaysOff //this make sthe app crash delegate: Maui.ListDelegate { id: itemDelegate iconSize: control.iconSize labelVisible: control.showLabels - iconName: model.icon + (Kirigami.Settings.isMobile ? ("-sidebar") : "") + iconName: model.icon + (Qt.platform.os == "android" ? ("-sidebar") : "") leftPadding: Maui.Style.space.tiny rightPadding: Maui.Style.space.tiny Connections { target: itemDelegate onClicked: { control.currentIndex = index control.itemClicked(index) } onRightClicked: { control.currentIndex = index control.itemRightClicked(index) } onPressAndHold: { control.currentIndex = index control.itemRightClicked(index) } } } } MouseArea { id: _handle visible: collapsible && collapsed Layout.preferredHeight: Maui.Style.toolBarHeight Layout.fillWidth: true hoverEnabled: true preventStealing: true propagateComposedEvents: false property int startX property int startY Rectangle { anchors.fill: parent color: _handle.containsMouse || _handle.containsPress ? Qt.rgba(Kirigami.Theme.highlightColor.r, Kirigami.Theme.highlightColor.g, Kirigami.Theme.highlightColor.b, 0.2) : "transparent" Kirigami.Separator { anchors { left: parent.left right: parent.right top: parent.top } height: Maui.Style.unit } Kirigami.Icon { source: privateProperties.isCollapsed ? "sidebar-expand" : "sidebar-collapse" color: _handle.containsMouse || _handle.containsPress ? Kirigami.Theme.highlightColor : Kirigami.Theme.textColor anchors.centerIn: parent width: Maui.Style.iconSizes.medium height: width } } onPositionChanged: { if (!pressed || !control.collapsible || !control.collapsed || !Kirigami.Settings.isMobile) return if(mouse.x > control.collapsedSize) { expand() } mouse.accepted = true } onPressed: { startY = mouse.y startX = mouse.x mouse.accepted = true } onReleased: { if(!control.collapsible) return if(mouse.x > control.width) return if(privateProperties.isCollapsed) expand() else collapse() mouse.accepted = true } } } MouseArea { z: control.modal ? applicationWindow().overlay.z + (control.position > 0 ? +1 : -1) : control.background.parent.z + 1 preventStealing: true anchors.horizontalCenter: parent.right anchors.top: parent.top anchors.bottom: parent.bottom visible: Kirigami.Settings.isMobile enabled: control.collapsed && visible width: Maui.Style.space.large property int startX property int startY onPressed: { startY = mouse.y startX = mouse.x mouse.accepted = true } onPositionChanged: { if (!pressed || !control.collapsible || !control.collapsed || !Kirigami.Settings.isMobile) return if(mouse.x > control.collapsedSize) { expand() }else { collapse() } mouse.accepted = true } } function collapse() { if(collapsible && !privateProperties.isCollapsed) { modal = false privateProperties.isCollapsed = true } } function expand() { if(collapsible && privateProperties.isCollapsed) { modal = true privateProperties.isCollapsed = false } } }