diff --git a/src/controls/FileBrowser.qml b/src/controls/FileBrowser.qml index 404f9f0..2af5b84 100644 --- a/src/controls/FileBrowser.qml +++ b/src/controls/FileBrowser.qml @@ -1,1054 +1,1053 @@ import QtQuick 2.9 import QtQuick.Controls 2.5 import QtQuick.Layouts 1.3 import org.kde.kirigami 2.7 as Kirigami import org.kde.mauikit 1.0 as Maui import "private" Maui.Page { id: control /* Controlc color scheming */ ColorScheme {id: colorScheme} property alias colorScheme : colorScheme /***************************/ property alias trackChanges: modelList.trackChanges property alias saveDirProps: modelList.saveDirProps property string currentPath: Maui.FM.homePath() property var copyItems : [] property var cutItems : [] property var indexHistory : [] property bool isCopy : false property bool isCut : false property bool selectionMode : false property bool group : false property bool showEmblems: true property alias selectionBar : selectionBarLoader.item property alias model : folderModel property alias list : modelList property alias browser : viewLoader.item property var currentFMList : modelList property alias previewer : previewer property alias menu : browserMenu.actions property alias itemMenu: itemMenu property alias holder: holder property alias dialog : dialogLoader.item property alias goUpButton : goUpButton property alias currentPathType : modelList.pathType property int thumbnailsSize : iconSizes.large signal itemClicked(int index) signal itemDoubleClicked(int index) signal itemRightClicked(int index) signal itemLeftEmblemClicked(int index) signal itemRightEmblemClicked(int index) signal rightClicked() signal newBookmark(var paths) margins: 0 focus: true Loader { id: dialogLoader } Component { id: removeDialogComponent Maui.Dialog { property var items: [] title: qsTr("Delete files?") message: qsTr("If you are sure you want to delete the files click on Accept, otherwise click on Cancel") rejectButton.text: qsTr("Cancel") acceptButton.text: qsTr("Accept") onRejected: close() onAccepted: { if(control.selectionBar && control.selectionBar.visible) { control.selectionBar.clear() control.selectionBar.animate("red") } control.remove(items) close() } } } Component { id: newFolderDialogComponent Maui.NewDialog { title: qsTr("New folder") message: qsTr("Create a new folder with a custom name") acceptButton.text: qsTr("Create") onFinished: list.createDir(text) rejectButton.visible: false } } Component { id: newFileDialogComponent Maui.NewDialog { title: qsTr("New file") message: qsTr("Create a new file with a custom name and extension") acceptButton.text: qsTr("Create") onFinished: Maui.FM.createFile(control.currentPath, text) rejectButton.visible: false } } Component { id: renameDialogComponent Maui.NewDialog { title: qsTr("Rename file") message: qsTr("Rename a file or folder to a new custom name") textEntry.text: list.get(browser.currentIndex).label textEntry.placeholderText: qsTr("New name...") onFinished: Maui.FM.rename(itemMenu.items[0].path, textEntry.text) onRejected: close() acceptText: qsTr("Rename") rejectText: qsTr("Cancel") } } Component { id: shareDialogComponent Maui.ShareDialog {} } Component { id: tagsDialogComponent Maui.TagsDialog { onTagsReady: composerList.updateToUrls(tags) } } BrowserMenu { id: browserMenu // width: unit *200 z : control.z +1 } Maui.FilePreviewer { id: previewer parent: parent onShareButtonClicked: control.shareFiles([url]) } Maui.BaseModel { id: folderModel list: modelList } Maui.FMList { id: modelList preview: true path: currentPath foldersFirst: true onSortByChanged: if(group) groupBy() onContentReadyChanged: console.log("CONTENT READY?", contentReady) onWarning: { notify("dialog-information", "An error happened", message) } onProgress: { if(percent === 100) _progressBar.value = 0 else _progressBar.value = percent/100 } } FileMenu { id: itemMenu width: unit *200 onBookmarkClicked: control.newBookmark([items[0].path]) onCopyClicked: { if(items.length) control.copy(items) } onCutClicked: { if(items.length) control.cut(items) } onTagsClicked: { if(items.length) { dialogLoader.sourceComponent = tagsDialogComponent if(items.length > 1 && control.selectionBar) dialog.composerList.urls = control.selectionBar.selectedPaths else dialog.composerList.urls = items[0].path dialog.open() } } onRenameClicked: { if(items.length === 1) { dialogLoader.sourceComponent = renameDialogComponent dialog.open() } } // onSaveToClicked: // { // fmDialog.saveDialog = false // fmDialog.multipleSelection = true // fmDialog.onlyDirs= true // var myPath = path // var paths = browser.selectionBar.selectedPaths // fmDialog.show(function(paths) // { // inx.copy(myPath, paths) // }) // } onRemoveClicked: { dialogLoader.sourceComponent= removeDialogComponent dialog.items = items dialog.open() } onShareClicked: { if(items.length) control.shareFiles([items[0].path]) } } Component { id: listViewBrowser Maui.ListBrowser { showPreviewThumbnails: modelList.preview showEmblem: selectionMode rightEmblem: isMobile ? "document-share" : "" leftEmblem: "list-add" showDetailsInfo: true // itemSize: thumbnailsSize model: folderModel section.delegate: Maui.LabelDelegate { id: delegate label: section labelTxt.font.pointSize: fontSizes.big isSection: true boldLabel: true height: toolBarHeightAlt } } } Component { id: gridViewBrowser Maui.GridBrowser { itemSize : thumbnailsSize + fontSizes.default showEmblem: selectionMode showPreviewThumbnails: modelList.preview rightEmblem: isMobile ? "document-share" : "" leftEmblem: "list-add" model: folderModel } } Component { id: millerViewBrowser Kirigami.ColumnView { id: _millerColumns // columnWidth: Kirigami.Units.gridUnit * 22 // fillWidth: true columnResizeMode: Kirigami.ColumnView.DynamicColumns signal itemClicked(int index) signal itemDoubleClicked(int index) signal itemRightClicked(int index) signal rightEmblemClicked(int index) signal leftEmblemClicked(int index) Maui.PathList { id: _millerList path: control.currentPath } Maui.BaseModel { id: _millerModel list: _millerList } Repeater { id: _repeater model: _millerModel onItemAdded: _millerColumns.currentIndex = _millerColumns.count -1 Item { property alias list : _millersFMList Maui.FMList { id: _millersFMList preview: modelList.preview path: model.path foldersFirst: modelList.foldersFirst onWarning: { notify("dialog-information", "An error happened", message) } onProgress: { if(percent === 100) _progressBar.value = 0 else _progressBar.value = percent/100 } } Maui.ListBrowser { id: _millerListView anchors.fill: parent showPreviewThumbnails: modelList.preview showEmblem: selectionMode rightEmblem: isMobile ? "document-share" : "" leftEmblem: "list-add" showDetailsInfo: true // itemSize: thumbnailsSize onItemClicked: { control.currentFMList = _millersFMList _millerColumns.itemClicked(index) } // onItemDoubleClicked: // { // modelList.path = _millersFMList.path // _millerColumns.onItemDoubleClicked(index) // } onItemRightClicked: _millerColumns.itemRightClicked(index) onRightEmblemClicked: _millerColumns.rightEmblemClicked(index) onLeftEmblemClicked: _millerColumns.leftEmblemClicked(index) model:Maui.BaseModel { list: _millersFMList } section.delegate: Maui.LabelDelegate { id: delegate label: section labelTxt.font.pointSize: fontSizes.big isSection: true boldLabel: true height: toolBarHeightAlt } } } } } } Connections { target: browser onItemClicked: { browser.currentIndex = index indexHistory.push(index) control.itemClicked(index) } onItemDoubleClicked: { browser.currentIndex = index indexHistory.push(index) control.itemDoubleClicked(index) } onItemRightClicked: { itemMenu.show([modelList.get(index)]) control.itemRightClicked(index) } onLeftEmblemClicked: { control.addToSelection(modelList.get(index), true) control.itemLeftEmblemClicked(index) } onRightEmblemClicked: { isAndroid ? Maui.Android.shareDialog([modelList.get(index).path]) : shareDialog.show([modelList.get(index).path]) control.itemRightEmblemClicked(index) } onAreaClicked: { if(!isMobile && mouse.button === Qt.RightButton) browserMenu.show() else return control.rightClicked() } onAreaRightClicked: browserMenu.show() } Maui.Holder { id: holder anchors.fill : parent z: -1 visible: !modelList.pathExists || modelList.pathEmpty || !modelList.contentReady emoji: if(modelList.pathExists && modelList.pathEmpty) "qrc:/assets/MoonSki.png" else if(!modelList.pathExists) "qrc:/assets/ElectricPlug.png" else if(!modelList.contentReady && currentPathType === Maui.FMList.SEARCH_PATH) "qrc:/assets/animat-search-color.gif" else if(!modelList.contentReady) "qrc:/assets/animat-rocket-color.gif" isGif: !modelList.contentReady isMask: false title : if(modelList.pathExists && modelList.pathEmpty) qsTr("Folder is empty!") else if(!modelList.pathExists) qsTr("Folder doesn't exists!") else if(!modelList.contentReady && currentPathType === Maui.FMList.SEARCH_PATH) qsTr("Searching for content!") else if(!modelList.contentReady) qsTr("Loading content!") body: if(modelList.pathExists && modelList.pathEmpty) qsTr("You can add new files to it") else if(!modelList.pathExists) qsTr("Create Folder?") else if(!modelList.contentReady && currentPathType === Maui.FMList.SEARCH_PATH) qsTr("This might take a while!") else if(!modelList.contentReady) qsTr("Almost ready!") emojiSize: iconSizes.huge onActionTriggered: { if(!modelList.pathExists) { Maui.FM.createDir(control.currentPath.slice(0, control.currentPath.lastIndexOf("/")), control.currentPath.split("/").pop()) control.openFolder(modelList.parentPath) } } } Keys.onSpacePressed: previewer.show(modelList.get(browser.currentIndex).path) headBarExit: false headBar.visible: currentPathType !== Maui.FMList.APPS_PATH altToolBars: isMobile headBar.rightContent:[ ToolButton { icon.name: "view-list-icons" onClicked: list.viewType = Maui.FMList.ICON_VIEW checkable: false checked: list.viewType === Maui.FMList.ICON_VIEW icon.width: iconSizes.medium autoExclusive: true }, ToolButton { icon.name: "view-list-details" onClicked: list.viewType = Maui.FMList.LIST_VIEW icon.width: iconSizes.medium checked: list.viewType === Maui.FMList.LIST_VIEW autoExclusive: true }, ToolButton { icon.name: "view-file-columns" onClicked: list.viewType = Maui.FMList.MILLERS_VIEW icon.width: iconSizes.medium checked: list.viewType === Maui.FMList.MILLERS_VIEW autoExclusive: true }, Kirigami.ActionToolBar { Layout.fillWidth: true z: 999 hiddenActions: browserMenu.actions display: isMobile ? ToolButton.IconOnly : ToolButton.TextBesideIcon actions: [ Kirigami.Action { icon.name: "view-sort" text: qsTr("Sort") Kirigami.Action { text: qsTr("Folders first") checked: list.foldersFirst onTriggered: list.foldersFirst = !list.foldersFirst } Kirigami.Action { text: qsTr("Type") checked: list.sortBy === Maui.FMList.MIME onTriggered: list.sortBy = Maui.FMList.MIME } Kirigami.Action { text: qsTr("Date") checked: list.sortBy === Maui.FMList.DATE onTriggered: list.sortBy = Maui.FMList.DATE } Kirigami.Action { text: qsTr("Modified") checked: list.sortBy === Maui.FMList.MODIFIED onTriggered: list.sortBy = Maui.FMList.MODIFIED } Kirigami.Action { text: qsTr("Size") checked: list.sortBy === Maui.FMList.SIZE onTriggered: list.sortBy = Maui.FMList.SIZE } Kirigami.Action { text: qsTr("Name") checked: list.sortBy === Maui.FMList.LABEL onTriggered: list.sortBy = Maui.FMList.LABEL } Kirigami.Action { id: groupAction text: qsTr("Group") checked: group onTriggered: { group = !group if(group) groupBy() else browser.section.property = "" } } }, Kirigami.Action { text: qsTr("Select") icon.name: "item-select" checkable: false checked: selectionMode onTriggered: selectionMode = !selectionMode } ] } ] headBar.leftContent: [ ToolButton { icon.name: "go-previous" onClicked: control.goBack() }, ToolButton { id: goUpButton visible: true icon.name: "go-up" onClicked: control.goUp() }, ToolButton { icon.name: "go-next" onClicked: control.goNext() } ] footBar.visible: false Component { id: selectionBarComponent Maui.SelectionBar { anchors.fill: parent onIconClicked: _selectionBarmenu.popup() onExitClicked: clearSelection() Menu { id: _selectionBarmenu MenuItem { text: qsTr("Copy...") onTriggered: { if(control.selectionBar) control.selectionBar.animate("#6fff80") control.copy(selectedItems) console.log(selectedItems) _selectionBarmenu.close() } } MenuItem { text: qsTr("Cut...") onTriggered: { if(control.selectionBar) control.selectionBar.animate("#fff44f") control.cut(selectedItems) _selectionBarmenu.close() } } MenuItem { text: qsTr("Share") onTriggered: { control.shareFiles(selectedPaths) _selectionBarmenu.close() } } MenuSeparator{} MenuItem { text: qsTr("Remove...") Kirigami.Theme.textColor: dangerColor onTriggered: { dialogLoader.sourceComponent= removeDialogComponent dialog.items = selectedItems dialog.open() _selectionBarmenu.close() } } } } } ColumnLayout { anchors.fill: parent visible: !holder.visible z: holder.z + 1 spacing: 0 Loader { id: viewLoader z: holder.z + 1 sourceComponent: switch(list.viewType) { case Maui.FMList.ICON_VIEW: return gridViewBrowser case Maui.FMList.LIST_VIEW: return listViewBrowser case Maui.FMList.MILLERS_VIEW: return millerViewBrowser } onLoaded: { if(sourceComponent !== millerViewBrowser) control.currentFMList = modelList } Layout.topMargin: list.viewType == Maui.FMList.ICON_VIEW ? contentMargins * 2 : unit Layout.margins: 0 Layout.fillWidth: true Layout.fillHeight: true } Loader { id: selectionBarLoader - visible: control.selectionBar && control.selectionBar.visible Layout.fillWidth: true - Layout.preferredHeight: visible ? control.selectionBar.barHeight: 0 + Layout.preferredHeight: control.selectionBar && control.selectionBar.visible ? control.selectionBar.barHeight: 0 Layout.leftMargin: contentMargins * (isMobile ? 3 : 2) Layout.rightMargin: contentMargins * (isMobile ? 3 : 2) - Layout.bottomMargin: visible ? contentMargins*2 : 0 + Layout.bottomMargin: control.selectionBar && control.selectionBar.visible ? contentMargins*2 : 0 z: holder.z +1 } ProgressBar { id: _progressBar Layout.fillWidth: true Layout.alignment: Qt.AlignBottom Layout.preferredHeight: visible ? iconSizes.medium : 0 visible: value > 0 } } // PinchArea // { // anchors.fill: parent // // property real initialWidth // property real initialHeight // // onPinchStarted: // { // console.log("pinch started") // } // // onPinchUpdated: // { // console.log(pinch.scale) // } // // onPinchFinished: // { // console.log("pinch finished") // } // } onThumbnailsSizeChanged: { if(trackChanges && saveDirProps) Maui.FM.setDirConf(currentPath+"/.directory", "MAUIFM", "IconSize", thumbnailsSize) else Maui.FM.saveSettings("IconSize", thumbnailsSize, "SETTINGS") if(list.viewType == Maui.FMList.ICON_VIEW) browser.adaptGrid() } function shareFiles(urls) { if(urls.length <= 0) return; if(isAndroid) Maui.Android.shareDialog(urls[0]) else { dialogLoader.sourceComponent= shareDialogComponent dialog.show(urls) } } function openItem(index) { var item = control.currentFMList.get(index) var path = item.path switch(currentPathType) { case Maui.FMList.APPS_PATH: if(item.path.endsWith("/")) populate(path) else Maui.FM.runApplication(path) break case Maui.FMList.CLOUD_PATH: if(item.mime === "inode/directory") control.openFolder(path) else Maui.FM.openCloudItem(item) break; default: if(selectionMode && !Maui.FM.isDir(item.path)) addToSelection(item, true) else { if(Maui.FM.isDir(path)) control.openFolder(path) else if(Maui.FM.isApp(path)) control.launchApp(path) else { if (isMobile) previewer.show(path) else control.openFile(path) } } } } function launchApp(path) { Maui.FM.runApplication(path, "") } function openFile(path) { Maui.FM.openUrl(path) } function openFolder(path) { populate(path) } function setPath(path) { currentPath = path } function populate(path) { if(!path.length) return; browser.currentIndex = 0 setPath(path) if(currentPathType === Maui.FMList.PLACES_PATH) { if(trackChanges && saveDirProps) { var conf = Maui.FM.dirConf(path+"/.directory") var iconsize = conf["iconsize"] || iconSizes.large thumbnailsSize = parseInt(iconsize) }else { thumbnailsSize = parseInt(Maui.FM.loadSettings("IconSize", "SETTINGS", thumbnailsSize)) } } if(list.viewType == Maui.FMList.ICON_VIEW) browser.adaptGrid() } function goBack() { populate(modelList.previousPath) browser.currentIndex = indexHistory.pop() // browser.positionViewAtIndex(browser.currentIndex, ListView.Center) } function goNext() { openFolder(modelList.posteriorPath) } function goUp() { openFolder(modelList.parentPath) } function refresh() { var pos = browser.contentY modelList.refresh() browser.contentY = pos } function addToSelection(item, append) { selectionBarLoader.sourceComponent= selectionBarComponent selectionBar.append(item) } function clearSelection() { clean() // selectionMode = false } function clean() { copyItems = [] cutItems = [] browserMenu.pasteFiles = 0 if(control.selectionBar && control.selectionBar.visible) selectionBar.clear() } function copy(items) { copyItems = items isCut = false isCopy = true } function cut(items) { cutItems = items isCut = true isCopy = false } function paste() { if(isCopy) list.copyInto(copyItems, currentPath) else if(isCut) { list.cutInto(cutItems, currentPath) clearSelection() } } function remove(items) { for(var i in items) Maui.FM.removeFile(items[i].path) } function bookmarkFolder(paths) { newBookmark(paths) } function zoomIn() { control.thumbnailsSize = control.thumbnailsSize + 8 } function zoomOut() { var newSize = control.thumbnailsSize - 8 if(newSize >= iconSizes.small) control.thumbnailsSize = newSize } function groupBy() { var prop = "" var criteria = ViewSection.FullString switch(modelList.sortBy) { case Maui.FMList.LABEL: prop = "label" criteria = ViewSection.FirstCharacter break; case Maui.FMList.MIME: prop = "mime" break; case Maui.FMList.SIZE: prop = "size" break; case Maui.FMList.DATE: prop = "date" break; case Maui.FMList.MODIFIED: prop = "modified" break; } list.viewType = Maui.FMList.LIST_VIEW if(!prop) { browser.section.property = "" return } browser.section.property = prop browser.section.criteria = criteria } } diff --git a/src/controls/GridView.qml b/src/controls/GridView.qml index 856e7c3..122682a 100644 --- a/src/controls/GridView.qml +++ b/src/controls/GridView.qml @@ -1,135 +1,160 @@ /* * 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.0 import QtQuick.Controls 2.2 import QtQuick.Layouts 1.3 import QtQuick.Controls.impl 2.3 import org.kde.mauikit 1.0 as Maui import org.kde.kirigami 2.2 as Kirigami import QtGraphicalEffects 1.0 ScrollView { id: control property int cellWidth: unit * 200 property int cellHeight: unit * 200 spacing: space.medium property int itemSize: 0 property alias model : gridView.model property alias delegate : gridView.delegate property alias contentY: gridView.contentY property alias currentIndex : gridView.currentIndex property alias count : gridView.count property alias cacheBuffer : gridView.cacheBuffer property alias topMargin: gridView.topMargin property alias bottomMargin: gridView.bottomMargin property alias rightMargin: gridView.rightMargin property alias leftMarging: gridView.leftMargin property alias header : gridView.header property bool centerContent: false property bool adaptContent: false signal areaClicked(var mouse) signal areaRightClicked() GridView { id: gridView anchors { leftMargin: control.ScrollBar.visible ? 0 : control.ScrollBar.width } flow: GridView.FlowLeftToRight clip: true focus: true anchors.horizontalCenter: centerContent ? parent.horizontalCenter : undefined width: centerContent ? Math.min(model.count, Math.floor(parent.width/cellWidth))*cellWidth : parent.width height: parent.height cellWidth: control.cellWidth cellHeight: control.cellHeight // maximumFlickVelocity: albumSize*8 boundsBehavior: !isMobile? Flickable.StopAtBounds : Flickable.OvershootBounds flickableDirection: Flickable.AutoFlickDirection snapMode: GridView.SnapToRow highlightMoveDuration: 0 interactive: true onWidthChanged: adaptContent? control.adaptGrid() : undefined + PinchArea + { + anchors.fill: parent + z: -1 + onPinchStarted: + { + console.log("pinch started") + } + + onPinchUpdated: + { + + } - MouseArea + onPinchFinished: + { + console.log("pinch finished") + resizeContent(pinch.scale) + } + + MouseArea { anchors.fill: parent - z: -1 + propagateComposedEvents: true acceptedButtons: Qt.RightButton | Qt.LeftButton onClicked: control.areaClicked(mouse) onPressAndHold: control.areaRightClicked() onWheel: { if (wheel.modifiers & Qt.ControlModifier) { if (wheel.angleDelta.y != 0) { var factor = 1 + wheel.angleDelta.y / 600; - if(factor > 1) - { - control.itemSize = control.itemSize + 10 - control.cellHeight = control.cellHeight + 10 - control.cellWidth = control.cellWidth + 10 - } - else if((control.itemSize - 10) > iconSizes.small) - { - control.itemSize = control.itemSize - 10 - control.cellHeight = control.cellHeight - 10 - control.cellWidth = control.cellWidth - 10 - } - - if(adaptContent) - control.adaptGrid() + control.resizeContent(factor) } - } + }else + wheel.accepted = false } - } + } + } } + function resizeContent(factor) + { + if(factor > 1) + { + control.itemSize = control.itemSize + 10 + control.cellHeight = control.cellHeight + 10 + control.cellWidth = control.cellWidth + 10 + } + else if((control.itemSize - 10) > iconSizes.small) + { + control.itemSize = control.itemSize - 10 + control.cellHeight = control.cellHeight - 10 + control.cellWidth = control.cellWidth - 10 + } + + if(adaptContent) + control.adaptGrid() + } function adaptGrid() { var amount = parseInt(gridView.width / (itemSize + spacing), 10) var leftSpace = parseInt(gridView.width - ( amount * (itemSize + spacing) ), 10) var size = parseInt((itemSize + spacing) + (parseInt(leftSpace/amount, 10)), 10) size = size > itemSize + spacing ? size : itemSize + spacing cellWidth = size } } diff --git a/src/controls/IconDelegate.qml b/src/controls/IconDelegate.qml index 82fe3db..7ffc5a1 100644 --- a/src/controls/IconDelegate.qml +++ b/src/controls/IconDelegate.qml @@ -1,353 +1,352 @@ /* * 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.0 import QtQuick.Controls 2.2 import QtQuick.Layouts 1.3 import org.kde.kirigami 2.2 as Kirigami import org.kde.mauikit 1.0 as Maui import QtGraphicalEffects 1.0 import "private" ItemDelegate { id: control /* Controlc color scheming */ ColorScheme { id: colorScheme } property alias colorScheme : colorScheme /***************************/ property bool isDetails : false property bool showDetailsInfo: false property int folderSize : iconSize property int emblemSize: iconSizes.medium property bool isHovered : hovered property bool showLabel : true property bool showEmblem : false property bool showSelectionBackground : true property bool showTooltip : false property bool showThumbnails : false property bool emblemAdded : false property bool keepEmblemOverlay : false property bool isCurrentListItem : ListView.isCurrentItem property color labelColor : (isCurrentListItem || GridView.isCurrentItem || (keepEmblemOverlay && emblemAdded)) && !hovered && showSelectionBackground ? highlightedTextColor : control.colorScheme.textColor property color hightlightedColor : GridView.isCurrentItem || hovered || (keepEmblemOverlay && emblemAdded) ? control.colorScheme.highlightColor : "transparent" property string rightEmblem property string leftEmblem : "list-add" signal rightClicked() signal emblemClicked(int index) signal rightEmblemClicked(int index) signal leftEmblemClicked(int index) focus: true clip: true hoverEnabled: !isMobile background: Rectangle { color: !isDetails? "transparent" : (isCurrentListItem || (hovered && isDetails) ? control.colorScheme.highlightColor : index % 2 === 0 ? Qt.lighter( control.colorScheme.backgroundColor,1.2) : control.colorScheme.backgroundColor) opacity: hovered ? 0.3 : 1 } // Drag.active: _mouseArea.drag.active // Drag.dragType: Drag.Automatic // Drag.supportedActions: Qt.CopyAction // Drag.mimeData: // { // "text/uri-list": model.path // } MouseArea { id: _mouseArea anchors.fill: parent acceptedButtons: Qt.RightButton // drag.target: parent onClicked: { if(!isMobile && mouse.button === Qt.RightButton) rightClicked() } // onPressed: parent.grabToImage(function(result) // { // parent.Drag.imageSource = result.url // }) } Maui.Badge { id: leftEmblemIcon iconName: leftEmblem visible: (isHovered && leftEmblem) || showEmblem z: 999 anchors.top: parent.top anchors.left: parent.left onClicked: leftEmblemClicked(index) // Component.onCompleted: leftEmblemIcon.item.isMask = false size: iconSizes.small colorScheme.backgroundColor: control.colorScheme.accentColor } Maui.Badge { id: rightEmblemIcon iconName: rightEmblem visible: (isHovered || keepEmblemOverlay) && showEmblem && rightEmblem z: 999 size: iconSizes.medium anchors.top: parent.top anchors.right: parent.right onClicked: rightEmblemClicked(index) colorScheme.backgroundColor: control.colorScheme.accentColor } Component { id: imgComponent Item { anchors.fill: parent Image { id: img clip: true anchors.centerIn: parent source: "file://"+model.thumbnail - height: folderSize - width: isDetails ? folderSize : control.width * 0.9 - sourceSize.width: width - sourceSize.height: folderSize + height: Math.min(folderSize, sourceSize.height) + width: isDetails ? folderSize : Math.min(control.width * 0.9, sourceSize.width) +// sourceSize.width: width +// sourceSize.height: height horizontalAlignment: Qt.AlignHCenter verticalAlignment: Qt.AlignVCenter fillMode: Image.PreserveAspectCrop cache: false asynchronous: true layer.enabled: true layer.effect: OpacityMask { maskSource: Item { - width: img.sourceSize.width - height: img.sourceSize.height + width: img.width + height: img.height Rectangle { anchors.centerIn: parent - width: img.sourceSize.width - height: img.sourceSize.height + width: img.width + height: img.height radius: radiusV } } } } Loader { - anchors.centerIn: parent - + anchors.centerIn: parent sourceComponent: img.status === Image.Ready ? undefined : iconComponent } } } Component { id: iconComponent Kirigami.Icon { source: model.icon fallback: "qrc:/assets/application-x-zerosize.svg" isMask: folderSize <= iconSizes.medium height: folderSize width: folderSize } } Component { id: labelComponent Item { anchors.fill: parent Label { id: label text: model.label width: parent.width height: parent.height horizontalAlignment: isDetails? Qt.AlignLeft : Qt.AlignHCenter verticalAlignment: Qt.AlignVCenter elide: Qt.ElideRight wrapMode: Text.Wrap font.pointSize: fontSizes.default color: labelColor Rectangle { visible: parent.visible && showSelectionBackground && !isDetails anchors.fill: parent z: -1 radius: radiusV color: hightlightedColor opacity: hovered ? 0.25 : 0.5 } } } } Component { id: detailsComponent RowLayout { anchors.fill: parent ColumnLayout { Layout.fillHeight: true Layout.fillWidth: false Layout.maximumWidth: 80 Layout.minimumWidth: 80 Layout.preferredWidth: 80 Layout.alignment: Qt.AlignRight Label { Layout.alignment: Qt.AlignRight Layout.fillWidth: true Layout.fillHeight: true horizontalAlignment: Qt.AlignRight verticalAlignment: Qt.AlignBottom elide: Qt.ElideRight wrapMode: Text.Wrap font.pointSize: fontSizes.small color: labelColor opacity: isCurrentListItem ? 1 : 0.5 text: model.mime === "inode/directory" ? (model.count ? model.count + qsTr(" items") : "") : Maui.FM.formatSize(model.size) } Label { Layout.alignment: Qt.AlignRight Layout.fillWidth: true Layout.fillHeight: true text: Maui.FM.formatDate(model.modified, "MM/dd/yyyy") horizontalAlignment: Qt.AlignRight verticalAlignment: Qt.AlignTop elide: Qt.ElideRight wrapMode: Text.Wrap font.pointSize: fontSizes.small color: labelColor opacity: isCurrentListItem ? 1 : 0.5 } } } } GridLayout { id: delegatelayout anchors.fill: parent rows: isDetails ? 1 : 2 columns: isDetails && showDetailsInfo ? 3 : (isDetails && !showDetailsInfo ? 2 : 1) rowSpacing: space.tiny columnSpacing: space.tiny Item { Layout.fillHeight: true Layout.fillWidth: true Layout.maximumWidth: folderSize Layout.row: 1 Layout.column: 1 Layout.alignment: Qt.AlignCenter Layout.leftMargin: isDetails ? space.medium : 0 Loader { id: loader anchors.centerIn: parent sourceComponent: model.mime ? (model.mime.indexOf("image") > -1 && showThumbnails ? imgComponent : iconComponent) : iconComponent } ToolTip.delay: 1000 ToolTip.timeout: 5000 ToolTip.visible: hovered && showTooltip ToolTip.text: model.tooltip ? model.tooltip : model.path } Loader { id: labelLoader Layout.fillWidth: true Layout.maximumHeight: (isDetails ? parent.height : fontSizes.default * 5) Layout.minimumHeight: (isDetails ? parent.height : control.height - folderSize - space.tiny) Layout.preferredHeight: (isDetails ? parent.height : control.height - folderSize - space.tiny) Layout.row: isDetails ? 1 : 2 Layout.column: isDetails ? 2 : 1 Layout.leftMargin: isDetails ? space.medium : 0 sourceComponent: model.label && model.label.length && showLabel? labelComponent : undefined } Loader { id: detailsInfoLoader sourceComponent: isDetails && showDetailsInfo ? detailsComponent : undefined Layout.fillWidth: isDetails && showDetailsInfo Layout.maximumHeight: ( isDetails && showDetailsInfo ? parent.height : fontSizes.default * 5) Layout.minimumHeight: ( isDetails && showDetailsInfo ? parent.height : control.height - folderSize - space.tiny) Layout.preferredHeight: ( isDetails && showDetailsInfo ? parent.height : control.height - folderSize - space.tiny) Layout.maximumWidth: control.width * (isMobile ? 0.5 : 0.3) Layout.row: isDetails && showDetailsInfo ? 1 : 2 Layout.column: isDetails && showDetailsInfo ? 3 : 0 Layout.rightMargin: space.medium // Layout.leftMargin: isDetails ? space.medium : 0 } } }