diff --git a/src/controls/Dialog.qml b/src/controls/Dialog.qml index 60c5a60..1aac18d 100644 --- a/src/controls/Dialog.qml +++ b/src/controls/Dialog.qml @@ -1,207 +1,208 @@ /* * 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.3 import QtQuick.Layouts 1.3 import org.kde.mauikit 1.0 as Maui import org.kde.kirigami 2.6 as Kirigami Maui.Popup { id: control property string message : "" property string title: "" property string acceptText: "Ok" property string rejectText: "No" property bool defaultButtons: true property bool confirmationDialog: false property bool entryField: false default property alias content : page.contentData property alias acceptButton : _acceptButton property alias rejectButton : _rejectButton property alias textEntry : _textEntry property alias page : page property alias footBar : page.footBar property alias headBar: page.headBar property alias closeButton: _closeButton signal accepted() signal rejected() maxWidth: unit * 300 maxHeight: (_pageContent.implicitHeight * 1.2) + page.footBar.height + space.huge + page.padding widthHint: 0.9 heightHint: 0.9 z: 1 clip: false Maui.Badge { id: _closeButton iconName: "window-close" colorScheme.backgroundColor: hovered ? dangerColor : colorScheme.altColor anchors { verticalCenter: parent.top - horizontalCenter: parent.left + horizontalCenter: parent.left + horizontalCenterOffset: control.width === control.parent.width ? _closeButton.width : 0 } z: control.z+1 onClicked: { // rejected() close() } } Maui.Page { id: page // headBar.visible: headBar.count > 2 anchors.fill: parent padding: space.huge // footBar.dropShadow: false // footBar.drawBorder: false // margins: space.big clip: true // headBarExit: false // colorScheme.backgroundColor : control.colorScheme.backgroundColor // footBar.visible: defaultButtons || footBar.count > 1 // footBar.colorScheme.backgroundColor: colorScheme.backgroundColor // footBar.margins: space.big footBar.visible: control.defaultButtons || footBar.count > 1 property QtObject _rejectButton : Button { id: _rejectButton visible: defaultButtons Kirigami.Theme.textColor: dangerColor // Kirigami.Theme.borderColor: dangerColor Kirigami.Theme.backgroundColor: "transparent" text: rejectText onClicked: rejected() } property QtObject _acceptButton: Button { id: _acceptButton visible: defaultButtons Kirigami.Theme.backgroundColor: infoColor Kirigami.Theme.textColor: "white" text: acceptText onClicked: accepted() } Component { id: _defaultButtonsComponent Row { spacing: space.big children: [_rejectButton, _acceptButton] } } footBar.rightContent: Loader { sourceComponent: control.defaultButtons ? _defaultButtonsComponent : undefined } ColumnLayout { id: _pageContent anchors.fill: parent spacing: space.medium Label { width: parent.width height: visible ? implicitHeight : 0 visible: title.length > 0 Layout.fillWidth: visible Layout.alignment: Qt.AlignLeft | Qt.AlignTop clip: true color: colorScheme.textColor text: title font.weight: Font.Thin font.bold: true font.pointSize: fontSizes.huge elide: Qt.ElideRight wrapMode: Text.Wrap // elide: Qt.ElideRight } ScrollView { visible: message.length > 0 Layout.fillHeight: visible Layout.fillWidth: visible Layout.alignment: Qt.AlignLeft | Qt.AlignTop padding: 0 clip: true ScrollBar.horizontal.policy: ScrollBar.AlwaysOff contentHeight: body.implicitHeight Label { id: body width: _pageContent.width padding: 0 enabled: false text: message textFormat : TextEdit.AutoText color: colorScheme.textColor font.pointSize: fontSizes.default wrapMode: TextEdit.WrapAtWordBoundaryOrAnywhere elide: Text.ElideLeft // background: Rectangle // { // color: "transparent" // } } } Maui.TextField { id: _textEntry // anchors.fill: parent onAccepted: control.accepted() Layout.fillWidth: entryField height: entryField ? iconSizes.big : 0 visible: entryField clip: true } } } } diff --git a/src/controls/FileDialog.qml b/src/controls/FileDialog.qml index fbe35f8..a19a1af 100644 --- a/src/controls/FileDialog.qml +++ b/src/controls/FileDialog.qml @@ -1,297 +1,298 @@ /* * 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 org.kde.kirigami 2.6 as Kirigami import org.kde.mauikit 1.0 as Maui import QtQuick.Layouts 1.3 Maui.Dialog { id: control maxHeight: isMobile ? parent.height * 0.95 : unit * 500 maxWidth: unit * 700 defaultButtons: false + page.padding: 0 property string initPath property string suggestedFileName : "" property var filters: [] property int filterType: Maui.FMList.NONE property bool onlyDirs: false property int sortBy: Maui.FMList.MODIFIED property bool searchBar : false readonly property var modes : ({OPEN: 0, SAVE: 1}) property int mode : modes.OPEN property var callback : ({}) property alias textField: _textField Maui.Dialog { id: _confirmationDialog // anchors.centerIn: parent acceptButton.text: qsTr("Accept") rejectButton.text: qsTr("Cancel") title: qsTr(textField.text+" already exists!") message: qsTr("If you are sure you want to replace the existing file click on Accept, otherwise click on cancel and change the name of the file to something different...") onAccepted: control.done() onRejected: close() } Maui.Page { id: page anchors.fill: parent leftPadding: 0 rightPadding: leftPadding topPadding: leftPadding bottomPadding: leftPadding headBar.implicitHeight: toolBarHeight + space.medium Component { id: _pathBarComponent Maui.PathBar { anchors.fill: parent // colorScheme.backgroundColor: "#fff" // colorScheme.textColor: "#333" // colorScheme.borderColor: Qt.darker(headBarBGColor, 1.4) onPathChanged: browser.openFolder(path) url: browser.currentPath onHomeClicked: browser.openFolder(Maui.FM.homePath()) onPlaceClicked: browser.openFolder(path) } } Component { id: _searchFieldComponent Maui.TextField { anchors.fill: parent placeholderText: qsTr("Search for files... ") onAccepted: browser.openFolder("Search/"+text) // onCleared: browser.goBack() onGoBackTriggered: { searchBar = false clear() // browser.goBack() } background: Rectangle { border.color: borderColor radius: radiusV } } } headBar.middleContent: Item { id: _pathBarLoader Layout.fillWidth: true Layout.margins: space.medium height: iconSizes.big Loader { anchors.fill: parent sourceComponent: searchBar ? _searchFieldComponent : _pathBarComponent } } headBar.rightContent: ToolButton { id: searchButton icon.name: "edit-find" onClicked: searchBar = !searchBar checked: searchBar } Kirigami.PageRow { id: pageRow anchors.fill: parent clip: true property int sidebarWidth: Kirigami.Units.gridUnit * (isMobile? 15 : 8) separatorVisible: wideMode initialPage: [sidebar, content] defaultColumnWidth: sidebarWidth // interactive: currentIndex === 1 Maui.PlacesSidebar { id: sidebar onPlaceClicked: { pageRow.currentIndex = 1 browser.openFolder(path) } list.groups: control.mode === modes.OPEN ? [ Maui.FMList.PLACES_PATH, Maui.FMList.CLOUD_PATH, Maui.FMList.REMOTE_PATH, Maui.FMList.DRIVES_PATH, Maui.FMList.TAGS_PATH] : [Maui.FMList.PLACES_PATH, Maui.FMList.REMOTE_PATH, Maui.FMList.CLOUD_PATH, Maui.FMList.DRIVES_PATH] } ColumnLayout { id: content Maui.FileBrowser { id: browser Layout.fillWidth: true Layout.fillHeight: true previewer.parent: ApplicationWindow.overlay trackChanges: false selectionMode: control.mode === modes.OPEN list.onlyDirs: control.onlyDirs list.filters: control.filters list.sortBy: control.sortBy list.filterType: control.filterType onItemClicked: { switch(control.mode) { case modes.OPEN : { openItem(index) break } case modes.SAVE: { if(Maui.FM.isDir(list.get(index).path)) openItem(index) else textField.text = list.get(index).label break } } } onCurrentPathChanged: { for(var i=0; i < sidebar.count; i++) if(currentPath === sidebar.list.get(i).path) sidebar.currentIndex = i } } Maui.ToolBar { id: _bottomBar position: ToolBar.Footer drawBorder: true Layout.fillWidth: true middleContent: Maui.TextField { id: _textField visible: control.mode === modes.SAVE width: _bottomBar.middleLayout.width * 0.9 placeholderText: qsTr("File name") text: suggestedFileName } rightContent: Row { spacing: space.big Button { id: _acceptButton Kirigami.Theme.textColor: "white" Kirigami.Theme.backgroundColor: suggestedColor text: qsTr("Accept") onClicked: { console.log("CURRENT PATHb", browser.currentPath+"/"+textField.text) if(control.mode === modes.SAVE && Maui.FM.fileExists(browser.currentPath+"/"+textField.text)) { _confirmationDialog.open() }else { done() } } } } } } } } function show(cb) { callback = cb if(initPath) browser.openFolder(initPath) else browser.openFolder(browser.currentPath) open() } function closeIt() { browser.clearSelection() close() } function done() { var paths = browser.selectionBar && browser.selectionBar.visible ? browser.selectionBar.selectedPaths : browser.currentPath if(control.mode === modes.SAVE) { if (typeof paths == 'string') { paths = paths + "/" + textField.text }else { for(var i in paths) paths[i] = paths[i] + "/" + textField.text } } callback(paths) control.closeIt() } } diff --git a/src/controls/GlobalDrawer.qml b/src/controls/GlobalDrawer.qml index d678eac..8bd9dcb 100644 --- a/src/controls/GlobalDrawer.qml +++ b/src/controls/GlobalDrawer.qml @@ -1,155 +1,156 @@ /* * 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 org.kde.kirigami 2.2 as Kirigami import org.kde.mauikit 1.0 as Maui import QtGraphicalEffects 1.0 import "private" Kirigami.GlobalDrawer { id: control /* Controlc color scheming */ ColorScheme { id: colorScheme backgroundColor: viewBackgroundColor } property alias colorScheme : colorScheme /***************************/ property Item bg // property alias handleButton : _handleButton // z: ApplicationWindow.overlay.z handleVisible: false // y: altToolBars ? 0 : headBar.height // height: parent.height - (floatingBar && altToolBars ? 0 : headBar.height) // modal: true implicitHeight: root.height - root.headBar.height - root.footBar.height height: root.height - root.headBar.height - root.footBar.height y: root.headBar.height + topPadding: 0 bottomPadding: 0 leftPadding: 0 rightPadding: 0 onModalChanged: { if(!modal) visible = true } FastBlur { id: blur height: parent.height width: parent.width radius: 90 opacity: 0.5 source: ShaderEffectSource { sourceItem: bg sourceRect:Qt.rect(bg.width-(control.position * control.width), 0, control.width, control.height) } } // background: Rectangle // { // color: control.colorScheme.backgroundColor // // Item // { // parent: control.handle // anchors.fill: parent // anchors.margins: space.huge // // DropShadow // { // anchors.fill: handleGraphics // horizontalOffset: 0 // verticalOffset: Kitrigami.Units.devicePixelRatio // radius: Kitrigami.Units.gridUnit /2 // samples: 16 // color: Qt.rgba(0, 0, 0, control.handle.pressed ? 0.6 : 0.4) // source: handleGraphics // } // // Rectangle // { // id: handleGraphics // anchors.centerIn: parent // // color: control.handle.pressed ? control.colorScheme.highlightColor : control.colorScheme.accentColor // width: iconSizes.medium + space.medium * 2 // height: width // radius: radiusV // // Maui.ToolButton // { // id: _handleButton // anchors.centerIn: parent // size: iconSizes.medium // } // // Behavior on color // { // ColorAnimation { // duration: Kirigami.Units.longDuration // easing.type: Easing.InOutQuad // } // } // } // } // // // EdgeShadow // { // z: -2 // edge: control.edge // anchors // { // right: control.edge == Qt.RightEdge ? parent.left : (control.edge == Qt.LeftEdge ? undefined : parent.right) // left: control.edge == Qt.LeftEdge ? parent.right : (control.edge == Qt.RightEdge ? undefined : parent.left) // top: control.edge == Qt.TopEdge ? parent.bottom : (control.edge == Qt.BottomEdge ? undefined : parent.top) // bottom: control.edge == Qt.BottomEdge ? parent.top : (control.edge == Qt.TopEdge ? undefined : parent.bottom) // } // // opacity: control.position == 0 ? 0 : 1 // // Behavior on opacity { // NumberAnimation { // duration: Units.longDuration // easing.type: Easing.InOutQuad // } // } // } // } } diff --git a/src/controls/Page.qml b/src/controls/Page.qml index 16a396d..eb0608a 100644 --- a/src/controls/Page.qml +++ b/src/controls/Page.qml @@ -1,68 +1,70 @@ import QtQuick 2.4 import QtQuick.Controls 2.2 import org.kde.mauikit 1.0 as Maui import org.kde.kirigami 2.7 as Kirigami Page { id: control // property int margins: 0 // contentItem.anchors.margins: margins // contentItem.anchors.left: contentItem.parent.left // contentItem.anchors.top: contentItem.parent.top // contentItem.anchors.bottom: contentItem.parent.bottom // contentItem.anchors.right: contentItem.parent.right leftPadding: control.padding rightPadding: control.padding topPadding: control.padding bottomPadding: control.padding property alias headBar : _headBar property alias footBar: _footBar property QtObject mheadBar : Maui.ToolBar { id: _headBar visible: count > 1 position: ToolBar.Header Kirigami.Theme.backgroundColor: control.Kirigami.Theme.backgroundColor Component { id: _titleComponent Label - { + { + width: parent.width + height: parent.height text: control.title elide : Text.ElideRight font.bold : false font.weight: Font.Bold color : colorScheme.textColor font.pointSize: fontSizes.big horizontalAlignment : Text.AlignHCenter verticalAlignment : Text.AlignVCenter } } middleContent: Loader { sourceComponent: control.title ? _titleComponent : undefined } } property QtObject mfootBar : Maui.ToolBar { id: _footBar visible: count position: ToolBar.Footer Kirigami.Theme.backgroundColor: control.Kirigami.Theme.backgroundColor } header: headBar.position === ToolBar.Header ? headBar : undefined footer: Column { id: _footer children: headBar.position === ToolBar.Footer ? [footBar, headBar] : footBar } } diff --git a/src/controls/TextField.qml b/src/controls/TextField.qml index 38f0429..d7fa91f 100644 --- a/src/controls/TextField.qml +++ b/src/controls/TextField.qml @@ -1,154 +1,155 @@ /* * 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(); - height: implicitHeight - width: implicitWidth +// height: implicitHeight +// width: implicitWidth z: 1 // topPadding: space.tiny bottomPadding: space.tiny rightPadding: clearButton.width + space.small selectByMouse: !isMobile persistentSelection: true focus: true - wrapMode: TextInput.WordWrap + 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(); } ToolButton { id: clearButton visible: control.text.length anchors.top: control.top anchors.right: control.right anchors.rightMargin: space.small anchors.verticalCenter: parent.verticalCenter icon.name: "edit-clear" icon.color: color onClicked: { control.clear() cleared() } } Menu { id: entryMenu z: control.z +1 MenuItem { text: qsTr("Copy") onTriggered: control.copy() enabled: control.selectedText.length } MenuItem { text: qsTr("Cut") onTriggered: control.cut() enabled: control.selectedText.length } MenuItem { text: qsTr("Paste") onTriggered: { var text = control.paste() control.insert(control.cursorPosition, text) } } MenuItem { text: qsTr("Select all") onTriggered: control.selectAll() enabled: control.text.length } MenuItem { text: qsTr("Undo") onTriggered: control.undo() enabled: control.canUndo } MenuItem { text: qsTr("Redo") onTriggered: control.redo() enabled: control.canRedo } } }