diff --git a/demo/src/main.qml b/demo/src/main.qml index 4f9a060..ca8a40c 100644 --- a/demo/src/main.qml +++ b/demo/src/main.qml @@ -1,349 +1,359 @@ import QtQuick 2.9 -import QtQuick.Controls 2.3 -import org.kde.mauikit 1.0 as Maui +import QtQuick.Controls 2.2 import QtQuick.Layouts 1.3 + +import org.kde.mauikit 1.0 as Maui import org.kde.kirigami 2.6 as Kirigami -import StoreList 1.0 +import QtQuick.Templates 2.3 as T Maui.ApplicationWindow { id: root // isWide : root.width >= Kirigami.Units.gridUnit * 10 property int currentPageIndex : 0 // about.appDescription: "MauiDemo is a gallery app displaying the MauiKit controls in conjuction with Kirigami and QQC2 controls." property alias dialog : _dialogLoader.item floatingBar: false mainMenu: [ Maui.MenuItem { text: qsTr("File dialog") icon.name: "folder-open" onTriggered: { _dialogLoader.sourceComponent = _fileDialogComponent dialog.callback = function(paths) { console.log("Selected paths >> ", paths) } dialog.open() } } ] headBar.spacing: space.huge headBar.middleContent: [ Maui.ToolButton { // Layout.fillHeight: true iconName: "nx-home" colorScheme.textColor : root.headBarFGColor spacing: space.medium active: currentPageIndex === 0 showIndicator: true onClicked: currentPageIndex = 0 text: qsTr("Home") }, Maui.ToolButton { // Layout.fillHeight: true iconName: "view-list-icons" colorScheme.textColor: root.headBarFGColor spacing: space.medium active: currentPageIndex === 1 showIndicator: true onClicked: currentPageIndex = 1 text: qsTr("Browser") }, Maui.ToolButton { // Layout.fillHeight: true iconName: "view-media-genre" colorScheme.textColor: root.headBarFGColor spacing: space.medium active: currentPageIndex === 2 showIndicator: true onClicked: currentPageIndex = 2 text: qsTr("Editor") }, Maui.ToolButton { // Layout.fillHeight: true iconName: "nx-software-center" colorScheme.textColor: root.headBarFGColor spacing: space.medium active: currentPageIndex === 3 showIndicator: true onClicked: currentPageIndex = 3 text: qsTr("Store") } ] footBar.leftContent: Maui.ToolButton { iconName: "view-split-left-right" onClicked: _drawer.visible = !_drawer.visible checked: _drawer.visible } footBar.rightContent: Kirigami.ActionToolBar { Layout.fillWidth: true actions: [ Kirigami.Action { iconName: "folder-new" text: "New folder" icon.width: iconSizes.medium icon.height: iconSizes.medium + expandible: true + + Kirigami.Action + { + text: "exmaple" + icon.name: "love" + } + }, Kirigami.Action { + id: _findAction iconName: "edit-find" - text: "Search" + text: parent == T.ToolButton ? "Search" : undefined icon.width: iconSizes.medium icon.height: iconSizes.medium }, Kirigami.Action { iconName: "document-preview-archive" text: "Hidden files" icon.width: iconSizes.medium icon.height: iconSizes.medium } ] } globalDrawer: Maui.GlobalDrawer { id: _drawer width: Kirigami.Units.gridUnit * 14 modal: !root.isWide actions: [ Kirigami.Action { text: qsTr("Shopping") iconName: "cpu" }, Kirigami.Action { text: qsTr("Notes") iconName: "send-sms" }, Kirigami.Action { text: qsTr("Example 3") iconName: "love" } ] } content: SwipeView { anchors.fill: parent currentIndex: currentPageIndex onCurrentIndexChanged: currentPageIndex = currentIndex Maui.Page { id: _page1 Item { anchors.fill: parent ColumnLayout { anchors.centerIn: parent width: Math.max(Math.min(implicitWidth, parent.width), Math.min(400, parent.width)) Label { text: "Header bar background color" Layout.fillWidth: true } Maui.TextField { Layout.fillWidth: true placeholderText: root.headBarBGColor onAccepted: { root.headBarBGColor= text } } Label { text: "Header bar foreground color" Layout.fillWidth: true } Maui.TextField { Layout.fillWidth: true placeholderText: root.headBarFGColor onAccepted: { root.headBarFGColor = text } } Label { text: "Header bar background color" Layout.fillWidth: true } Maui.TextField { Layout.fillWidth: true onAccepted: { root.headBarBGColor= text } } // CheckBox // { // text: "Draw toolbar borders" // Layout.fillWidth: true // onCheckedChanged: // { // headBar.drawBorder = checked // footBar.drawBorder = checked // } // } } } headBar.rightContent: Maui.ToolButton { iconName: "documentinfo" text: qsTr("Notify") onClicked: { var callback = function() { _batteryBtn.visible = true } notify("battery", qsTr("Plug your device"), qsTr("Your device battery level is below 20%, please plug your device to a power supply"), callback, 5000) } } headBar.leftContent: Maui.ToolButton { id: _batteryBtn visible: false iconName: "battery" } } Maui.FileBrowser { id: _page2 onItemClicked: openItem(index) } Maui.Page { id: _page3 margins: 0 headBar.visible: false Maui.Editor { id: _editor anchors { fill: parent // top: parent.top // right: parent.right // left: parent.left // bottom: _terminal.top } } // Maui.Terminal // { // id: _terminal //// anchors //// { //// top: _editor.top //// right: parent.right //// left: parent.left //// bottom: parent.bottom //// } // } footBar.rightContent: Maui.ToolButton { iconName: "utilities-terminal" onClicked: { // _terminal.visible = _terminal.visible } } } Maui.Store { id: _page4 list.provider: StoreList.KDELOOK list.category: StoreList.WALLPAPERS } } //Components ///Dialog loaders Loader { id: _dialogLoader } Component { id: _fileDialogComponent Maui.FileDialog { } } } diff --git a/src/controls/ApplicationWindow.qml b/src/controls/ApplicationWindow.qml index bb56391..a7e3c99 100644 --- a/src/controls/ApplicationWindow.qml +++ b/src/controls/ApplicationWindow.qml @@ -1,596 +1,596 @@ /* * 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.Window 2.0 import QtQuick.Layouts 1.3 import QtGraphicalEffects 1.0 import QtQuick.Window 2.3 import org.kde.kirigami 2.2 as Kirigami import org.kde.mauikit 1.0 as Maui import QtQuick.Controls.Material 2.1 import "private" import SyncingModel 1.0 import SyncingList 1.0 Kirigami.AbstractApplicationWindow { id: root visible: true width: Screen.width * (isMobile ? 1 : 0.4) height: Screen.height * (isMobile ? 1 : 0.4) contentItem.anchors.leftMargin: 0 contentItem.anchors.rightMargin: 0 contentItem.anchors.margins: 0 property bool showAccounts : true /***************************************************/ /******************** ALIASES *********************/ /*************************************************/ property alias page : page property alias footBar : page.footBar property alias headBar : page.headBar property alias dialog: dialogLoader.item property alias leftIcon : menuBtn property alias rightIcon : searchBtn default property alias content : page.content - property alias mainMenu : mainMenu.content + property alias mainMenu : mainMenu.contentData property alias about : aboutDialog property alias accounts: _accountsDialogLoader.item property alias currentAccount: _accountCombobox.currentText property alias notifyDialog: _notify //redefines here as here we can know a pointer to PageRow wideScreen: isWide /***************************************************/ /*********************** UI ***********************/ /*************************************************/ property bool isWide : root.width >= Kirigami.Units.gridUnit * 30 property int radiusV : unit * 4 property int iconSize : iconSizes.medium * (isMobile ? 0.95 : 1) readonly property int unit : Maui.Style.unit readonly property int rowHeight: Maui.Style.rowHeight readonly property int rowHeightAlt: Maui.Style.rowHeightAlt readonly property int toolBarHeight: Maui.Style.toolBarHeight readonly property int toolBarHeightAlt: Maui.Style.toolBarHeightAlt readonly property int contentMargins: space.medium readonly property var fontSizes: Maui.Style.fontSizes readonly property var space : Maui.Style.space readonly property var iconSizes : Maui.Style.iconSizes property string colorSchemeName : Qt.application.name /***************************************************/ /********************* COLORS *********************/ /*************************************************/ readonly property var colorScheme: ({ Default : 1, Light : 2, Dark: 3, Custom: 4 }) property color borderColor: Qt.tint(textColor, Qt.rgba(backgroundColor.r, backgroundColor.g, backgroundColor.b, 0.7)) property color backgroundColor: Maui.Style.backgroundColor property color textColor: Maui.Style.textColor property color highlightColor: Maui.Style.highlightColor property color highlightedTextColor: Maui.Style.highlightedTextColor property color buttonBackgroundColor: Maui.Style.buttonBackgroundColor property color viewBackgroundColor: Maui.Style.viewBackgroundColor property color altColor: Maui.Style.altColor property color altColorText: Maui.Style.altColorText property color accentColor : buttonBackgroundColor property color bgColor: viewBackgroundColor property color headBarBGColor: backgroundColor property color headBarFGColor: textColor readonly property string darkBorderColor: Qt.darker(darkBackgroundColor, 1.5) readonly property string darkBackgroundColor: "#303030" readonly property string darkTextColor: "#FAFAFA" readonly property string darkHighlightColor: "#29B6F6" readonly property string darkHighlightedTextColor: darkTextColor readonly property string darkViewBackgroundColor: "#212121" readonly property string darkDarkColor: "#191919" readonly property string darkButtonBackgroundColor : "#191919" readonly property color darkAltColor: "#333" readonly property color darkAltColorText: darkTextColor readonly property color darkAccentColor : darkButtonBackgroundColor readonly property color darkBgColor: darkBackgroundColor property color warningColor : Maui.Style.warningColor property color dangerColor : Maui.Style.dangerColor property color infoColor : Maui.Style.infoColor property color suggestedColor : Maui.Style.suggestedColor /* ANDROID THEMING*/ Material.theme: Material.Light Material.accent: highlightColor Material.background: headBarBGColor Material.primary: headBarBGColor Material.foreground: 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 /***************************************************/ /********************* PROPS **********************/ /*************************************************/ property bool altToolBars : isMobile property bool floatingBar : altToolBars property int footBarAligment : Qt.AlignCenter property bool footBarOverlap : false property bool allowRiseContent: floatingBar && footBarOverlap property int footBarMargins: space.big property alias searchButton : searchBtn property alias menuButton : menuBtn /***************************************************/ /******************** SIGNALS *********************/ /*************************************************/ signal menuButtonClicked(); signal searchButtonClicked(); signal goBackTriggered(); signal goFowardTriggered(); // overlay.modal: Rectangle // { // color: Color.transparent(altColor, 0.5) // } // overlay.modeless: Rectangle { // color: "transparent" // } onClosing: { if(!isMobile) { var height = root.height var width = root.width var x = root.x var 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 && !altToolBars) Maui.KDE.setColorScheme(colorSchemeName, headBarBGColor, headBarFGColor) else if(isAndroid && !altToolBars) Maui.Android.statusbarColor(headBarBGColor, false) else if(isAndroid && altToolBars) Maui.Android.statusbarColor(viewBackgroundColor, true) } onHeadBarFGColorChanged: { if(!isAndroid && !isMobile && colorSchemeName.length > 0 && !altToolBars) Maui.KDE.setColorScheme(colorSchemeName, headBarBGColor, headBarFGColor) else if(isAndroid && !altToolBars) Maui.Android.statusbarColor(headBarBGColor, false) else if(isAndroid && altToolBars) Maui.Android.statusbarColor(viewBackgroundColor, true) } background: Rectangle { color: bgColor } // globalDrawer.height: root.height - headBar.height // globalDrawer.y: headBar.height Maui.Page { id: page anchors.fill: parent leftMargin: root.globalDrawer && (root.globalDrawer.modal === false) ? root.globalDrawer.contentItem.width * root.globalDrawer.position : 0 margins: 0 headBar.plegable: false headBar.height: toolBarHeight + space.small headBar.implicitHeight: toolBarHeight + space.small headBarExit: false altToolBars: root.altToolBars floatingBar : root.floatingBar footBarAligment : root.footBarAligment footBarOverlap : root.footBarOverlap footBarMargins: root.footBarMargins allowRiseContent: root.allowRiseContent background: Rectangle { color: bgColor } headBar.colorScheme.backgroundColor: headBarBGColor headBar.colorScheme.textColor: headBarFGColor headBar.leftContent: Maui.ToolButton { id: menuBtn iconName: "application-menu" iconColor: headBarFGColor checked: mainMenu.visible onClicked: { menuButtonClicked() mainMenu.visible ? mainMenu.close() : mainMenu.popup(parent, parent.x , altToolBars ? 0 : parent.height+ space.medium) } - Maui.Menu + Menu { id: mainMenu modal: true width: unit * 200 Item { height: _accountCombobox.visible ? unit * 90 : 0 anchors { left: parent.left right: parent.right top: parent.top margins: space.medium } Maui.ComboBox { id: _accountCombobox anchors.centerIn: parent // parent: mainMenu popup.z: 999 width: parent.width visible: (count > 1) && showAccounts textRole: "user" flat: true model: showAccounts ? accounts.model : undefined iconButton.iconName: "user-identity" iconButton.isMask: false } } MenuSeparator { visible: _accountCombobox.visible } - Maui.MenuItem + MenuItem { text: qsTr("Accounts") visible: root.showAccounts icon.name: "list-add-user" onTriggered: { if(root.accounts) accounts.open() } } - Maui.MenuItem + MenuItem { text: qsTr("About") icon.name: "documentinfo" onTriggered: aboutDialog.open() } MenuSeparator {} } } headBar.rightContent: Maui.ToolButton { id: searchBtn iconName: "edit-find" iconColor: headBarFGColor onClicked: searchButtonClicked() } Keys.onBackPressed: { goBackTriggered(); console.log("GO BACK CLICKED") event.accepted = true } Shortcut { sequence: "Forward" onActivated: goFowardTriggered(); } Shortcut { sequence: StandardKey.Forward onActivated: goFowardTriggered(); } Shortcut { sequence: StandardKey.Back onActivated: goBackTriggered(); } } Maui.AboutDialog { id: aboutDialog } Loader { id: _accountsDialogLoader sourceComponent: root.showAccounts ? _accountsDialogComponent : undefined } Component { id: _accountsDialogComponent AccountsHelper {} } Maui.Dialog { id: _notify property var cb : ({}) verticalAlignment: Qt.AlignTop defaultButtons: false colorScheme.backgroundColor: altColor colorScheme.textColor: altColorText maxHeight: Math.max(unit * 120, (_notifyLayout.implicitHeight)) maxWidth: isMobile ? parent.width * 0.9 : unit * 500 Timer { id: _notifyTimer onTriggered: _notify.close() } onClosed: _notifyTimer.stop() MouseArea { anchors.fill: parent onClicked: { if(_notify.cb) _notify.cb() _notify.close() } } GridLayout { anchors.fill: parent columns: 2 rows: 1 Item { Layout.fillHeight: true Layout.preferredWidth: iconSizes.huge + space.big Layout.row: 1 Layout.column: 1 Maui.ToolButton { id: _notifyIcon size: iconSizes.large anchors.centerIn: parent isMask: false } } Item { Layout.fillHeight: true Layout.fillWidth: true Layout.row: 1 Layout.column: 2 ColumnLayout { anchors.fill: parent id: _notifyLayout Label { id: _notifyTitle Layout.fillHeight: true Layout.fillWidth: true font.weight: Font.Bold font.bold: true font.pointSize: fontSizes.big color: _notify.colorScheme.textColor elide: Qt.ElideRight wrapMode: Text.Wrap } Label { id: _notifyBody Layout.fillHeight: true Layout.fillWidth: true font.pointSize: fontSizes.default color: _notify.colorScheme.textColor elide: Qt.ElideRight wrapMode: Text.Wrap } } } } function show(callback) { _notify.cb = callback _notifyTimer.start() _notify.open() } } Loader { id: dialogLoader } Component.onCompleted: { if(isAndroid && altToolBars) Maui.Android.statusbarColor(backgroundColor, true) if(!isMobile) { var 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 } } // Connections // { // target: Maui.FM // // onNewItem: notify("dialog-information", qsTr("File uploaded"), "Your file has been uploaded to your account /n"+path) // onWarningMessage: notify("dialog-information", "Oops!", message) // } function switchColorScheme(variant) { switch(variant) { case colorScheme.Default: backgroundColor = Maui.Style.backgroundColor textColor = Maui.Style.textColor highlightColor = Maui.Style.highlightColor highlightedTextColor = Maui.Style.highlightedTextColor buttonBackgroundColor = Maui.Style.buttonBackgroundColor viewBackgroundColor = Maui.Style.viewBackgroundColor altColor = Maui.Style.altColor borderColor = Maui.Style.borderColor if(isAndroid) Maui.Android.statusbarColor(backgroundColor, true) break case colorScheme.Dark: borderColor = darkBorderColor backgroundColor = darkBackgroundColor textColor = darkTextColor highlightColor = darkHighlightColor highlightedTextColor = darkHighlightedTextColor buttonBackgroundColor = darkButtonBackgroundColor viewBackgroundColor = darkViewBackgroundColor altColor = darkDarkColor altColorText = darkAltColorText bgColor =darkBgColor if(isAndroid) Maui.Android.statusbarColor(backgroundColor, false) break } } function notify(icon, title, body, callback, timeout) { _notifyIcon.iconName = icon _notifyTitle.text = title _notifyBody.text = body _notifyTimer.interval = timeout ? timeout : 2500 _notify.show(callback) } /** FUNCTIONS **/ // function riseContent() // { // if(allowRiseContent) // flickable.flick(0, flickable.contentHeight* -2) // } // function dropContent() // { // if(allowRiseContent) // flickable.flick(0, flickable.contentHeight* 2) // } } diff --git a/src/controls/FileBrowser.qml b/src/controls/FileBrowser.qml index 105b146..a7c01ed 100644 --- a/src/controls/FileBrowser.qml +++ b/src/controls/FileBrowser.qml @@ -1,929 +1,921 @@ import QtQuick 2.9 import QtQuick.Controls 2.2 import QtQuick.Layouts 1.3 -import org.kde.kirigami 2.0 as Kirigami +import org.kde.kirigami 2.6 as Kirigami import org.kde.mauikit 1.0 as Maui import "private" import FMModel 1.0 import FMList 1.0 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 alias previewer : previewer - property alias menu : browserMenu.content + property alias menu : browserMenu.contentData 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() margins: 0 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 + width: unit *200 + z : 999 } Maui.FilePreviewer { id: previewer parent: parent onShareButtonClicked: control.shareFiles([url]) } FMModel { id: folderModel list: modelList } 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.bookmarkFolder([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 } } 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() } focus: true 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 === 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 === 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 === 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 !== FMList.APPS_PATH altToolBars: isMobile - headBar.rightContent: [ + headBar.rightContent: Kirigami.ActionToolBar + { + Layout.fillWidth: true + z: 999 + actions: [ - Maui.ToolButton + Kirigami.Action { - id: viewBtn iconName: list.viewType == FMList.ICON_VIEW ? "view-list-details" : "view-list-icons" - onClicked: control.switchView() + onTriggered: control.switchView() }, - Maui.ToolButton + Kirigami.Action { iconName: "view-sort" - tooltipText: qsTr("Sort by...") - onClicked: sortMenu.popup() - - Maui.Menu - { - id: sortMenu - - Maui.MenuItem - { - text: qsTr("Folders first") - checkable: true - checked: list.foldersFirst - onTriggered: list.foldersFirst = !list.foldersFirst - } - - MenuSeparator{} - - Maui.MenuItem - { - text: qsTr("Type") - checkable: true - checked: list.sortBy === FMList.MIME - onTriggered: list.sortBy = FMList.MIME - } - - Maui.MenuItem - { - text: qsTr("Date") - checkable: true - checked: list.sortBy === FMList.DATE - onTriggered: list.sortBy = FMList.DATE - } - - Maui.MenuItem - { - text: qsTr("Modified") - checkable: true - checked: list.sortBy === FMList.MODIFIED - onTriggered: list.sortBy = FMList.MODIFIED - } - - Maui.MenuItem - { - text: qsTr("Size") - checkable: true - checked: list.sortBy === FMList.SIZE - onTriggered: list.sortBy = FMList.SIZE - } - - Maui.MenuItem - { - text: qsTr("Name") - checkable: true - checked: list.sortBy === FMList.LABEL - onTriggered: list.sortBy = FMList.LABEL - } - - MenuSeparator {} - - Maui.MenuItem - { - id: groupAction - text: qsTr("Group") - checkable: true - onTriggered: - { - group = checked - group ? groupBy() : browser.section.property = "" - } - } - } + 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 === FMList.MIME + onTriggered: list.sortBy = FMList.MIME + } + + Kirigami.Action + { + text: qsTr("Date") + checked: list.sortBy === FMList.DATE + onTriggered: list.sortBy = FMList.DATE + } + + Kirigami.Action + { + text: qsTr("Modified") + checked: list.sortBy === FMList.MODIFIED + onTriggered: list.sortBy = FMList.MODIFIED + } + + Kirigami.Action + { + text: qsTr("Size") + checked: list.sortBy === FMList.SIZE + onTriggered: list.sortBy = FMList.SIZE + } + + Kirigami.Action + { + text: qsTr("Name") + checked: list.sortBy === FMList.LABEL + onTriggered: list.sortBy = FMList.LABEL + } + + Kirigami.Action + { + id: groupAction + text: qsTr("Group") + checked: group + onTriggered: + { + group = !group + if(group) + groupBy() + else + browser.section.property = "" + } + } + }, - Maui.ToolButton + Kirigami.Action { iconName: "item-select" checkable: true checked: selectionMode - onClicked: selectionMode = !selectionMode + onTriggered: selectionMode = !selectionMode }, - Maui.ToolButton + Kirigami.Action { iconName: "overflow-menu" - onClicked: browserMenu.show() - tooltipText: qsTr("Menu...") + onTriggered: browserMenu.show() } ] +} headBar.leftContent: [ Maui.ToolButton { iconName: "go-previous" onClicked: control.goBack() }, Maui.ToolButton { id: goUpButton visible: isAndroid iconName: "go-up" onClicked: control.goUp() }, Maui.ToolButton { iconName: "go-next" onClicked: control.goNext() } ] footBar.visible: false Component { id: selectionBarComponent Maui.SelectionBar { anchors.fill: parent onIconClicked: _selectionBarmenu.popup() onExitClicked: clearSelection() - Maui.Menu + Menu { id: _selectionBarmenu - Maui.MenuItem + MenuItem { text: qsTr("Copy...") onTriggered: { if(control.selectionBar) control.selectionBar.animate("#6fff80") control.copy(selectedItems) console.log(selectedItems) _selectionBarmenu.close() } } - Maui.MenuItem + MenuItem { text: qsTr("Cut...") onTriggered: { if(control.selectionBar) control.selectionBar.animate("#fff44f") control.cut(selectedItems) _selectionBarmenu.close() } } - Maui.MenuItem + MenuItem { text: qsTr("Share") onTriggered: { control.shareFiles(selectedPaths) _selectionBarmenu.close() } } MenuSeparator{} - Maui.MenuItem + MenuItem { text: qsTr("Remove...") - colorScheme.textColor: dangerColor + 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: list.viewType == FMList.ICON_VIEW ? gridViewBrowser : listViewBrowser Layout.margins: list.viewType == FMList.LIST_VIEW ? unit : contentMargins * 2 Layout.fillWidth: true Layout.fillHeight: true } Loader { id: selectionBarLoader Layout.fillWidth: true Layout.preferredHeight: control.selectionBar ? (control.selectionBar.visible ? control.selectionBar.barHeight : 0) : 0 Layout.leftMargin: contentMargins * (isMobile ? 3 : 2) Layout.rightMargin: contentMargins * (isMobile ? 3 : 2) Layout.bottomMargin: contentMargins*2 z: holder.z +1 } ProgressBar { id: _progressBar Layout.fillWidth: true Layout.alignment: Qt.AlignBottom height: iconSizes.medium 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 == 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 = modelList.get(index) var path = item.path switch(currentPathType) { case FMList.APPS_PATH: if(item.path.endsWith("/")) populate(path) else Maui.FM.runApplication(path) break case 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 === 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 == 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 switchView() { list.viewType = list.viewType === FMList.ICON_VIEW ? FMList.LIST_VIEW : FMList.ICON_VIEW } function bookmarkFolder(paths) { if(paths.length > 0) { for(var i in paths) { if(Maui.FM.isDefaultPath(paths[i])) continue Maui.FM.bookmark(paths[i]) } newBookmark() } } 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 FMList.LABEL: prop = "label" criteria = ViewSection.FirstCharacter break; case FMList.MIME: prop = "mime" break; case FMList.SIZE: prop = "size" break; case FMList.DATE: prop = "date" break; case FMList.MODIFIED: prop = "modified" break; } list.viewType = FMList.LIST_VIEW if(!prop) { browser.section.property = "" return } browser.section.property = prop browser.section.criteria = criteria } } diff --git a/src/controls/GridBrowser.qml b/src/controls/GridBrowser.qml index 7fa448a..bd658e5 100644 --- a/src/controls/GridBrowser.qml +++ b/src/controls/GridBrowser.qml @@ -1,106 +1,107 @@ /* * 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.mauikit 1.0 as Maui Maui.GridView { id: control itemSize : iconSizes.large spacing: isMobile ? itemSize * 0.7 : itemSize * 0.8 property bool showEmblem : true property string rightEmblem property string leftEmblem centerContent: false adaptContent: true property bool showPreviewThumbnails: true signal itemClicked(int index) signal itemDoubleClicked(int index) signal rightEmblemClicked(int index) signal leftEmblemClicked(int index) signal itemRightClicked(int index) cellWidth: itemSize + spacing cellHeight: itemSize + (spacing * 1.5) model: ListModel { id: gridModel } delegate: Maui.IconDelegate { id: delegate isDetails: false width: control.cellWidth * 0.9 height: control.cellHeight * 0.9 folderSize : control.itemSize showTooltip: true showEmblem: control.showEmblem showThumbnails: control.showPreviewThumbnails rightEmblem: control.rightEmblem leftEmblem: control.leftEmblem + opacity: (model.name).startsWith(".") ? 0.5 : 1 Connections { target: delegate onClicked: { control.currentIndex = index itemClicked(index) } onDoubleClicked: { control.currentIndex = index itemDoubleClicked(index) } onPressAndHold: { control.currentIndex = index control.itemRightClicked(index) } onRightClicked: { control.currentIndex = index control.itemRightClicked(index) } onRightEmblemClicked: { control.currentIndex = index control.rightEmblemClicked(index) } onLeftEmblemClicked: { control.currentIndex = index control.leftEmblemClicked(index) } } } } diff --git a/src/controls/Menu.qml b/src/controls/Menu.qml index 4f957fd..0a2b956 100644 --- a/src/controls/Menu.qml +++ b/src/controls/Menu.qml @@ -1,93 +1,24 @@ import QtQuick 2.0 import QtQuick.Controls 2.3 import QtQuick.Layouts 1.3 import org.kde.mauikit 1.0 as Maui import org.kde.kirigami 2.2 as Kirigami import "private" import QtQuick.Controls.Material 2.1 import QtQuick.Window 2.10 Menu { id: control /* Controlc color scheming */ ColorScheme { id: colorScheme backgroundColor: viewBackgroundColor } property alias colorScheme : colorScheme /***************************/ z: 999 - default property alias content : content.data - - closePolicy: Menu.CloseOnPressOutside - - implicitWidth: Math.max(background ? background.implicitWidth : 0, - contentItem ? contentItem.implicitWidth + leftPadding + rightPadding : 0) - implicitHeight: Math.max(background ? background.implicitHeight : 0, - contentItem ? contentItem.implicitHeight : 0) + topPadding + bottomPadding - margins: unit - padding: unit - cascade: true - transformOrigin: !cascade ? Item.Top : (mirrored ? Item.TopRight : Item.TopLeft) - delegate: MenuItem { } - - topPadding: menuBackground.radius - bottomPadding: menuBackground.radius - leftPadding: control.padding - rightPadding: control.padding - - rightMargin: control.margins - leftMargin: control.margins - topMargin: control.margins - bottomMargin: control.margins - - modal: isMobile - focus: true - parent: isMobile ? ApplicationWindow.overlay : undefined - - contentItem: ListView - { - id: content - implicitHeight: contentHeight - - model: control.contentModel - interactive: Window.window ? contentHeight > Window.window.height : false - clip: true - currentIndex: control.currentIndex - - ScrollIndicator.vertical: ScrollIndicator {} - } - - Material.accent: colorScheme.highlightColor - Material.background: colorScheme.backgroundColor - Material.primary: colorScheme.backgroundColor - Material.foreground: colorScheme.textColor - - enter: Transition - { - // grow_fade_in - NumberAnimation { property: "scale"; from: 0.9; to: 1.0; easing.type: Easing.OutQuint; duration: 220 } - NumberAnimation { property: "opacity"; from: 0.0; to: 1.0; easing.type: Easing.OutCubic; duration: 150 } - } - - exit: Transition - { - // shrink_fade_out - NumberAnimation { property: "scale"; from: 1.0; to: 0.9; easing.type: Easing.OutQuint; duration: 220 } - NumberAnimation { property: "opacity"; from: 1.0; to: 0.0; easing.type: Easing.OutCubic; duration: 150 } - } - - background: Rectangle - { - id: menuBackground - radius: radiusV - color: colorScheme.backgroundColor - border.color: colorScheme.borderColor - - implicitWidth: Kirigami.Units.gridUnit * 8 - implicitHeight: Kirigami.Units.gridUnit * 6 - } + default property alias content : control.contentData } diff --git a/src/controls/MenuItem.qml b/src/controls/MenuItem.qml index 84d2e57..3bff1e4 100644 --- a/src/controls/MenuItem.qml +++ b/src/controls/MenuItem.qml @@ -1,128 +1,36 @@ /* * 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.Layouts 1.3 import QtQuick.Controls 2.3 import org.kde.mauikit 1.0 as Maui import org.kde.kirigami 2.0 as Kirigami import "private" MenuItem { id: control /* Controlc color scheming */ ColorScheme {id: colorScheme} property alias colorScheme : colorScheme /***************************/ - - width: parent.width - height: control.visible ? rowHeight : 0 - spacing: space.medium - font.pointSize: fontSizes.default - - icon.width: iconSizes.medium - icon.height: iconSizes.medium - - Component - { - id: _iconComponent - - Item - { - anchors.fill: parent - - Kirigami.Icon - { - id: _controlIcon - anchors.centerIn: parent - source: control.icon.name - height: control.icon.height - width: control.icon.width - isMask: true - color: _controlLabel.color - } - } - } - - contentItem: RowLayout - { - anchors.fill: control - anchors.rightMargin: control.checkable ? control.indicator.width + control.spacing + space.big : control.spacing - anchors.leftMargin: control.spacing - - Loader - { - id: _iconLoader - Layout.fillHeight: true - Layout.preferredWidth: control.icon.name.length ? control.icon.width + space.medium : 0 - Layout.alignment: Qt.AlignVCenter - - sourceComponent: control.icon.name.length ? _iconComponent : undefined - } - - Item - { - Layout.fillHeight: true - Layout.fillWidth: true - Layout.alignment: Qt.AlignVCenter - Layout.leftMargin: control.icon.name.length ? space.medium : 0 - - Label - { - id: _controlLabel - visible: control.text - height: parent.height - width: parent.width - verticalAlignment: Qt.AlignVCenter - horizontalAlignment: Qt.AlignLeft - - text: control.action ? control.action.text : control.text - font: control.font - elide: Text.ElideRight - - color: control.hovered && !control.pressed ? colorScheme.highlightedTextColor : colorScheme.textColor - } - } - } - - indicator: CheckIndicator - { - id: _checkIndicator - root: control - anchors.right: control.right - anchors.rightMargin: control.spacing - } - background: Item - { - anchors.fill: parent - implicitWidth: Kirigami.Units.gridUnit * 8 - implicitHeight: rowHeight - - Rectangle - { - anchors.fill: parent - color: colorScheme.highlightColor - opacity: control.hovered && !control.pressed ? 1 : 0 - Behavior on opacity { NumberAnimation { duration: 150 } } - } - } } diff --git a/src/controls/TextField.qml b/src/controls/TextField.qml index 5f6e221..3623c99 100644 --- a/src/controls/TextField.qml +++ b/src/controls/TextField.qml @@ -1,193 +1,193 @@ /* * 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.Layouts 1.3 import QtQuick.Controls 2.2 import QtQuick.Controls.Material 2.1 import org.kde.kirigami 2.2 as Kirigami import QtQuick.Controls.impl 2.3 import QtQuick.Controls.Material.impl 2.3 import org.kde.mauikit 1.0 as Maui import "private" TextField { id: control /* Controlc color scheming */ ColorScheme {id: colorScheme} property alias colorScheme : colorScheme /***************************/ property alias menu : entryMenu signal cleared() signal goBackTriggered(); signal goFowardTriggered(); implicitWidth: Math.max(background ? background.implicitWidth : 0, placeholderText ? placeholder.implicitWidth + leftPadding + rightPadding : 0) || contentWidth + leftPadding + rightPadding implicitHeight: iconSizes.big height: implicitHeight width: implicitWidth z: 1 topPadding: space.tiny bottomPadding: space.tiny rightPadding: clearButton.width + space.small color: enabled ? colorScheme.textColor : Qt.lighter(colorScheme.textColor, 1.4) selectionColor: highlightColor selectedTextColor: highlightedTextColor persistentSelection: true verticalAlignment: TextInput.AlignVCenter horizontalAlignment: Text.AlignHCenter cursorDelegate: CursorDelegate { } selectByMouse: !isMobile focus: true wrapMode: TextInput.WordWrap onPressAndHold: entryMenu.popup() onPressed: { if(!isMobile && event.button === Qt.RightButton) entryMenu.popup() } Keys.onBackPressed: { goBackTriggered(); event.accepted = true } Shortcut { sequence: "Forward" onActivated: goFowardTriggered(); } Shortcut { sequence: StandardKey.Forward onActivated: goFowardTriggered(); } Shortcut { sequence: StandardKey.Back onActivated: goBackTriggered(); } Maui.ToolButton { id: clearButton visible: control.text.length anchors.top: control.top anchors.right: control.right anchors.rightMargin: space.small anchors.verticalCenter: parent.verticalCenter iconName: "edit-clear" iconColor: color onClicked: {control.clear(); cleared()} } Label { id: placeholder x: control.leftPadding y: control.topPadding width: control.width - (control.leftPadding + control.rightPadding) height: control.height - (control.topPadding + control.bottomPadding) text: control.placeholderText font: control.font color: Qt.lighter(colorScheme.textColor, 1.4) opacity: 0.4 horizontalAlignment: control.horizontalAlignment verticalAlignment: control.verticalAlignment visible: !control.length && !control.preeditText && (!control.activeFocus || control.horizontalAlignment !== Qt.AlignHCenter) elide: Text.ElideRight } background: Rectangle { implicitWidth: unit * 120 implicitHeight: iconSizes.big color: control.activeFocus ? Qt.lighter(colorScheme.backgroundColor, 1.4) : (control.hovered ? Qt.lighter(colorScheme.backgroundColor, 1.3) : colorScheme.backgroundColor) border.color: colorScheme.borderColor radius: radiusV border.width: unit } - Maui.Menu + Menu { id: entryMenu - Maui.MenuItem + MenuItem { text: qsTr("Copy") onTriggered: control.copy() enabled: control.selectedText.length } - Maui.MenuItem + MenuItem { text: qsTr("Cut") onTriggered: control.cut() enabled: control.selectedText.length } - Maui.MenuItem + MenuItem { text: qsTr("Paste") onTriggered: { var text = control.paste() control.insert(control.cursorPosition, text) } } - Maui.MenuItem + MenuItem { text: qsTr("Select all") onTriggered: control.selectAll() enabled: control.text.length } - Maui.MenuItem + MenuItem { text: qsTr("Undo") onTriggered: control.undo() enabled: control.canUndo } - Maui.MenuItem + MenuItem { text: qsTr("Redo") onTriggered: control.redo() enabled: control.canRedo } } } diff --git a/src/controls/private/BrowserMenu.qml b/src/controls/private/BrowserMenu.qml index 2620193..9f8d977 100644 --- a/src/controls/private/BrowserMenu.qml +++ b/src/controls/private/BrowserMenu.qml @@ -1,142 +1,143 @@ import QtQuick 2.9 import QtQuick.Controls 2.3 import QtQuick.Layouts 1.3 import org.kde.mauikit 1.0 as Maui import org.kde.kirigami 2.2 as Kirigami import FMList 1.0 -Maui.Menu +Menu { property int pasteFiles : 0 - +// popup.z : 999 /* Maui.MenuItem { che ckable: true checked: saveDirProps text: qsTr("Per dir props") onTriggered: saveDirProps = !saveDirProps }*/ + - Maui.MenuItem + MenuItem { icon.name: "image-preview" text: qsTr("Previews") checkable: true checked: list.preview onTriggered: { list.preview = !list.preview close() } } - Maui.MenuItem + MenuItem { icon.name: "visibility" text: qsTr("Hidden files") checkable: true checked: list.hidden onTriggered: { list.hidden = !list.hidden close() } } - Maui.MenuItem + MenuItem { icon.name: "bookmark-new" text: qsTr("Bookmark") checkable: true checked: modelList.isBookmark onTriggered: { modelList.isBookmark = !modelList.isBookmark newBookmark() close() } } MenuSeparator { } - Maui.MenuItem + MenuItem { icon.name: "folder-add" text: qsTr("New folder") onTriggered: { dialogLoader.sourceComponent= newFolderDialogComponent dialog.open() close() } } - Maui.MenuItem + MenuItem { icon.name: "document-new" text: qsTr("New file") onTriggered: { dialogLoader.sourceComponent= newFileDialogComponent dialog.open() close() } } MenuSeparator { visible : pasteItem.enabled} - Maui.MenuItem + MenuItem { id: pasteItem visible: enabled text: qsTr("Paste ")+"["+pasteFiles+"]" enabled: pasteFiles > 0 onTriggered: paste() } /* Maui.MenuItem { width: parent.width RowLayout { anchors.fill: parent Maui.ToolButton { Layout.fillHeight: true Layout.fillWidth: true iconName: "list-add" onClicked: zoomIn() } Maui.ToolButton { Layout.fillHeight: true Layout.fillWidth: true iconName: "list-remove" onClicked: zoomOut() } } }*/ function show() { if(currentPathType === FMList.PLACES_PATH || currentPathType === FMList.TAGS_PATH || currentPathType === FMList.CLOUD_PATH) { if(isCopy) pasteFiles = copyItems.length else if(isCut) pasteFiles = cutItems.length popup() } } } diff --git a/src/controls/private/FileMenu.qml b/src/controls/private/FileMenu.qml index 3ec5053..63eaaff 100644 --- a/src/controls/private/FileMenu.qml +++ b/src/controls/private/FileMenu.qml @@ -1,154 +1,155 @@ import QtQuick 2.9 import QtQuick.Controls 2.3 import QtQuick.Layouts 1.3 import org.kde.mauikit 1.0 as Maui import org.kde.kirigami 2.2 as Kirigami -Maui.Menu +Menu { id: control implicitWidth: colorBar.implicitWidth + space.big property var items : [] property bool isDir : false signal bookmarkClicked(var items) signal removeClicked(var items) signal shareClicked(var items) signal copyClicked(var items) signal cutClicked(var items) signal renameClicked(var items) signal tagsClicked(var items) - Maui.MenuItem + MenuItem { text: qsTr("Select") onTriggered: { addToSelection(list.get(browser.currentIndex)) } } MenuSeparator{} - Maui.MenuItem + MenuItem { text: qsTr("Copy...") onTriggered: { copyClicked(control.items) close() } } - Maui.MenuItem + MenuItem { text: qsTr("Cut...") onTriggered: { cutClicked(control.items) close() } } - Maui.MenuItem + MenuItem { text: qsTr("Rename...") onTriggered: { renameClicked(control.items) close() } } MenuSeparator{} - Maui.MenuItem + MenuItem { text: qsTr("Bookmark") enabled: isDir onTriggered: { bookmarkClicked(control.items) close() } } - Maui.MenuItem + MenuItem { text: qsTr("Tags...") onTriggered: { tagsClicked(control.items) close() } } - Maui.MenuItem + MenuItem { text: qsTr("Share...") onTriggered: { shareClicked(control.items) close() } } - Maui.MenuItem + MenuItem { text: qsTr("Preview...") onTriggered: { previewer.show(control.items[0].path) close() } } MenuSeparator{} - Maui.MenuItem + MenuItem { text: qsTr("Remove...") - colorScheme.textColor: dangerColor + Kirigami.Theme.textColor: dangerColor onTriggered: { removeClicked(control.items) close() } } MenuSeparator{} - Maui.MenuItem + MenuItem { width: parent.width + height: visible ? iconSize + space.big : 0 visible: isDir Maui.ColorsBar { anchors.centerIn: parent id: colorBar size: iconSize onColorPicked: { for(var i in control.items) Maui.FM.setDirConf(control.items[i].path+"/.directory", "Desktop Entry", "Icon", color) refresh() } } } function show(items) { if(items.length > 0 ) { if(items.length == 1) isDir = Maui.FM.isDir(items[0].path) control.items = items popup() } } }