diff --git a/src/controls/ActionGroup.qml b/src/controls/ActionGroup.qml index f5c7f0b..a403c2b 100644 --- a/src/controls/ActionGroup.qml +++ b/src/controls/ActionGroup.qml @@ -1,171 +1,170 @@ /* * 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.5 import QtQuick.Layouts 1.3 import org.kde.kirigami 2.7 as Kirigami import org.kde.mauikit 1.0 as Maui Item { id: control default property list actions property list hiddenActions property int currentIndex : 0 readonly property int count : control.actions.length + control.hiddenActions.length signal clicked(int index) signal pressAndHold(int index) - signal doubleClicked(int index) - + signal doubleClicked(int index) property Component delegate : ToolButton { id: _delegate anchors.verticalCenter: parent.verticalCenter action: modelData icon.width: Maui.Style.iconSizes.medium icon.height: Maui.Style.iconSizes.medium autoExclusive: true checkable: true checked: index == control.currentIndex display: control.currentIndex === index ? ToolButton.TextBesideIcon : ToolButton.IconOnly Kirigami.Theme.backgroundColor: modelData.Kirigami.Theme.backgroundColor Kirigami.Theme.highlightColor: modelData.Kirigami.Theme.highlightColor Behavior on implicitWidth { NumberAnimation { duration: Kirigami.Units.shortDuration easing.type: Easing.InOutQuad } } onClicked: { control.currentIndex = index control.clicked(index) } onPressAndHold: control.pressAndHold(index) onDoubleClicked: control.doubleClicked(index) } implicitHeight: parent.height implicitWidth: _layout.implicitWidth Behavior on implicitWidth { NumberAnimation { duration: Kirigami.Units.shortDuration easing.type: Easing.InOutQuad } } Row { id: _layout height: parent.height // width: Math.min(implicitWidth, parent.width) spacing: Maui.Style.space.medium Repeater { model: control.actions delegate: control.delegate } ToolButton { id: _exposedHiddenActionButton visible: action action: control.currentIndex >= control.actions.length && control.currentIndex < control.count? control.hiddenActions[control.currentIndex - control.actions.length] : null checkable: true checked: visible anchors.verticalCenter: parent.verticalCenter icon.width: Maui.Style.iconSizes.medium icon.height: Maui.Style.iconSizes.medium display: ToolButton.TextBesideIcon width: visible ? implicitWidth : 0 Behavior on width { NumberAnimation { duration: Kirigami.Units.longDuration easing.type: Easing.InOutQuad } } } ToolButton { id: _menuButton icon.name: "list-add" visible: control.hiddenActions.length > 0 onClicked: { if(_menu.visible) _menu.close() else _menu.popup(_menuButton, 0, _menuButton.height) } anchors.verticalCenter: parent.verticalCenter text: qsTr("More") autoExclusive: false checkable: true checked: _menu.visible display: checked ? ToolButton.TextBesideIcon : ToolButton.IconOnly Behavior on implicitWidth { NumberAnimation { duration: Kirigami.Units.shortDuration easing.type: Easing.InOutQuad } } Menu { id: _menu closePolicy: Popup.CloseOnReleaseOutsideParent Repeater { model: control.hiddenActions MenuItem { action: modelData checkable: true autoExclusive: true checked: control.currentIndex === control.actions.length + index onTriggered: { control.currentIndex = control.actions.length + index control.clicked(control.currentIndex) } } } } } } } diff --git a/src/controls/ApplicationWindow.qml b/src/controls/ApplicationWindow.qml index d58c4f4..64b2f36 100644 --- a/src/controls/ApplicationWindow.qml +++ b/src/controls/ApplicationWindow.qml @@ -1,435 +1,437 @@ /* * 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 QtGraphicalEffects 1.0 import QtQuick.Window 2.3 import org.kde.kirigami 2.7 as Kirigami import org.kde.mauikit 1.0 as Maui import QtQuick.Controls.Material 2.1 import "private" Kirigami.AbstractApplicationWindow { id: root visible: true width: Screen.width * (Kirigami.Settings.isMobile ? 1 : 0.4) height: Screen.height * (Kirigami.Settings.isMobile ? 1 : 0.4) contentItem.anchors.leftMargin: root.sideBar && !root.globalDrawer ? ((root.sideBar.collapsible && root.sideBar.collapsed) ? root.sideBar.collapsedSize : (root.sideBar.modal ? 0 : root.sideBar.width * root.sideBar.position)) : (!root.sideBar && root.globalDrawer && (root.globalDrawer.modal === false) ? root.globalDrawer.width * root.globalDrawer.position : 0) property Maui.AbstractSideBar sideBar /***************************************************/ /******************** ALIASES *********************/ /*************************************************/ property alias headBar : _headBar property alias footBar: _footBar property alias dialog: dialogLoader.item property alias leftIcon : menuBtn property alias rightIcon : searchBtn property alias mainMenu : mainMenu.contentData property alias about : aboutDialog property alias accounts: _accountsDialogLoader.item property var currentAccount: Maui.App.accounts.currentAccount property alias notifyDialog: _notify property alias searchButton : searchBtn property alias menuButton : menuBtn wideScreen: isWide /***************************************************/ /*********************** UI ***********************/ /*************************************************/ property bool isWide : root.width >= Kirigami.Units.gridUnit * 30 property string colorSchemeName : Qt.application.name /***************************************************/ /********************* COLORS *********************/ /*************************************************/ property color headBarBGColor: Kirigami.Theme.backgroundColor property color headBarFGColor: Kirigami.Theme.textColor /***************************************************/ /**************** READONLY PROPS ******************/ /*************************************************/ readonly property bool isMobile : Kirigami.Settings.isMobile readonly property bool isAndroid: Qt.platform.os == "android" readonly property real screenWidth : Screen.width readonly property real screenHeight : Screen.height /***************************************************/ /******************** SIGNALS *********************/ /*************************************************/ signal menuButtonClicked(); signal searchButtonClicked(); onClosing: { if(!isMobile) { const height = root.height const width = root.width const x = root.x const y = root.y Maui.FM.saveSettings("GEOMETRY", Qt.rect(x, y, width, height), "WINDOW") } } property bool isPortrait: Screen.primaryOrientation === Qt.PortraitOrientation || Screen.primaryOrientation === Qt.InvertedPortraitOrientation onIsPortraitChanged: { if(isPortrait) { console.log("PORTARIT MODE CHANGED") width: Screen.width height: Screen.height } } // onHeadBarBGColorChanged: // { // if(!isMobile && colorSchemeName.length > 0) // Maui.KDE.setColorScheme(colorSchemeName, headBarBGColor, headBarFGColor) // else if(isAndroid && headBar.position === ToolBar.Header) // Maui.Android.statusbarColor(headBarBGColor, false) // else if(isAndroid && headBar.position === ToolBar.Footer) // Maui.Android.statusbarColor(Kirigami.Theme.viewBackgroundColor, true) // // } // // onHeadBarFGColorChanged: // { // if(!isAndroid && !isMobile && colorSchemeName.length > 0 && headBar.position === ToolBar.Header) // Maui.KDE.setColorScheme(colorSchemeName, headBarBGColor, headBarFGColor) // else if(isAndroid && headBar.position === ToolBar.Header) // Maui.Android.statusbarColor(headBarBGColor, false) // else if(isAndroid && headBar.position === ToolBar.Footer) // Maui.Android.statusbarColor(Kirigami.Theme.viewBackgroundColor, true) // } /* * background: Rectangle * { * color: bgColor } */ property Maui.ToolBar mheadBar : Maui.ToolBar { id: _headBar visible: count > 1 position: ToolBar.Header width: root.width height: implicitHeight // Kirigami.Theme.backgroundColor: headBarBGColor // Kirigami.Theme.textColor: headBarFGColor // Kirigami.Theme.inherit: true leftContent: [ ToolButton { id: menuBtn icon.name: "application-menu" icon.color: headBarFGColor icon.width: Maui.Style.iconSizes.medium icon.height: Maui.Style.iconSizes.medium checked: mainMenu.visible onClicked: { menuButtonClicked() mainMenu.visible ? mainMenu.close() : mainMenu.popup(parent, parent.x , parent.height+ Maui.Style.space.medium) } Menu { id: mainMenu modal: true z: 999 width: Maui.Style.unit * 200 MenuItem { visible: (_accountCombobox.count > 0) && Maui.App.handleAccounts height: visible ? _accountCombobox.implicitHeight + Maui.Style.space.big : 0 ComboBox { id: _accountCombobox anchors.fill: parent anchors.margins: Maui.Style.space.small popup.z: 999 width: parent.width textRole: "user" flat: true model: Maui.BaseModel { list: Maui.App.accounts } onActivated: Maui.App.accounts.currentAccountIndex = index; Component.onCompleted: { if(_accountCombobox.count > 0) { _accountCombobox.currentIndex = 0 Maui.App.accounts.currentAccountIndex = _accountCombobox.currentIndex } } } } MenuItem { text: qsTr("Accounts") visible: Maui.App.handleAccounts icon.name: "list-add-user" onTriggered: { if(root.accounts) accounts.open() } } MenuSeparator { visible: _accountCombobox.visible } MenuItem { text: qsTr("About") icon.name: "documentinfo" onTriggered: aboutDialog.open() } } - } + }, + + ToolSeparator{} ] rightContent: ToolButton { id: searchBtn icon.name: "edit-find" icon.color: headBarFGColor onClicked: searchButtonClicked() icon.width: Maui.Style.iconSizes.medium icon.height: Maui.Style.iconSizes.medium } } property Maui.ToolBar mfootBar : Maui.ToolBar { id: _footBar visible: count position: ToolBar.Footer width: root.width height: implicitHeight } header: headBar.count && headBar.position === ToolBar.Header ? headBar : null footer: Column { id: _footer visible : children children: { if(headBar.position === ToolBar.Footer && headBar.count && footBar.count) return [footBar , headBar] else if(headBar.position === ToolBar.Footer && headBar.count) return [headBar] else if(footBar.count) return [footBar] else return [] } } Maui.AboutDialog { id: aboutDialog } Loader { id: _accountsDialogLoader source: Maui.App.handleAccounts ? "private/AccountsHelper.qml" : "" } Maui.Dialog { id: _notify property var cb : ({}) verticalAlignment: Qt.AlignTop defaultButtons: _notify.cb !== null rejectButton.visible: false onAccepted: { if(_notify.cb) { _notify.cb() _notify.close() } } page.padding: Maui.Style.space.medium footBar.background: null maxHeight: Math.max(Maui.Style.iconSizes.large + Maui.Style.space.huge, (_notifyLayout.implicitHeight)) + Maui.Style.space.big + footBar.height maxWidth: Kirigami.Settings.isMobile ? parent.width * 0.9 : Maui.Style.unit * 500 widthHint: 0.8 Timer { id: _notifyTimer onTriggered: { if(_mouseArea.containsPress || _mouseArea.containsMouse) return; _notify.close() } } onClosed: _notifyTimer.stop() GridLayout { anchors.fill: parent columns: 2 rows: 1 Item { Layout.fillHeight: true Layout.preferredWidth: Maui.Style.iconSizes.large + Maui.Style.space.big Layout.row: 1 Layout.column: 1 Kirigami.Icon { id: _notifyIcon width: Maui.Style.iconSizes.large height: width anchors.centerIn: parent fallback : "dialog-warning" } } Item { Layout.fillHeight: true Layout.fillWidth: true Layout.margins: Maui.Style.space.medium Layout.row: 1 Layout.column: 2 ColumnLayout { id: _notifyLayout anchors.centerIn: parent width: parent.width Label { id: _notifyTitle Layout.fillHeight: true Layout.fillWidth: true font.weight: Font.Bold font.bold: true font.pointSize:Maui.Style.fontSizes.big elide: Qt.ElideRight wrapMode: Text.NoWrap } Label { id: _notifyBody Layout.fillHeight: true Layout.fillWidth: true font.pointSize:Maui.Style.fontSizes.default elide: Qt.ElideRight wrapMode: Text.Wrap } } } } MouseArea { id: _mouseArea anchors.fill: parent hoverEnabled: true } function show(callback) { _notify.cb = callback || null _notifyTimer.start() _notify.open() } } Loader { id: dialogLoader } Component.onCompleted: { if(isAndroid && headBar.position === ToolBar.Footer) Maui.Android.statusbarColor(Kirigami.Theme.backgroundColor, true) if(!isMobile) { const rect = Maui.FM.loadSettings("GEOMETRY", "WINDOW", Qt.rect(root.x, root.y, root.width, root.height)) root.x = rect.x root.y = rect.y root.width = rect.width root.height = rect.height } } function notify(icon, title, body, callback, timeout, buttonText) { _notifyIcon.source = icon || "emblem-warning" _notifyTitle.text = title _notifyBody.text = body _notifyTimer.interval = timeout ? timeout : 2500 _notify.acceptButton.text = buttonText || qsTr ("Accept") _notify.show(callback) } } diff --git a/src/controls/FileBrowser.qml b/src/controls/FileBrowser.qml index ca99973..1b9ea8f 100644 --- a/src/controls/FileBrowser.qml +++ b/src/controls/FileBrowser.qml @@ -1,1192 +1,1178 @@ import QtQuick 2.9 import QtQuick.Controls 2.3 import QtQuick.Layouts 1.3 import QtQml.Models 2.3 import QtQml 2.1 import org.kde.kirigami 2.8 as Kirigami import org.kde.mauikit 1.0 as Maui import "private" Maui.Page { - id: control - - property url currentPath - onCurrentPathChanged: control.browserView.path = control.currentPath - - property int viewType : Maui.FMList.LIST_VIEW - onViewTypeChanged: browserView.viewType = control.viewType - - property int thumbnailsSize : Maui.Style.iconSizes.large * 1.7 - property bool showThumbnails: true - - property var indexHistory : [] - - property bool isCopy : false - property bool isCut : false - - property bool selectionMode : false - property bool singleSelection: false - - property bool group : false - - //group properties from the browser since the browser views are loaded async and - //their properties can not be accesed inmediately, so they are stored here and then when completed they are set - property BrowserSettings settings : BrowserSettings {} - - property alias selectionBar : selectionBarLoader.item - property alias browserView : _browserList.currentItem - readonly property Maui.FMList currentFMList : browserView.currentFMList - - property alias previewer : previewer - property alias menu : browserMenu.contentData - property alias itemMenu: itemMenu - property alias dialog : dialogLoader.item - - 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) - - Kirigami.Theme.colorSet: Kirigami.Theme.View - Kirigami.Theme.inherit: false - - onGoBackTriggered: control.goBack() - onGoForwardTriggered: control.goNext() - - focus: true - footBar.visible: false - footBar.leftContent: Label - { - Layout.fillWidth: true - text: control.currentFMList.count + " " + qsTr("items") - } - - footBar.rightContent: [ - - ToolButton - { - icon.name: "zoom-in" - onClicked: zoomIn() - }, - - ToolButton - { - icon.name: "zoom-out" - onClicked: zoomOut() - } - ] - - headBar.position: Kirigami.Settings.isMobile ? ToolBar.Footer : ToolBar.Header - - headBar.rightContent:[ - - ToolButton - { - icon.name: "item-select" - checkable: true - checked: control.selectionMode - onClicked: control.selectionMode = !control.selectionMode - }, - - ToolButton - { - icon.name: "view-sort" - onClicked: - { - if(_sortMenu.visible) - _sortMenu.close() - else - _sortMenu.popup(0, height) - } - checked: _sortMenu.visible - checkable: false - - Menu - { - id: _sortMenu - closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutsideParent - - MenuItem - { - text: qsTr("Folders first") - checked: control.currentFMList.foldersFirst - checkable: true - onTriggered: control.currentFMList.foldersFirst = !control.currentFMList.foldersFirst - } - - MenuSeparator {} - - MenuItem - { - text: qsTr("Type") - checked: control.currentFMList.sortBy === Maui.FMList.MIME - checkable: true - onTriggered: control.currentFMList.sortBy = Maui.FMList.MIME - autoExclusive: true - } - - MenuItem - { - text: qsTr("Date") - checked: control.currentFMList.sortBy === Maui.FMList.DATE - checkable: true - onTriggered: control.currentFMList.sortBy = Maui.FMList.DATE - autoExclusive: true - } - - MenuItem - { - text: qsTr("Modified") - checkable: true - checked: control.currentFMList.sortBy === Maui.FMList.MODIFIED - onTriggered: control.currentFMList.sortBy = Maui.FMList.MODIFIED - autoExclusive: true - } - - MenuItem - { - text: qsTr("Size") - checkable: true - checked: control.currentFMList.sortBy === Maui.FMList.SIZE - onTriggered: control.currentFMList.sortBy = Maui.FMList.SIZE - autoExclusive: true - } - - MenuItem - { - text: qsTr("Name") - checkable: true - checked: control.currentFMList.sortBy === Maui.FMList.LABEL - onTriggered: control.currentFMList.sortBy = Maui.FMList.LABEL - autoExclusive: true - } - - MenuSeparator{} - - MenuItem - { - id: groupAction - text: qsTr("Group") - checkable: true - checked: control.group - onTriggered: - { - control.group = !control.group - if(control.group) - control.groupBy() - else - browserView.currentView.section.property = "" - } - } - } - }, - - ToolButton - { - id: _optionsButton - icon.name: "overflow-menu" - onClicked: - { - if(browserMenu.visible) - browserMenu.close() - else - browserMenu.show(_optionsButton, 0, height) - } - checked: browserMenu.visible - checkable: false - } - ] - - headBar.leftContent: [ - ToolButton - { - icon.name: "go-previous" - onClicked: control.goBack() - }, - - ToolButton - { - icon.name: "go-next" - onClicked: control.goNext() - }, - - Maui.ToolActions - { - direction: Qt.Vertical - - currentAction: switch(browserView.viewType) - { - case Maui.FMList.ICON_VIEW: return actions[0] - case Maui.FMList.LIST_VIEW: return actions[1] - case Maui.FMList.MILLERS_VIEW: return actions[2] - } - - Action - { - icon.name: "view-list-icons" - text: qsTr("Grid") - onTriggered: control.viewType = Maui.FMList.ICON_VIEW - checked: browserView.viewType === Maui.FMList.ICON_VIEW - icon.width: Maui.Style.iconSizes.medium - } - - Action - { - icon.name: "view-list-details" - text: qsTr("List") - onTriggered: control.viewType = Maui.FMList.LIST_VIEW - icon.width: Maui.Style.iconSizes.medium - checkable: true - checked: browserView.viewType === Maui.FMList.LIST_VIEW - } - - Action - { - icon.name: "view-file-columns" - text: qsTr("Columns") - onTriggered: control.viewType = Maui.FMList.MILLERS_VIEW - icon.width: Maui.Style.iconSizes.medium - checkable: true - checked: browserView.viewType === Maui.FMList.MILLERS_VIEW - } - } - ] - - Loader { id: dialogLoader } - - Component - { - id: removeDialogComponent - - Maui.Dialog - { - property var urls: [] - - title: qsTr(String("Removing %1 files").arg(urls.length.toString())) - message: isAndroid ? qsTr("This action will completely remove your files from your system. This action can not be undone.") : qsTr("You can move the file to the Trash or Delete it completely from your system. Which one you preffer?") - rejectButton.text: qsTr("Delete") - acceptButton.text: qsTr("Trash") - acceptButton.visible: !Kirigami.Settings.isMobile - page.padding: Maui.Style.space.huge - - onRejected: - { - if(control.selectionBar && control.selectionBar.visible) - { - control.selectionBar.animate(Maui.Style.dangerColor) - control.clearSelection() - } - - for(var i in urls) - Maui.FM.removeFile(urls[i]) - - close() - } - - onAccepted: - { - if(control.selectionBar && control.selectionBar.visible) - { - control.selectionBar.animate(Maui.Style.dangerColor) - control.clearSelection() - } - - for(var i in urls) - Maui.FM.moveToTrash(urls[i]) - 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: control.currentFMList.createDir(text) - rejectButton.visible: false - textEntry.placeholderText: qsTr("Folder name...") - } - } - - 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 - textEntry.placeholderText: qsTr("File name...") - } - } - - Component - { - id: renameDialogComponent - Maui.NewDialog - { - title: qsTr("Rename file") - message: qsTr("Rename a file or folder to a new custom name") - textEntry.text: itemMenu.item.label - textEntry.placeholderText: qsTr("New name...") - onFinished: Maui.FM.rename(itemMenu.item.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) - if(control.previewer.visible) - control.previewer.tagBar.list.refresh() - } - } - } - - Component - { - id: _configDialogComponent - - Maui.Dialog - { - maxHeight: _configLayout.implicitHeight * 1.5 - maxWidth: 300 - defaultButtons: false - - Kirigami.FormLayout - { - id: _configLayout - width: parent.width - anchors.centerIn: parent - - Kirigami.Separator - { - Kirigami.FormData.label: qsTr("Navigation") - Kirigami.FormData.isSection: true - } - - Switch - { - icon.name: "image-preview" - checkable: true - checked: control.showThumbnails - Kirigami.FormData.label: qsTr("Thumbnails") - onToggled: control.showThumbnails = !control.showThumbnails - } - - Switch - { - Kirigami.FormData.label: qsTr("Hidden files") - checkable: true - checked: control.currentFMList.hidden - onToggled: control.currentFMList.hidden = !control.currentFMList.hidden - } - - Kirigami.Separator - { - Kirigami.FormData.label: qsTr("Others") - Kirigami.FormData.isSection: true - } - - Switch - { - Kirigami.FormData.label: qsTr("Status bar") - checkable: true - checked: control.footBar.visible - onToggled: control.footBar.visible = !control.footBar.visible - - } - } - } - } - - Maui.FilePreviewer - { - id: previewer - onShareButtonClicked: control.shareFiles([url]) - } - - BrowserMenu { id: browserMenu } - - FileMenu - { - id: itemMenu - width: Maui.Style.unit *200 - onBookmarkClicked: control.bookmarkFolder([item.path]) - onCopyClicked: - { - if(item) - control.copy([item.path]) - } - - onCutClicked: - { - if(item) - control.cut([item.path]) - } - - onTagsClicked: - { - if(item) - { - dialogLoader.sourceComponent = tagsDialogComponent - dialog.composerList.urls = [item.path] - dialog.open() - } - } - - onRenameClicked: - { - dialogLoader.sourceComponent = renameDialogComponent - dialog.open() - } - - onRemoveClicked: - { - control.remove([item.path]) - } - - onShareClicked: control.shareFiles([item.path]) - } - - Connections - { - target: browserView.currentView - - onKeyPress: - { - console.log(event.key, event.modifier, event.count) - const index = browserView.currentView.currentIndex - const item = control.currentFMList.get(index) - - // Shortcuts for refreshing - if((event.key == Qt.Key_F5)) - { - control.currentFMList.refresh() - } - - // Shortcuts for selecting file - if((event.key == Qt.Key_A) && (event.modifiers & Qt.ControlModifier)) - { - control.selectAll() - } - - if(event.key == Qt.Key_S) - { - if(control.selectionBar && control.selectionBar.contains(item.path)) - { - control.selectionBar.removeAtPath(item.path) - }else - { - control.addToSelection(item) - } - } - - if((event.key == Qt.Key_Left || event.key == Qt.Key_Right || event.key == Qt.Key_Down || event.key == Qt.Key_Up) && (event.modifiers & Qt.ControlModifier) && (event.modifiers & Qt.ShiftModifier)) - { - if(control.selectionBar && control.selectionBar.contains(item.path)) - { - control.selectionBar.removeAtPath(item.path) - }else - { - control.addToSelection(item) - } - } - - // Shortcut for pasting an item - if((event.key == Qt.Key_V) && (event.modifiers & Qt.ControlModifier)) - { - control.paste(Maui.Handy.getClipboard().urls) - } - - // Shortcut for cutting an item - if((event.key == Qt.Key_X) && (event.modifiers & Qt.ControlModifier)) - { - var urls = [] - if(control.selectionBar) - { - urls = control.selectionBar.selectedPaths - } - else - { - urls = [item.path] - } - control.cut(urls) - } - - // Shortcut for copying an item - if((event.key == Qt.Key_C) && (event.modifiers & Qt.ControlModifier)) - { - var urls = [] - if(control.selectionBar) - { - urls = control.selectionBar.selectedPaths - } - else - { - urls = [item.path] - } - control.copy(urls) - } - - // Shortcut for removing an item - if(event.key == Qt.Key_Delete) - { - var urls = [] - if(control.selectionBar) - { - urls = control.selectionBar.selectedPaths - } - else - { - urls = [item.path] - } - control.remove(urls) - } - - // Shortcut for opening new tab - if((event.key == Qt.Key_T) && (event.modifiers & Qt.ControlModifier)) - { - const _path = (currentPath).toString() - control.openTab(" ") - control.currentPath = _path - } - - // Shortcut for closing tab - if((event.key == Qt.Key_W) && (event.modifiers & Qt.ControlModifier)) - { - if(tabsBar.count > 1) - control.closeTab(tabsBar.currentIndex) - } - - // Shortcut for opening files in new tab , previewing or launching - if((event.key == Qt.Key_Return) && (event.modifiers & Qt.ControlModifier)) - { - if(item.isdir == "true") - control.openTab(item.path) - - }else if((event.key == Qt.Key_Return) && (event.modifiers & Qt.AltModifier)) - { - control.previewer.show(control.currentFMList.get(index).path) - }else if(event.key == Qt.Key_Return) - { - indexHistory.push(index) - control.itemClicked(index) - } - - // Shortcut for going back in browsing history - if(event.key == Qt.Key_Backspace || event.key == Qt.Key_Back) - { - if(control.selectionBar) - control.clearSelection() - else - control.goBack() - } - - // Shortcut for clearing selection - if(event.key == Qt.Key_Escape) - { - if(control.selectionBar) - control.clearSelection() - } - } - - onItemClicked: - { - browserView.currentView.currentIndex = index - indexHistory.push(index) - control.itemClicked(index) - } - - onItemDoubleClicked: - { - browserView.currentView.currentIndex = index - indexHistory.push(index) - control.itemDoubleClicked(index) - } - - onItemRightClicked: - { - if(control.currentFMList.pathType !== Maui.FMList.TRASH_PATH && control.currentFMList.pathType !== Maui.FMList.REMOTE_PATH) - itemMenu.show(index) - control.itemRightClicked(index) - } - - onLeftEmblemClicked: - { - const item = control.currentFMList.get(index) - - if(control.selectionBar && control.selectionBar.contains(item.path)) - { - control.selectionBar.removeAtPath(item.path) - }else - { - control.addToSelection(item) - } - control.itemLeftEmblemClicked(index) - } - - onRightEmblemClicked: - { - isAndroid ? Maui.Android.shareDialog([control.currentFMList.get(index).path]) : shareDialog.show([control.currentFMList.get(index).path]) - control.itemRightEmblemClicked(index) - } - - onAreaClicked: - { - if(!Kirigami.Settings.isMobile && mouse.button === Qt.RightButton) - browserMenu.show(control) - else return - - control.rightClicked() - } - - onAreaRightClicked: browserMenu.show(control) - - // onWarning: - // { - // notify("dialog-information", "An error happened", message) - // } - - // onProgress: - // { - // if(percent === 100) - // _progressBar.value = 0 - // else - // _progressBar.value = percent/100 - // } - } - - Component - { - id: selectionBarComponent - - Maui.SelectionBar - { - id: _selectionBar - anchors.fill: parent - onIconClicked: _selectionBarmenu.popup() - singleSelection: control.singleSelection - onExitClicked: - { - control.clearSelection() - control.selectionMode = false - } - onCountChanged: - { - if(_selectionBar.count < 1) - control.clearSelection() - } - - onRightClicked: _selectionBarmenu.popup() - - onItemClicked: control.previewer.show(itemAt(index).path) - - onItemPressAndHold: removeAtIndex(index) - - Menu - { - id: _selectionBarmenu - - MenuItem - { - text: qsTr("Open") + id: control + + property url currentPath + onCurrentPathChanged: control.browserView.path = control.currentPath + + property int viewType : Maui.FMList.LIST_VIEW + onViewTypeChanged: browserView.viewType = control.viewType + + property int thumbnailsSize : Maui.Style.iconSizes.large * 1.7 + property bool showThumbnails: true + + property var indexHistory : [] + + property bool isCopy : false + property bool isCut : false + + property bool selectionMode : false + property bool singleSelection: false + + property bool group : false + + //group properties from the browser since the browser views are loaded async and + //their properties can not be accesed inmediately, so they are stored here and then when completed they are set + property BrowserSettings settings : BrowserSettings {} + + property alias selectionBar : selectionBarLoader.item + property alias browserView : _browserList.currentItem + readonly property Maui.FMList currentFMList : browserView.currentFMList + + property alias previewer : previewer + property alias menu : browserMenu.contentData + property alias itemMenu: itemMenu + property alias dialog : dialogLoader.item + + 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) + + Kirigami.Theme.colorSet: Kirigami.Theme.View + Kirigami.Theme.inherit: false + + onGoBackTriggered: control.goBack() + onGoForwardTriggered: control.goNext() + + focus: true + footBar.visible: false + footBar.leftContent: Label + { + Layout.fillWidth: true + text: control.currentFMList.count + " " + qsTr("items") + } + + footBar.rightContent: [ + + ToolButton + { + icon.name: "zoom-in" + onClicked: zoomIn() + }, + + ToolButton + { + icon.name: "zoom-out" + onClicked: zoomOut() + } + ] + + headBar.position: Kirigami.Settings.isMobile ? ToolBar.Footer : ToolBar.Header + + headBar.rightContent:[ + + ToolButton + { + icon.name: "item-select" + checkable: true + checked: control.selectionMode + onClicked: control.selectionMode = !control.selectionMode + }, + + Maui.ToolButtonMenu + { + icon.name: "view-sort" + + MenuItem + { + text: qsTr("Folders first") + checked: control.currentFMList.foldersFirst + checkable: true + onTriggered: control.currentFMList.foldersFirst = !control.currentFMList.foldersFirst + } + + MenuSeparator {} + + MenuItem + { + text: qsTr("Type") + checked: control.currentFMList.sortBy === Maui.FMList.MIME + checkable: true + onTriggered: control.currentFMList.sortBy = Maui.FMList.MIME + autoExclusive: true + } + + MenuItem + { + text: qsTr("Date") + checked: control.currentFMList.sortBy === Maui.FMList.DATE + checkable: true + onTriggered: control.currentFMList.sortBy = Maui.FMList.DATE + autoExclusive: true + } + + MenuItem + { + text: qsTr("Modified") + checkable: true + checked: control.currentFMList.sortBy === Maui.FMList.MODIFIED + onTriggered: control.currentFMList.sortBy = Maui.FMList.MODIFIED + autoExclusive: true + } + + MenuItem + { + text: qsTr("Size") + checkable: true + checked: control.currentFMList.sortBy === Maui.FMList.SIZE + onTriggered: control.currentFMList.sortBy = Maui.FMList.SIZE + autoExclusive: true + } + + MenuItem + { + text: qsTr("Name") + checkable: true + checked: control.currentFMList.sortBy === Maui.FMList.LABEL + onTriggered: control.currentFMList.sortBy = Maui.FMList.LABEL + autoExclusive: true + } + + MenuSeparator{} + + MenuItem + { + id: groupAction + text: qsTr("Group") + checkable: true + checked: control.group + onTriggered: + { + control.group = !control.group + if(control.group) + control.groupBy() + else + browserView.currentView.section.property = "" + } + } + + }, + + ToolButton + { + id: _optionsButton + icon.name: "overflow-menu" + onClicked: + { + if(browserMenu.visible) + browserMenu.close() + else + browserMenu.show(_optionsButton, 0, height) + } + checked: browserMenu.visible + checkable: false + } + ] + + headBar.leftContent: [ + ToolButton + { + icon.name: "go-previous" + onClicked: control.goBack() + }, + + ToolButton + { + icon.name: "go-next" + onClicked: control.goNext() + }, + + Maui.ToolActions + { + direction: Qt.Vertical + + currentAction: switch(browserView.viewType) + { + case Maui.FMList.ICON_VIEW: return actions[0] + case Maui.FMList.LIST_VIEW: return actions[1] + case Maui.FMList.MILLERS_VIEW: return actions[2] + } + + Action + { + icon.name: "view-list-icons" + text: qsTr("Grid") + onTriggered: control.viewType = Maui.FMList.ICON_VIEW + checked: browserView.viewType === Maui.FMList.ICON_VIEW + icon.width: Maui.Style.iconSizes.medium + } + + Action + { + icon.name: "view-list-details" + text: qsTr("List") + onTriggered: control.viewType = Maui.FMList.LIST_VIEW + icon.width: Maui.Style.iconSizes.medium + checkable: true + checked: browserView.viewType === Maui.FMList.LIST_VIEW + } + + Action + { + icon.name: "view-file-columns" + text: qsTr("Columns") + onTriggered: control.viewType = Maui.FMList.MILLERS_VIEW + icon.width: Maui.Style.iconSizes.medium + checkable: true + checked: browserView.viewType === Maui.FMList.MILLERS_VIEW + } + } + ] + + Loader { id: dialogLoader } + + Component + { + id: removeDialogComponent + + Maui.Dialog + { + property var urls: [] + + title: qsTr(String("Removing %1 files").arg(urls.length.toString())) + message: isAndroid ? qsTr("This action will completely remove your files from your system. This action can not be undone.") : qsTr("You can move the file to the Trash or Delete it completely from your system. Which one you preffer?") + rejectButton.text: qsTr("Delete") + acceptButton.text: qsTr("Trash") + acceptButton.visible: !Kirigami.Settings.isMobile + page.padding: Maui.Style.space.huge + + onRejected: + { + if(control.selectionBar && control.selectionBar.visible) + { + control.selectionBar.animate(Maui.Style.dangerColor) + control.clearSelection() + } + + for(var i in urls) + Maui.FM.removeFile(urls[i]) + + close() + } + + onAccepted: + { + if(control.selectionBar && control.selectionBar.visible) + { + control.selectionBar.animate(Maui.Style.dangerColor) + control.clearSelection() + } + + for(var i in urls) + Maui.FM.moveToTrash(urls[i]) + 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: control.currentFMList.createDir(text) + rejectButton.visible: false + textEntry.placeholderText: qsTr("Folder name...") + } + } + + 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 + textEntry.placeholderText: qsTr("File name...") + } + } + + Component + { + id: renameDialogComponent + Maui.NewDialog + { + title: qsTr("Rename file") + message: qsTr("Rename a file or folder to a new custom name") + textEntry.text: itemMenu.item.label + textEntry.placeholderText: qsTr("New name...") + onFinished: Maui.FM.rename(itemMenu.item.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) + if(control.previewer.visible) + control.previewer.tagBar.list.refresh() + } + } + } + + Component + { + id: _configDialogComponent + + Maui.Dialog + { + maxHeight: _configLayout.implicitHeight * 1.5 + maxWidth: 300 + defaultButtons: false + + Kirigami.FormLayout + { + id: _configLayout + width: parent.width + anchors.centerIn: parent + + Kirigami.Separator + { + Kirigami.FormData.label: qsTr("Navigation") + Kirigami.FormData.isSection: true + } + + Switch + { + icon.name: "image-preview" + checkable: true + checked: control.showThumbnails + Kirigami.FormData.label: qsTr("Thumbnails") + onToggled: control.showThumbnails = !control.showThumbnails + } + + Switch + { + Kirigami.FormData.label: qsTr("Hidden files") + checkable: true + checked: control.currentFMList.hidden + onToggled: control.currentFMList.hidden = !control.currentFMList.hidden + } + + Kirigami.Separator + { + Kirigami.FormData.label: qsTr("Others") + Kirigami.FormData.isSection: true + } + + Switch + { + Kirigami.FormData.label: qsTr("Status bar") + checkable: true + checked: control.footBar.visible + onToggled: control.footBar.visible = !control.footBar.visible + + } + } + } + } + + Maui.FilePreviewer + { + id: previewer + onShareButtonClicked: control.shareFiles([url]) + } + + BrowserMenu { id: browserMenu } + + FileMenu + { + id: itemMenu + width: Maui.Style.unit *200 + onBookmarkClicked: control.bookmarkFolder([item.path]) + onCopyClicked: + { + if(item) + control.copy([item.path]) + } + + onCutClicked: + { + if(item) + control.cut([item.path]) + } + + onTagsClicked: + { + if(item) + { + dialogLoader.sourceComponent = tagsDialogComponent + dialog.composerList.urls = [item.path] + dialog.open() + } + } + + onRenameClicked: + { + dialogLoader.sourceComponent = renameDialogComponent + dialog.open() + } + + onRemoveClicked: + { + control.remove([item.path]) + } + + onShareClicked: control.shareFiles([item.path]) + } + + Connections + { + target: browserView.currentView + + onKeyPress: + { + console.log(event.key, event.modifier, event.count) + const index = browserView.currentView.currentIndex + const item = control.currentFMList.get(index) + + // Shortcuts for refreshing + if((event.key == Qt.Key_F5)) + { + control.currentFMList.refresh() + } + + // Shortcuts for selecting file + if((event.key == Qt.Key_A) && (event.modifiers & Qt.ControlModifier)) + { + control.selectAll() + } + + if(event.key == Qt.Key_S) + { + if(control.selectionBar && control.selectionBar.contains(item.path)) + { + control.selectionBar.removeAtPath(item.path) + }else + { + control.addToSelection(item) + } + } + + if((event.key == Qt.Key_Left || event.key == Qt.Key_Right || event.key == Qt.Key_Down || event.key == Qt.Key_Up) && (event.modifiers & Qt.ControlModifier) && (event.modifiers & Qt.ShiftModifier)) + { + if(control.selectionBar && control.selectionBar.contains(item.path)) + { + control.selectionBar.removeAtPath(item.path) + }else + { + control.addToSelection(item) + } + } + + // Shortcut for pasting an item + if((event.key == Qt.Key_V) && (event.modifiers & Qt.ControlModifier)) + { + control.paste(Maui.Handy.getClipboard().urls) + } + + // Shortcut for cutting an item + if((event.key == Qt.Key_X) && (event.modifiers & Qt.ControlModifier)) + { + var urls = [] + if(control.selectionBar) + { + urls = control.selectionBar.selectedPaths + } + else + { + urls = [item.path] + } + control.cut(urls) + } + + // Shortcut for copying an item + if((event.key == Qt.Key_C) && (event.modifiers & Qt.ControlModifier)) + { + var urls = [] + if(control.selectionBar) + { + urls = control.selectionBar.selectedPaths + } + else + { + urls = [item.path] + } + control.copy(urls) + } + + // Shortcut for removing an item + if(event.key == Qt.Key_Delete) + { + var urls = [] + if(control.selectionBar) + { + urls = control.selectionBar.selectedPaths + } + else + { + urls = [item.path] + } + control.remove(urls) + } + + // Shortcut for opening new tab + if((event.key == Qt.Key_T) && (event.modifiers & Qt.ControlModifier)) + { + const _path = (currentPath).toString() + control.openTab(" ") + control.currentPath = _path + } + + // Shortcut for closing tab + if((event.key == Qt.Key_W) && (event.modifiers & Qt.ControlModifier)) + { + if(tabsBar.count > 1) + control.closeTab(tabsBar.currentIndex) + } + + // Shortcut for opening files in new tab , previewing or launching + if((event.key == Qt.Key_Return) && (event.modifiers & Qt.ControlModifier)) + { + if(item.isdir == "true") + control.openTab(item.path) + + }else if((event.key == Qt.Key_Return) && (event.modifiers & Qt.AltModifier)) + { + control.previewer.show(control.currentFMList.get(index).path) + }else if(event.key == Qt.Key_Return) + { + indexHistory.push(index) + control.itemClicked(index) + } + + // Shortcut for going back in browsing history + if(event.key == Qt.Key_Backspace || event.key == Qt.Key_Back) + { + if(control.selectionBar) + control.clearSelection() + else + control.goBack() + } + + // Shortcut for clearing selection + if(event.key == Qt.Key_Escape) + { + if(control.selectionBar) + control.clearSelection() + } + } + + onItemClicked: + { + browserView.currentView.currentIndex = index + indexHistory.push(index) + control.itemClicked(index) + } + + onItemDoubleClicked: + { + browserView.currentView.currentIndex = index + indexHistory.push(index) + control.itemDoubleClicked(index) + } + + onItemRightClicked: + { + if(control.currentFMList.pathType !== Maui.FMList.TRASH_PATH && control.currentFMList.pathType !== Maui.FMList.REMOTE_PATH) + itemMenu.show(index) + control.itemRightClicked(index) + } + + onLeftEmblemClicked: + { + const item = control.currentFMList.get(index) + + if(control.selectionBar && control.selectionBar.contains(item.path)) + { + control.selectionBar.removeAtPath(item.path) + }else + { + control.addToSelection(item) + } + control.itemLeftEmblemClicked(index) + } + + onRightEmblemClicked: + { + isAndroid ? Maui.Android.shareDialog([control.currentFMList.get(index).path]) : shareDialog.show([control.currentFMList.get(index).path]) + control.itemRightEmblemClicked(index) + } + + onAreaClicked: + { + if(!Kirigami.Settings.isMobile && mouse.button === Qt.RightButton) + browserMenu.show(control) + else return + + control.rightClicked() + } + + onAreaRightClicked: browserMenu.show(control) + + // onWarning: + // { + // notify("dialog-information", "An error happened", message) + // } + + // onProgress: + // { + // if(percent === 100) + // _progressBar.value = 0 + // else + // _progressBar.value = percent/100 + // } + } + + Component + { + id: selectionBarComponent + + Maui.SelectionBar + { + id: _selectionBar + anchors.fill: parent + onIconClicked: _selectionBarmenu.popup() + singleSelection: control.singleSelection + onExitClicked: + { + control.clearSelection() + control.selectionMode = false + } + onCountChanged: + { + if(_selectionBar.count < 1) + control.clearSelection() + } + + onRightClicked: _selectionBarmenu.popup() + + onItemClicked: control.previewer.show(itemAt(index).path) + + onItemPressAndHold: removeAtIndex(index) + + Menu + { + id: _selectionBarmenu + + MenuItem + { + text: qsTr("Open") icon.name: "document-open" - onTriggered: - { - if(control.selectionBar) - { - for(var i in selectedPaths) - openFile(selectedPaths[i]) - } - } - } - - MenuSeparator {} - - MenuItem - { - text: qsTr("Copy") + onTriggered: + { + if(control.selectionBar) + { + for(var i in selectedPaths) + openFile(selectedPaths[i]) + } + } + } + + MenuSeparator {} + + MenuItem + { + text: qsTr("Copy") icon.name: "edit-copy" - onTriggered: if(control.selectionBar) - { - control.selectionBar.animate("#6fff80") - control.copy(selectedPaths) - _selectionBarmenu.close() - } - } - - MenuItem - { - text: qsTr("Cut") + onTriggered: if(control.selectionBar) + { + control.selectionBar.animate("#6fff80") + control.copy(selectedPaths) + _selectionBarmenu.close() + } + } + + MenuItem + { + text: qsTr("Cut") icon.name: "edit-cut" - onTriggered: if(control.selectionBar) - { - control.selectionBar.animate("#fff44f") - control.cut(selectedPaths) - _selectionBarmenu.close() - } - - } - - MenuSeparator {} - - MenuItem - { + onTriggered: if(control.selectionBar) + { + control.selectionBar.animate("#fff44f") + control.cut(selectedPaths) + _selectionBarmenu.close() + } + + } + + MenuSeparator {} + + MenuItem + { text: qsTr("Tags") icon.name: "tag" onTriggered: if(control.selectionBar) { dialogLoader.sourceComponent = tagsDialogComponent dialog.composerList.urls = selectedPaths dialog.open() _selectionBarmenu.close() } } - MenuItem - { - text: qsTr("Share") + MenuItem + { + text: qsTr("Share") icon.name: "document-share" - onTriggered: - { - control.shareFiles(selectedPaths) - _selectionBarmenu.close() - } - } - - MenuSeparator{} - - MenuItem - { - text: qsTr("Remove") + onTriggered: + { + control.shareFiles(selectedPaths) + _selectionBarmenu.close() + } + } + + MenuSeparator{} + + MenuItem + { + text: qsTr("Remove") icon.name: "edit-delete" - Kirigami.Theme.textColor: Kirigami.Theme.negativeTextColor - - onTriggered: - { - control.remove(selectedPaths) - _selectionBarmenu.close() - } - } - } - } - } - - ObjectModel { id: tabsObjectModel } - - ColumnLayout - { - anchors.fill: parent - spacing: 0 - - Maui.TabBar - { - id: tabsBar - visible: _browserList.count > 1 - Layout.fillWidth: true - Layout.preferredHeight: tabsBar.implicitHeight - position: TabBar.Header - currentIndex : _browserList.currentIndex - - ListModel { id: tabsListModel } - - Keys.onPressed: - { - if(event.key == Qt.Key_Return) - { - _browserList.currentIndex = currentIndex - control.currentPath = tabsObjectModel.get(currentIndex).path - } - } - - Repeater - { - id: _repeater - model: tabsListModel - - Maui.TabButton - { - id: _tabButton - implicitHeight: tabsBar.implicitHeight - implicitWidth: Math.max(control.width / _repeater.count, 120) - checked: index === _browserList.currentIndex - - text: tabsObjectModel.get(index).currentFMList.pathName - - onClicked: - { - _browserList.currentIndex = index - control.currentPath = tabsObjectModel.get(index).path - } - - onCloseClicked: control.closeTab(index) - } - } - } - - ListView - { - id: _browserList - Layout.margins: 0 - Layout.fillWidth: true - Layout.fillHeight: true - clip: true - focus: true - orientation: ListView.Horizontal - model: tabsObjectModel - snapMode: ListView.SnapOneItem - spacing: 0 - interactive: Kirigami.Settings.isMobile && tabsObjectModel.count > 1 - highlightFollowsCurrentItem: true - highlightMoveDuration: 0 - onMovementEnded: _browserList.currentIndex = indexAt(contentX, contentY) - - // DropArea - // { - // id: _dropArea - // anchors.fill: parent - // z: parent.z -2 - // onDropped: - // { - // const urls = drop.urls - // for(var i in urls) - // { - // const item = Maui.FM.getFileInfo(urls[i]) - // if(item.isdir == "true") - // { - // control.openTab(urls[i]) - // } - // } - // } - // } - } - - Loader - { - id: selectionBarLoader - Layout.fillWidth: true - Layout.preferredHeight: control.selectionBar && control.selectionBar.visible ? control.selectionBar.barHeight: 0 - Layout.leftMargin: Maui.Style.contentMargins * (Kirigami.Settings.isMobile ? 3 : 2) - Layout.rightMargin: Maui.Style.contentMargins * (Kirigami.Settings.isMobile ? 3 : 2) - Layout.bottomMargin: control.selectionBar && control.selectionBar.visible ? Maui.Style.contentMargins*2 : 0 - } - - ProgressBar - { - id: _progressBar - Layout.fillWidth: true - Layout.alignment: Qt.AlignBottom - Layout.preferredHeight: visible ? Maui.Style.iconSizes.medium : 0 - visible: value > 0 - } - } - - Component.onCompleted: - { - openTab(Maui.FM.homePath()) - control.setSettings() - browserView.currentView.forceActiveFocus() - } - - onThumbnailsSizeChanged: - { - if(settings.trackChanges && settings.saveDirProps) - Maui.FM.setDirConf(currentPath+"/.directory", "MAUIFM", "IconSize", thumbnailsSize) - else - Maui.FM.saveSettings("IconSize", thumbnailsSize, "SETTINGS") - - if(control.viewType === Maui.FMList.ICON_VIEW) - browserView.currentView.adaptGrid() - } - - function setSettings() - { - if(control.currentFMList !== null) - { - control.currentFMList.onlyDirs= control.settings.onlyDirs - control.currentFMList.filters= control.settings.filters - control.currentFMList.sortBy= control.settings.sortBy || control.currentFMList.sortBy - control.currentFMList.filterType= control.settings.filterType - control.currentFMList.trackChanges= control.settings.trackChanges || control.currentFMList.trackChanges - control.currentFMList.saveDirProps= control.settings.saveDirProps - } - } - - function closeTab(index) - { - tabsObjectModel.remove(index) - tabsListModel.remove(index) - } - - function openTab(path) - { - if(path) - { - const component = Qt.createComponent("private/BrowserView.qml"); - if (component.status === Component.Ready) - { - const object = component.createObject(tabsObjectModel); - tabsObjectModel.append(object); - } - - tabsListModel.append({"path": path}) - _browserList.currentIndex = tabsObjectModel.count - 1 - - browserView.viewType = control.viewType - openFolder(path) - } - } - - 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) - { - const item = control.currentFMList.get(index) - const path = item.path - - switch(control.currentFMList.pathType) - { - case Maui.FMList.CLOUD_PATH: - if(item.isdir === "true") - { - control.openFolder(path) - } - else - { - Maui.FM.openCloudItem(item) - } - break; - default: - if(selectionMode && item.isdir == "false") - { - if(control.selectionBar && control.selectionBar.contains(item.path)) - { - control.selectionBar.removeAtPath(item.path) - }else - { - control.addToSelection(item) - } - } - else - { - if(item.isdir == "true") - { - control.openFolder(path) - } - else - { - if (Kirigami.Settings.isMobile) - { - control.previewer.show(path) - } - else - { - control.openFile(path) - } - } - } - } - } - - function openFile(path) - { - Maui.FM.openUrl(path) - } - - function openFolder(path) - { + Kirigami.Theme.textColor: Kirigami.Theme.negativeTextColor + + onTriggered: + { + control.remove(selectedPaths) + _selectionBarmenu.close() + } + } + } + } + } + + ObjectModel { id: tabsObjectModel } + + ColumnLayout + { + anchors.fill: parent + spacing: 0 + + Maui.TabBar + { + id: tabsBar + visible: _browserList.count > 1 + Layout.fillWidth: true + Layout.preferredHeight: tabsBar.implicitHeight + position: TabBar.Header + currentIndex : _browserList.currentIndex + + ListModel { id: tabsListModel } + + Keys.onPressed: + { + if(event.key == Qt.Key_Return) + { + _browserList.currentIndex = currentIndex + control.currentPath = tabsObjectModel.get(currentIndex).path + } + } + + Repeater + { + id: _repeater + model: tabsListModel + + Maui.TabButton + { + id: _tabButton + implicitHeight: tabsBar.implicitHeight + implicitWidth: Math.max(control.width / _repeater.count, 120) + checked: index === _browserList.currentIndex + + text: tabsObjectModel.get(index).currentFMList.pathName + + onClicked: + { + _browserList.currentIndex = index + control.currentPath = tabsObjectModel.get(index).path + } + + onCloseClicked: control.closeTab(index) + } + } + } + + ListView + { + id: _browserList + Layout.margins: 0 + Layout.fillWidth: true + Layout.fillHeight: true + clip: true + focus: true + orientation: ListView.Horizontal + model: tabsObjectModel + snapMode: ListView.SnapOneItem + spacing: 0 + interactive: Kirigami.Settings.isMobile && tabsObjectModel.count > 1 + highlightFollowsCurrentItem: true + highlightMoveDuration: 0 + onMovementEnded: _browserList.currentIndex = indexAt(contentX, contentY) + + // DropArea + // { + // id: _dropArea + // anchors.fill: parent + // z: parent.z -2 + // onDropped: + // { + // const urls = drop.urls + // for(var i in urls) + // { + // const item = Maui.FM.getFileInfo(urls[i]) + // if(item.isdir == "true") + // { + // control.openTab(urls[i]) + // } + // } + // } + // } + } + + Loader + { + id: selectionBarLoader + Layout.fillWidth: true + Layout.preferredHeight: control.selectionBar && control.selectionBar.visible ? control.selectionBar.barHeight: 0 + Layout.leftMargin: Maui.Style.contentMargins * (Kirigami.Settings.isMobile ? 3 : 2) + Layout.rightMargin: Maui.Style.contentMargins * (Kirigami.Settings.isMobile ? 3 : 2) + Layout.bottomMargin: control.selectionBar && control.selectionBar.visible ? Maui.Style.contentMargins*2 : 0 + } + + ProgressBar + { + id: _progressBar + Layout.fillWidth: true + Layout.alignment: Qt.AlignBottom + Layout.preferredHeight: visible ? Maui.Style.iconSizes.medium : 0 + visible: value > 0 + } + } + + Component.onCompleted: + { + openTab(Maui.FM.homePath()) + control.setSettings() + browserView.currentView.forceActiveFocus() + } + + onThumbnailsSizeChanged: + { + if(settings.trackChanges && settings.saveDirProps) + Maui.FM.setDirConf(currentPath+"/.directory", "MAUIFM", "IconSize", thumbnailsSize) + else + Maui.FM.saveSettings("IconSize", thumbnailsSize, "SETTINGS") + + if(control.viewType === Maui.FMList.ICON_VIEW) + browserView.currentView.adaptGrid() + } + + function setSettings() + { + if(control.currentFMList !== null) + { + control.currentFMList.onlyDirs= control.settings.onlyDirs + control.currentFMList.filters= control.settings.filters + control.currentFMList.sortBy= control.settings.sortBy || control.currentFMList.sortBy + control.currentFMList.filterType= control.settings.filterType + control.currentFMList.trackChanges= control.settings.trackChanges || control.currentFMList.trackChanges + control.currentFMList.saveDirProps= control.settings.saveDirProps + } + } + + function closeTab(index) + { + tabsObjectModel.remove(index) + tabsListModel.remove(index) + } + + function openTab(path) + { + if(path) + { + const component = Qt.createComponent("private/BrowserView.qml"); + if (component.status === Component.Ready) + { + const object = component.createObject(tabsObjectModel); + tabsObjectModel.append(object); + } + + tabsListModel.append({"path": path}) + _browserList.currentIndex = tabsObjectModel.count - 1 + + browserView.viewType = control.viewType + openFolder(path) + } + } + + 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) + { + const item = control.currentFMList.get(index) + const path = item.path + + switch(control.currentFMList.pathType) + { + case Maui.FMList.CLOUD_PATH: + if(item.isdir === "true") + { + control.openFolder(path) + } + else + { + Maui.FM.openCloudItem(item) + } + break; + default: + if(selectionMode && item.isdir == "false") + { + if(control.selectionBar && control.selectionBar.contains(item.path)) + { + control.selectionBar.removeAtPath(item.path) + }else + { + control.addToSelection(item) + } + } + else + { + if(item.isdir == "true") + { + control.openFolder(path) + } + else + { + if (Kirigami.Settings.isMobile) + { + control.previewer.show(path) + } + else + { + control.openFile(path) + } + } + } + } + } + + function openFile(path) + { + Maui.FM.openUrl(path) + } + + function openFolder(path) + { if(!String(path).length) return; control.browserView.currentView.currentIndex = 0 control.currentPath = path - } - - function goBack() - { - openFolder(control.currentFMList.previousPath) - // browserView.currentView.currentIndex = indexHistory.pop() - } - - function goNext() - { - openFolder(control.currentFMList.posteriorPath) - } - - function goUp() - { - openFolder(control.currentFMList.parentPath) - } - - function refresh() - { - const pos = browserView.currentView.contentY - browserView.currentView.contentY = pos - } - - function addToSelection(item) - { - if(item.path.startsWith("tags://") || item.path.startsWith("applications://") ) - return - - if(!control.selectionBar) - selectionBarLoader.sourceComponent = selectionBarComponent - - control.selectionBar.append(item) - } - - function clearSelection() - { - if(control.selectionBar) - { - control.selectionBar.clear() - selectionBarLoader.sourceComponent = null - } - } - - function copy(urls) - { - Maui.Handy.copyToClipboard({"urls": urls}) - control.isCut = false - control.isCopy = true - } - - function cut(urls) - { - Maui.Handy.copyToClipboard({"urls": urls}) - control.isCut = true - control.isCopy = false - } - - function paste() - { - const urls = Maui.Handy.getClipboard().urls - - if(!urls) - return - - if(control.isCut) + } + + function goBack() + { + openFolder(control.currentFMList.previousPath) + // browserView.currentView.currentIndex = indexHistory.pop() + } + + function goNext() + { + openFolder(control.currentFMList.posteriorPath) + } + + function goUp() + { + openFolder(control.currentFMList.parentPath) + } + + function refresh() + { + const pos = browserView.currentView.contentY + browserView.currentView.contentY = pos + } + + function addToSelection(item) + { + if(item.path.startsWith("tags://") || item.path.startsWith("applications://") ) + return + + if(!control.selectionBar) + selectionBarLoader.sourceComponent = selectionBarComponent + + control.selectionBar.append(item) + } + + function clearSelection() + { + if(control.selectionBar) + { + control.selectionBar.clear() + selectionBarLoader.sourceComponent = null + } + } + + function copy(urls) + { + Maui.Handy.copyToClipboard({"urls": urls}) + control.isCut = false + control.isCopy = true + } + + function cut(urls) + { + Maui.Handy.copyToClipboard({"urls": urls}) + control.isCut = true + control.isCopy = false + } + + function paste() + { + const urls = Maui.Handy.getClipboard().urls + + if(!urls) + return + + if(control.isCut) { control.currentFMList.cutInto(urls) control.clearSelection() }else { control.currentFMList.copyInto(urls) } - } - - function remove(urls) - { - dialogLoader.sourceComponent= removeDialogComponent - dialog.urls = urls - dialog.open() - } - - function selectAll() //TODO for now dont select more than 100 items so things dont freeze or break - { - for(var i = 0; i < Math.min(control.currentFMList.count, 100); i++) - addToSelection(control.currentFMList.get(i)) - } - - function bookmarkFolder(paths) //multiple paths - { - control.newBookmark(paths) - } - - function zoomIn() - { - control.thumbnailsSize = control.thumbnailsSize + 8 - } - - function zoomOut() - { - const newSize = control.thumbnailsSize - 8 - - if(newSize >= Maui.Style.iconSizes.small) - control.thumbnailsSize = newSize - } - - function groupBy() - { - var prop = "" - var criteria = ViewSection.FullString - - switch(control.currentFMList.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; - } - - if(!prop) - { - control.browserView.currentView.section.property = "" - return - } - - control.browserView.viewType = Maui.FMList.LIST_VIEW - control.browserView.currentView.section.property = prop - control.browserView.currentView.section.criteria = criteria - } - - function openConfigDialog() - { - dialogLoader.sourceComponent = _configDialogComponent - control.dialog.open() - } + } + + function remove(urls) + { + dialogLoader.sourceComponent= removeDialogComponent + dialog.urls = urls + dialog.open() + } + + function selectAll() //TODO for now dont select more than 100 items so things dont freeze or break + { + for(var i = 0; i < Math.min(control.currentFMList.count, 100); i++) + addToSelection(control.currentFMList.get(i)) + } + + function bookmarkFolder(paths) //multiple paths + { + control.newBookmark(paths) + } + + function zoomIn() + { + control.thumbnailsSize = control.thumbnailsSize + 8 + } + + function zoomOut() + { + const newSize = control.thumbnailsSize - 8 + + if(newSize >= Maui.Style.iconSizes.small) + control.thumbnailsSize = newSize + } + + function groupBy() + { + var prop = "" + var criteria = ViewSection.FullString + + switch(control.currentFMList.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; + } + + if(!prop) + { + control.browserView.currentView.section.property = "" + return + } + + control.browserView.viewType = Maui.FMList.LIST_VIEW + control.browserView.currentView.section.property = prop + control.browserView.currentView.section.criteria = criteria + } + + function openConfigDialog() + { + dialogLoader.sourceComponent = _configDialogComponent + control.dialog.open() + } } diff --git a/src/controls/SelectionBar.qml b/src/controls/SelectionBar.qml index d5bb792..aced876 100644 --- a/src/controls/SelectionBar.qml +++ b/src/controls/SelectionBar.qml @@ -1,390 +1,390 @@ /* * 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 focus: true Kirigami.Theme.inherit: false Kirigami.Theme.colorSet: Kirigami.Theme.Complementary - readonly property int barHeight : Maui.Style.iconSizes.large + (Maui.Style.space.large * 1.8) + readonly property int barHeight : Maui.Style.iconSizes.large + (Maui.Style.space.large * 1.5) property var selectedPaths: [] property var selectedItems: [] property alias selectionList : selectionList property alias anim : anim property alias model : selectionList.model property alias count : selectionList.count property color animColor : "black" property int position: Qt.Horizontal property string iconName : "overflow-menu" property bool iconVisible: true /** * if singleSelection is set to true then only a single item is selected * at time, and replaced with a newe item appended **/ property bool singleSelection: false signal iconClicked() signal cleared() signal exitClicked() signal itemClicked(int index) signal itemPressAndHold(int index) signal itemAdded(var item) signal itemRemoved(var item) signal pathAdded(string path) signal pathRemoved(string path) signal clicked(var mouse) signal rightClicked(var mouse) implicitHeight: if(position === Qt.Horizontal) barHeight else if(position === Qt.Vertical) parent.height else undefined implicitWidth: if(position === Qt.Horizontal) parent.width else if(position === Qt.Vertical) barHeight else undefined visible: control.count > 0 Rectangle { id: bg anchors.fill: parent color: Qt.rgba(Kirigami.Theme.backgroundColor.r, Kirigami.Theme.backgroundColor.g, Kirigami.Theme.backgroundColor.b, 0.6) radius: Maui.Style.radiusV opacity: 1 border.color: Kirigami.Theme.backgroundColor MouseArea { anchors.fill: parent acceptedButtons: Qt.RightButton | Qt.LeftButton onClicked: { if(!Kirigami.Settings.isMobile && mouse.button === Qt.RightButton) control.rightClicked(mouse) else control.clicked(mouse) } onPressAndHold : { if(Kirigami.Settings.isMobile) control.rightClicked(mouse) } } SequentialAnimation { id: anim PropertyAnimation { target: bg property: "opacity" easing.type: Easing.InOutQuad from: 0.5 to: 1 duration: 600 } } } Maui.Badge { anchors.verticalCenter: parent.top anchors.horizontalCenter: parent.left iconName: "qrc://assets/dialog-close.svg" Kirigami.Theme.backgroundColor: Kirigami.Theme.negativeTextColor Kirigami.Theme.textColor: Kirigami.Theme.highlightedTextColor z: parent.z +1 onClicked: { clear() exitClicked() } } Maui.Badge { Kirigami.Theme.backgroundColor: Kirigami.Theme.highlightColor text: selectionList.count z: parent.z +1 anchors.verticalCenter: parent.top anchors.horizontalCenter: parent.right onClicked: clear() } GridLayout { anchors.fill: parent anchors.margins: Maui.Style.space.small rows: if(position === Qt.Horizontal) 1 else if(position === Qt.Vertical) 4 else undefined columns: if(position === Qt.Horizontal) 4 else if(position === Qt.Vertical) 1 else undefined Item { Layout.fillHeight: true Layout.fillWidth: true Layout.leftMargin: Maui.Style.space.small Layout.column: if(position === Qt.Horizontal) 2 else if(position === Qt.Vertical) 1 else undefined Layout.row: if(position === Qt.Horizontal) 1 else if(position === Qt.Vertical) 2 else undefined ListView { id: selectionList anchors.fill: parent highlightFollowsCurrentItem: true highlightMoveDuration: 0 keyNavigationEnabled: true interactive: Kirigami.Settings.isMobile boundsBehavior: !Kirigami.Settings.isMobile? Flickable.StopAtBounds : Flickable.OvershootBounds orientation: if(position === Qt.Horizontal) ListView.Horizontal else if(position === Qt.Vertical) ListView.Vertical else undefined clip: true focus: true spacing: Maui.Style.space.small ScrollBar.horizontal: ScrollBar { policy: Kirigami.Settings.isMobile? Qt.ScrollBarAlwaysOff : Qt.ScrollBarAsNeeded } model: ListModel{} delegate: Maui.GridBrowserDelegate { id: delegate isCurrentItem: ListView.isCurrentItem height: selectionList.height * 0.95 width: height + Maui.Style.space.big folderSize: Maui.Style.iconSizes.big showLabel: true keepEmblemOverlay: true leftEmblem: "list-remove" showEmblem: !Kirigami.Settings.isMobile showTooltip: true showThumbnails: true emblemSize: Maui.Style.iconSizes.small Kirigami.Theme.backgroundColor: "transparent" Kirigami.Theme.textColor: control.Kirigami.Theme.textColor Connections { target: delegate onLeftEmblemClicked: removeAtIndex(index) onClicked: control.itemClicked(index) onPressAndHold: control.itemPressAndHold(index) } } } } Item { Layout.fillWidth: position === Qt.Vertical Layout.fillHeight: position === Qt.Horizontal Layout.preferredWidth: Maui.Style.iconSizes.medium Layout.preferredHeight: Maui.Style.iconSizes.medium Layout.column: if(position === Qt.Horizontal) 3 else if(position === Qt.Vertical) 1 else undefined Layout.row: if(position === Qt.Horizontal) 1 else if(position === Qt.Vertical) 3 else undefined Layout.margins: Maui.Style.space.medium ToolButton { visible: iconVisible anchors.centerIn: parent icon.name: control.iconName icon.color: control.Kirigami.Theme.textColor onClicked: iconClicked() } } } onVisibleChanged: { if(position === Qt.Vertical) return } Keys.onEscapePressed: { control.exitClicked(); event.accepted = true } Keys.onBackPressed: { control.exitClicked(); event.accepted = true } function clear() { selectedPaths = [] selectedItems = [] selectionList.model.clear() control.cleared() } function itemAt(index) { if(index < 0 || index > selectionList.count) return return selectionList.model.get(index) } function removeAtIndex(index) { if(index < 0) return const item = selectionList.model.get(index) const path = item.path if(contains(path)) { selectedPaths.splice(index, 1) selectedItems.splice(index, 1) selectionList.model.remove(index) control.itemRemoved(item) control.pathRemoved(path) } } function removeAtPath(path) { removeAtIndex(indexOf(path)) } function indexOf(path) { return control.selectedPaths.indexOf(path) } function append(item) { const index = selectedPaths.indexOf(item.path) if(index < 0) { if(control.singleSelection) clear() selectedItems.push(item) selectedPaths.push(item.path) selectionList.model.append(item) selectionList.positionViewAtEnd() selectionList.currentIndex = selectionList.count - 1 control.itemAdded(item) control.pathAdded(item.path) }else { selectionList.currentIndex = index // notify(item.icon, qsTr("Item already selected!"), String("The item '%1' is already in the selection box").arg(item.label), null, 4000) } animate(Kirigami.Theme.backgroundColor) } function animate(color) { animColor = color anim.running = true } function getSelectedPathsString() { return String(""+selectedPaths.join(",")) } function contains(path) { return control.selectedPaths.includes(path) } } diff --git a/src/controls/ToolActions.qml b/src/controls/ToolActions.qml index efe8184..a5a771b 100644 --- a/src/controls/ToolActions.qml +++ b/src/controls/ToolActions.qml @@ -1,192 +1,175 @@ import QtQuick 2.9 import QtQuick.Controls 2.3 import QtQuick.Layouts 1.3 import QtQml.Models 2.3 import QtQml 2.1 import org.kde.kirigami 2.7 as Kirigami import org.kde.mauikit 1.0 as Maui MouseArea { id: control implicitWidth: _layout.implicitWidth + Maui.Style.space.medium implicitHeight: parent.height - default property list actions + default property list actions property bool autoExclusive: true property int direction : Qt.Vertical - + property Action currentAction : actions[0] property bool expanded : false - Rectangle - { - anchors.fill: parent - color: control.expanded ? "#333" : "transparent" - opacity: 0.1 - radius: Math.min(Maui.Style.radiusV, height) - - Behavior on color - { - ColorAnimation - { - duration: Kirigami.Units.longDuration - } - } - } + // Rectangle + // { + // anchors.fill: parent + // color: control.expanded ? "#333" : "transparent" + // opacity: 0.1 + // radius: Math.min(Maui.Style.radiusV, height) + // + // Behavior on color + // { + // ColorAnimation + // { + // duration: Kirigami.Units.longDuration + // } + // } + // } onClicked: { control.expanded = !control.expanded } Row { id: _layout height: parent.height - spacing: 0 + spacing: Maui.Style.space.small anchors.centerIn: parent - Item - { - visible: control.direction === Qt.Vertical || (control.direction === Qt.Horizontal && !control.expanded) - - width: parent.height - height: width - Kirigami.Icon - { - source: control.currentAction.icon.name - width: Maui.Style.iconSizes.medium - height: width - anchors.centerIn: parent - } - - } - -// Label -// { -// visible: control.direction === Qt.Vertical || (control.direction === Qt.Horizontal && !control.expanded) -// text: control.currentAction.text -// height: parent.height -// } - Rectangle - { - color:/* control.expanded && control.direction === Qt.Horizontal? Kirigami.Theme.highlightColor :*/ "transparent" - height: parent.height - width: control.expanded && control.direction === Qt.Horizontal? height : Maui.Style.iconSizes.small - radius: Maui.Style.radiusV - Kirigami.Icon - { - source: control.direction === Qt.Horizontal ? ( control.expanded ? "go-previous" : "go-next") : (control.direction === Qt.Vertical ? "qrc://assets/arrow-down.svg" : "") - width: Maui.Style.iconSizes.small - height: width - anchors.centerIn: parent - isMask: true - } - } + ToolButton + { + icon.name: control.currentAction.icon.name + text: " " + onClicked: control.expanded = !control.expanded + + Kirigami.Icon + { + anchors + { + right: parent.right + verticalCenter: parent.verticalCenter + } + color: control.Kirigami.Theme.textColor + source: "qrc://assets/arrow-down.svg" + width: Maui.Style.iconSizes.small + height: width + isMask: true + } + } + Loader { id: _loader height: parent.height - sourceComponent: control.direction === Qt.Horizontal ? _rowComponent : (control.direction === Qt.Vertical ? _menuComponent : null) + sourceComponent: control.direction === Qt.Horizontal ? _rowComponent : (control.direction === Qt.Vertical ? _menuComponent : "") } } Component { id: _rowComponent Row { id: _row width: control.expanded ? implicitWidth : 0 spacing: Maui.Style.space.medium clip: true height: parent.height Behavior on width { NumberAnimation { duration: Kirigami.Units.longDuration easing.type: Easing.InOutQuad } } Kirigami.Separator { width: 1 height: parent.height * 0.7 anchors.verticalCenter: parent.verticalCenter - } - + } Repeater { model: control.actions ToolButton { action: modelData autoExclusive: control.autoExclusive anchors.verticalCenter: parent.verticalCenter onClicked: { control.currentAction = action control.expanded = false } } } } } Component { id: _menuComponent Menu { id: _actionsMenu Connections { target: control onExpandedChanged: { if(control.expanded) _actionsMenu.popup(0, parent.height) else _actionsMenu.close() } } onClosed: control.expanded = false - closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutsideParent + closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutsideParent Repeater { model: control.actions MenuItem { action: modelData autoExclusive: control.autoExclusive - Connections - { - target: modelData - onTriggered: control.currentAction = action - } + Connections + { + target: modelData + onTriggered: control.currentAction = action + } } } } } } diff --git a/src/controls/ToolButtonMenu.qml b/src/controls/ToolButtonMenu.qml new file mode 100644 index 0000000..ff6d45d --- /dev/null +++ b/src/controls/ToolButtonMenu.qml @@ -0,0 +1,49 @@ +import QtQuick 2.9 +import QtQuick.Controls 2.3 +import QtQuick.Layouts 1.3 +import QtQml.Models 2.3 +import QtQml 2.1 + +import org.kde.kirigami 2.7 as Kirigami +import org.kde.mauikit 1.0 as Maui + +ToolButton +{ + id: control + default property list content + checked: _menu.visible + checkable: false + text: " " + display: ToolButton.TextBesideIcon + + onClicked: + { + if(_menu.visible) + _menu.close() + else + _menu.popup(0, height) + } + + Kirigami.Icon + { + anchors + { + right: parent.right + verticalCenter: parent.verticalCenter + } + color: control.Kirigami.Theme.textColor + source: "qrc://assets/arrow-down.svg" + width: Maui.Style.iconSizes.small + height: width + isMask: true + } + + + Menu + { + id: _menu + closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutsideParent + + contentData: control.content + } +} diff --git a/src/controls/qmldir b/src/controls/qmldir index e2d5183..1611209 100644 --- a/src/controls/qmldir +++ b/src/controls/qmldir @@ -1,60 +1,61 @@ module org.kde.mauikit plugin MauiKit classname MauiKit depends QtQuick.Controls 1.4 depends QtQuick.Controls.Private 1.0 depends QtQuick.Controls 2.0 depends QtGraphicalEffects 1.0 designersupported typeinfo plugins.qmltypes singleton Style 1.0 Style.qml ApplicationWindow 1.0 ApplicationWindow.qml ToolBar 1.0 ToolBar.qml Page 1.0 Page.qml ShareDialog 1.0 ShareDialog.qml PieButton 1.0 PieButton.qml SideBar 1.0 SideBar.qml AbstractSideBar 1.0 AbstractSideBar.qml GlobalDrawer 1.0 GlobalDrawer.qml ListDelegate 1.0 ListDelegate.qml ItemDelegate 1.0 ItemDelegate.qml SwipeItemDelegate 1.0 SwipeItemDelegate.qml SwipeBrowserDelegate 1.0 SwipeBrowserDelegate.qml ListBrowserDelegate 1.0 ListBrowserDelegate.qml GridBrowserDelegate 1.0 GridBrowserDelegate.qml SelectionBar 1.0 SelectionBar.qml LabelDelegate 1.0 LabelDelegate.qml NewDialog 1.0 NewDialog.qml TagsBar 1.0 TagsBar.qml TagsDialog 1.0 TagsDialog.qml Taglist 1.0 private/TagList.qml GridBrowser 1.0 GridBrowser.qml ListBrowser 1.0 ListBrowser.qml FileBrowser 1.0 FileBrowser.qml FilePreviewer 1.0 FilePreviewer.qml FileDialog 1.0 FileDialog.qml PlacesSidebar 1.0 PlacesSidebar.qml PlacesListBrowser 1.0 PlacesListBrowser.qml PathBar 1.0 PathBar.qml Dialog 1.0 Dialog.qml Popup 1.0 Popup.qml AboutDialog 1.0 AboutDialog.qml TextField 1.0 TextField.qml Badge 1.0 Badge.qml GridView 1.0 GridView.qml Terminal 1.0 Terminal.qml SyncDialog 1.0 SyncDialog.qml SyncDialog 1.0 SyncDialogA.qml Editor 1.0 Editor.qml ColorsBar 1.0 ColorsBar.qml Holder 1.0 Holder.qml ImageViewer 1.0 ImageViewer.qml TabBar 1.0 TabBar.qml TabButton 1.0 TabButton.qml ActionGroup 1.0 ActionGroup.qml ActionSideBar 1.0 ActionSideBar.qml ToolActions 1.0 ToolActions.qml DocumentPreview 1.0 DocumentPreview.qml +ToolButtonMenu 1.0 ToolButtonMenu.qml