diff --git a/src/controls/AboutDialog.qml b/src/controls/AboutDialog.qml index a601be1..7e498b0 100644 --- a/src/controls/AboutDialog.qml +++ b/src/controls/AboutDialog.qml @@ -1,237 +1,233 @@ /* * 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.Dialog { id: control property var app : ({}) property string appName : Qt.application.name property string appVersion : Qt.application.version property string organizationName : Qt.application.organization property string organizationDomain : Qt.application.domain property string appDescription : "" property string appLink: "www.maui-project.org" property string appDonation: "" property string appIcon: "qrc:/assets/mauikit-logo.png" defaultButtons: false - widthHint: 0.9 - heightHint: 0.8 - - maxWidth: unit * 400 - maxHeight: unit * 250 - - footBar.middleContent: ToolButton - { - icon.name: "view-links" - onClicked: Maui.FM.openUrl(control.appLink) - - } - - footBar.rightContent: ToolButton - { - icon.name: "love" - onClicked: Maui.FM.openUrl(control.appDonation) + widthHint: 0.9 + heightHint: 0.8 - } - - footBar.leftContent: ToolButton - { - icon.name: "documentinfo" - } - - RowLayout - { - id: layout - anchors.centerIn: parent - width: parent.width - height: parent.height * 0.7 + maxWidth: unit * 400 + maxHeight: unit * 250 - Item + footBar.middleContent: ToolButton { - Layout.fillHeight: true - Layout.margins: space.small - Layout.alignment: Qt.AlignHCenter | Qt.AlignTop - Layout.minimumWidth: iconSizes.huge - Layout.maximumWidth: iconSizes.huge - Layout.preferredWidth: iconSizes.huge - Layout.minimumHeight: iconSizes.huge + icon.name: "view-links" + onClicked: Maui.FM.openUrl(control.appLink) - clip: true - - Image - { - source: app.icon || control.appIcon - width: iconSizes.huge - height: width - sourceSize.width: width - sourceSize.height: height - horizontalAlignment: Qt.AlignHCenter - asynchronous: true - - fillMode: Image.PreserveAspectFit - } } + footBar.rightContent: ToolButton + { + icon.name: "love" + onClicked: Maui.FM.openUrl(control.appDonation) + + } - - - Item + footBar.leftContent: ToolButton { - id: _descriptionItem - Layout.fillWidth: true - Layout.fillHeight: true - Layout.alignment: Qt.AlignLeft | Qt.AlignTop - ScrollView + icon.name: "documentinfo" + } + + RowLayout { - anchors.fill: parent - - contentHeight: _columnInfo.implicitHeight + id: layout + anchors.centerIn: parent + width: parent.width + height: parent.height * 0.7 - padding: 0 - clip: true - - - ColumnLayout + Item { + Layout.fillHeight: true + Layout.margins: space.small + Layout.alignment: Qt.AlignHCenter | Qt.AlignTop + Layout.minimumWidth: iconSizes.huge + Layout.maximumWidth: iconSizes.huge + Layout.preferredWidth: iconSizes.huge + Layout.minimumHeight: iconSizes.huge - id: _columnInfo - width: parent.width - spacing: 0 - Label - { - id: appTitle - Layout.fillWidth: true -// Layout.preferredHeight: implicitHeight - - Layout.alignment: Qt.AlignLeft - clip: true - width: parent.width - height: parent.height - color: textColor - text: appName - font.weight: Font.Bold - font.bold: true - font.pointSize: fontSizes.huge - } + clip: true - Label + Image { - id: appVersion - Layout.fillWidth: true -// Layout.preferredHeight: fontSizes.default - - Layout.alignment: Qt.AlignLeft - clip: true - - width: parent.width - height: parent.height - color: Qt.lighter(textColor, 1.2) - text: app.version - font.pointSize: fontSizes.default + source: app.icon || control.appIcon + width: iconSizes.huge + height: width + sourceSize.width: width + sourceSize.height: height + horizontalAlignment: Qt.AlignHCenter + asynchronous: true + fillMode: Image.PreserveAspectFit } - - Label + } + + Item + { + id: _descriptionItem + Layout.fillWidth: true + Layout.fillHeight: true + Layout.alignment: Qt.AlignLeft | Qt.AlignTop + ScrollView { - id: body - // Layout.fillWidth: true -// Layout.fillHeight: true - Layout.preferredWidth:_descriptionItem.width + anchors.fill: parent - padding: 0 - // placeholderText: qsTr("App description") - enabled: false - text: appDescription - textFormat : TextEdit.AutoText - color: textColor - font.pointSize: fontSizes.default - wrapMode: TextEdit.WrapAtWordBoundaryOrAnywhere + contentHeight: _columnInfo.implicitHeight + padding: 0 clip: true - // background: Rectangle - // { - // color: "transparent" - // } + + ColumnLayout + { + + id: _columnInfo + width: parent.width + spacing: 0 + Label + { + id: appTitle + Layout.fillWidth: true + // Layout.preferredHeight: implicitHeight + + Layout.alignment: Qt.AlignLeft + clip: true + width: parent.width + height: parent.height + color: textColor + text: appName + font.weight: Font.Bold + font.bold: true + font.pointSize: fontSizes.huge + } + + Label + { + id: appVersion + Layout.fillWidth: true + // Layout.preferredHeight: fontSizes.default + + Layout.alignment: Qt.AlignLeft + clip: true + + width: parent.width + height: parent.height + color: Qt.lighter(textColor, 1.2) + text: app.version + font.pointSize: fontSizes.default + + } + + Label + { + id: body + // Layout.fillWidth: true + // Layout.fillHeight: true + Layout.preferredWidth:_descriptionItem.width + + padding: 0 + // placeholderText: qsTr("App description") + enabled: false + text: appDescription + textFormat : TextEdit.AutoText + color: textColor + font.pointSize: fontSizes.default + wrapMode: TextEdit.WrapAtWordBoundaryOrAnywhere + + clip: true + // background: Rectangle + // { + // color: "transparent" + // } + } + } + } + } + // Item + // { + // Layout.fillWidth: true + // Layout.row: 4 + // Layout.column: 2 + // Layout.margins: space.small + // Layout.alignment: Qt.AlignLeft | Qt.AlignTop + // Label + // { + // color: textColor + // width: parent.width + // height: parent.height + // + // text: qsTr("Built with MauiKit and Kirigami.") + // font.pointSize: fontSizes.default + // wrapMode: TextEdit.WrapAnywhere + // + // + // } + // } + + + + + // Item + // { + // Layout.fillWidth: true + // Layout.fillHeight: true + // Layout.row: 5 + // Layout.column: 2 + // Layout.margins: space.big + // Layout.alignment: Qt.AlignLeft | Qt.AlignTop + // + // Label + // { + // color: textColor + // width: parent.width + // height: parent.height + // + // text: "MauiKit " + app.mauikit + " Qt " +app.qt + // font.pointSize: fontSizes.default + // wrapMode: TextEdit.WrapAnywhere + // + // } + // } + } - } - - // Item - // { - // Layout.fillWidth: true - // Layout.row: 4 - // Layout.column: 2 - // Layout.margins: space.small - // Layout.alignment: Qt.AlignLeft | Qt.AlignTop - // Label - // { - // color: textColor - // width: parent.width - // height: parent.height - // - // text: qsTr("Built with MauiKit and Kirigami.") - // font.pointSize: fontSizes.default - // wrapMode: TextEdit.WrapAnywhere - // - // - // } - // } - - - - - // Item - // { - // Layout.fillWidth: true - // Layout.fillHeight: true - // Layout.row: 5 - // Layout.column: 2 - // Layout.margins: space.big - // Layout.alignment: Qt.AlignLeft | Qt.AlignTop - // - // Label - // { - // color: textColor - // width: parent.width - // height: parent.height - // - // text: "MauiKit " + app.mauikit + " Qt " +app.qt - // font.pointSize: fontSizes.default - // wrapMode: TextEdit.WrapAnywhere - // - // } - // } - - } - - onOpened : control.app = Maui.Handy.appInfo() + onOpened : control.app = Maui.Handy.appInfo() } diff --git a/src/controls/ActionBar.qml b/src/controls/ActionBar.qml deleted file mode 100644 index 07d4659..0000000 --- a/src/controls/ActionBar.qml +++ /dev/null @@ -1,3 +0,0 @@ -import org.kde.kirigami 2.6 as Kirigami - -Kirigami.ActionToolBar{} diff --git a/src/controls/ApplicationWindow.qml b/src/controls/ApplicationWindow.qml index 1e1226d..1de65f3 100644 --- a/src/controls/ApplicationWindow.qml +++ b/src/controls/ApplicationWindow.qml @@ -1,596 +1,573 @@ /* * 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.7 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 + default property alias content : page.contentData 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) + if(!isMobile && colorSchemeName.length > 0) Maui.KDE.setColorScheme(colorSchemeName, headBarBGColor, headBarFGColor) - else if(isAndroid && !altToolBars) + else if(isAndroid && headBar.position === ToolBar.Header) Maui.Android.statusbarColor(headBarBGColor, false) - else if(isAndroid && altToolBars) + else if(isAndroid && headBar.position === ToolBar.Footer) Maui.Android.statusbarColor(viewBackgroundColor, true) } onHeadBarFGColorChanged: { - if(!isAndroid && !isMobile && colorSchemeName.length > 0 && !altToolBars) + if(!isAndroid && !isMobile && colorSchemeName.length > 0 && headBar.position === ToolBar.Header) Maui.KDE.setColorScheme(colorSchemeName, headBarBGColor, headBarFGColor) - else if(isAndroid && !altToolBars) + else if(isAndroid && headBar.position === ToolBar.Header) Maui.Android.statusbarColor(headBarBGColor, false) - else if(isAndroid && altToolBars) + else if(isAndroid && headBar.position === ToolBar.Footer) 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 - } - -// Kirigami.Theme.backgroundColor: headBarBGColor + + anchors.fill: parent + contentItem.anchors.leftMargin: root.globalDrawer && (root.globalDrawer.modal === false) ? root.globalDrawer.contentItem.width * root.globalDrawer.position : 0 + contentItem.anchors.left: contentItem.parent.left + contentItem.anchors.right: contentItem.parent.right +// margins: 0 +// headBar.plegable: false +// headBar.height: toolBarHeight + space.small +// headBar.implicitHeight: toolBarHeight + space.small + +// Kirigami.Theme.backgroundColor: "red" // Kirigami.Theme.textColor: headBarFGColor - headBar.leftContent: ToolButton - { - id: menuBtn - icon.name: "application-menu" - icon.color: headBarFGColor - checked: mainMenu.visible - onClicked: - { - menuButtonClicked() - mainMenu.visible ? mainMenu.close() : mainMenu.popup(parent, parent.x , altToolBars ? 0 : parent.height+ space.medium) - } - - Menu - { - id: mainMenu - modal: true - z: 999 - width: unit * 200 + headBar.leftContent: ToolButton + { + id: menuBtn + icon.name: "application-menu" + icon.color: headBarFGColor + checked: mainMenu.visible + onClicked: + { + menuButtonClicked() + mainMenu.visible ? mainMenu.close() : mainMenu.popup(parent, parent.x , parent.height+ space.medium) + } - Item + Menu { - height: _accountCombobox.visible ? unit * 90 : 0 + id: mainMenu + modal: true + z: 999 + width: unit * 200 - anchors + Item { - left: parent.left - right: parent.right - top: parent.top - margins: space.medium + height: _accountCombobox.visible ? unit * 90 : 0 + + anchors + { + left: parent.left + right: parent.right + top: parent.top + margins: space.medium + } + + 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 + // icon.name: "user-identity" + // iconButton.isMask: false + } } - ComboBox + MenuSeparator { - 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 -// icon.name: "user-identity" -// iconButton.isMask: false + visible: _accountCombobox.visible } - } - - MenuSeparator - { - visible: _accountCombobox.visible - } - - MenuItem - { - text: qsTr("Accounts") - visible: root.showAccounts - icon.name: "list-add-user" - onTriggered: + + MenuItem + { + text: qsTr("Accounts") + visible: root.showAccounts + icon.name: "list-add-user" + onTriggered: + { + if(root.accounts) + accounts.open() + } + } + + MenuItem { - if(root.accounts) - accounts.open() + text: qsTr("About") + icon.name: "documentinfo" + onTriggered: aboutDialog.open() } - } - - MenuItem - { - text: qsTr("About") - icon.name: "documentinfo" - onTriggered: aboutDialog.open() } - - MenuSeparator {} - - } - } - - headBar.rightContent: ToolButton - { - id: searchBtn - icon.name: "edit-find" - icon.color: headBarFGColor - onClicked: searchButtonClicked() - } + } + + headBar.rightContent: ToolButton + { + id: searchBtn + icon.name: "edit-find" + icon.color: 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 ToolButton { id: _notifyIcon icon.width: 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) + if(isAndroid && headBar.position === ToolBar.Footer) 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.icon.name = 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/Button.qml b/src/controls/Button.qml deleted file mode 100644 index f5edc49..0000000 --- a/src/controls/Button.qml +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright 2018 Camilo Higuita - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library General Public License as - * published by the Free Software Foundation; either version 2, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -import QtQuick 2.0 -import QtQuick.Controls 2.2 -import QtQuick.Layouts 1.3 -import QtQuick.Controls.impl 2.3 -import org.kde.mauikit 1.0 as Maui -import org.kde.kirigami 2.6 as Kirigami -import QtGraphicalEffects 1.0 -import "private" - -Button -{ - id: control - - /* Controlc color scheming */ - ColorScheme {id: colorScheme} - property alias colorScheme : colorScheme - /***************************/ - - Kirigami.Theme.backgroundColor: colorScheme.backgroundColor - Kirigami.Theme.textColor: colorScheme.textColor - -// implicitWidth: Math.max(background ? background.implicitWidth : 0, -// contentItem.implicitWidth + leftPadding + rightPadding) -// implicitHeight: background.implicitHeight -// hoverEnabled: !isMobile - - leftPadding: space.small - rightPadding: leftPadding - -// property alias bg : _buttonBG -// -// contentItem: RowLayout -// { -// anchors.fill: control -// Kirigami.Icon -// { -// id: _icon -// visible: icon && icon.name.length > 0 -// // Layout.leftMargin: space.small -// Layout.fillHeight: visible -// Layout.preferredWidth: visible ? iconSizes.medium + space.medium : 0 -// Layout.alignment: Qt.AlignCenter -// source: icon.name -// width: iconSizes.medium * 0.9 -// height: width -// isMask: true -// color: _text.text.length ? _text.color : icon.color -// } -// -// Text -// { -// id: _text -// visible: text -// Layout.fillHeight: visible -// Layout.fillWidth: visible -// Layout.alignment: Qt.AlignCenter -// text: control.text -// font: control.font -// color: !control.enabled ? Qt.lighter(colorScheme.textColor, 1,2) : -// control.highlighted || control.down ? Qt.lighter(colorScheme.textColor, 1.4) : colorScheme.textColor -// horizontalAlignment: Text.AlignHCenter -// verticalAlignment: Text.AlignVCenter -// elide: Text.ElideRight -// } -// -// } -// -// background: Rectangle -// { -// id: _buttonBG -// implicitWidth: _icon.visible ? ( (control.text ? (iconSizes.medium * 3) : 0 ) + _icon.width + space.small) : iconSizes.medium * 3 -// implicitHeight: iconSizes.medium + space.small -// -// color: !control.enabled ? colorScheme.viewBackgroundColor : control.highlighted || control.down ? Qt.darker(colorScheme.backgroundColor, 1.4) : colorScheme.backgroundColor -// -// border.color: control.highlighted || control.down ? Qt.darker(colorScheme.borderColor, 1.4) : colorScheme.borderColor -// -// border.width: unit -// radius: radiusV -// -// } - -} diff --git a/src/controls/ComboBox.qml b/src/controls/ComboBox.qml deleted file mode 100644 index 4d1f676..0000000 --- a/src/controls/ComboBox.qml +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Copyright 2017 Marco Martin - * Copyright 2017 The Qt Company Ltd. - * - * GNU Lesser General Public License Usage - * Alternatively, this file may be used under the terms of the GNU Lesser - * General Public License version 3 as published by the Free Software - * Foundation and appearing in the file LICENSE.LGPLv3 included in the - * packaging of this file. Please review the following information to - * ensure the GNU Lesser General Public License version 3 requirements - * will be met: https://www.gnu.org/licenses/lgpl.html. - * - * GNU General Public License Usage - * Alternatively, this file may be used under the terms of the GNU - * General Public License version 2.0 or later as published by the Free - * Software Foundation and appearing in the file LICENSE.GPL included in - * the packaging of this file. Please review the following information to - * ensure the GNU General Public License version 2.0 requirements will be - * met: http://www.gnu.org/licenses/gpl-2.0.html. - */ - - -import QtQuick 2.6 -import QtQuick.Window 2.2 -import QtQuick.Controls 2.3 -import QtGraphicalEffects 1.0 -import org.kde.kirigami 2.2 as Kirigami -import org.kde.mauikit 1.0 as Maui -import "private" - -ComboBox -{ - id: control - - ColorScheme - { - id: colorScheme - } - property alias colorScheme : colorScheme - property alias iconButton : _iconButton - property alias indicatorButton : _indicatorButton - - - implicitWidth: Math.max(background ? background.implicitWidth : 0, - contentItem.implicitWidth + leftPadding + rightPadding) - implicitHeight: Math.max(background ? background.implicitHeight : 0, - Math.max(contentItem.implicitHeight, - indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding) - - baselineOffset: contentItem.y + contentItem.baselineOffset - - leftPadding: padding + (!control.mirrored || !indicator || !indicator.visible ? 0 : indicator.width + spacing) - rightPadding: padding + (control.mirrored || !indicator || !indicator.visible ? 0 : indicator.width + spacing) - - - - ToolButton - { - id: _iconButton - visible: iconName.length - icon.width: iconSizes.medium - enabled: false - icon.color: control.pressed || control.down ? control.colorScheme.highlightedTextColor : control.colorScheme.textColor - anchors.left: control.left - anchors.verticalCenter: control.verticalCenter - anchors.margins: space.small - } - - indicator: ToolButton - { - id: _indicatorButton - icon.width: iconSizes.small - enabled: false - icon.name: _popup.visible ? "go-up" : "go-down" - icon.color: control.pressed || control.down ? control.colorScheme.highlightedTextColor : control.colorScheme.textColor - anchors.right: control.right - anchors.verticalCenter: control.verticalCenter - anchors.margins: space.small - } - - delegate: Maui.ListDelegate - { - label: control.textRole ? (Array.isArray(control.model) ? modelData[control.textRole] : model[control.textRole]) : modelData -// highlighted: control.highlightedIndex == index - } - - contentItem: Text - { - leftPadding: iconButton.width + space.small - rightPadding: control.indicator.width + control.spacing - - text: control.displayText - font: control.font - color: control.pressed || control.down ? control.colorScheme.highlightedTextColor : control.colorScheme.textColor - verticalAlignment: TextInput.AlignVCenter - horizontalAlignment: Text.AlignHCenter - elide: Text.ElideRight - } - - background: Rectangle - { - implicitWidth: iconSizes.medium * 2 - implicitHeight: iconSizes.medium + space.small - color: control.pressed || control.down ? control.colorScheme.highlightColor : control.colorScheme.viewBackgroundColor - border.color: control.pressed ? control.colorScheme.highlightColor : control.colorScheme.borderColor - border.width: control.visualFocus ? 2 : 1 - radius: radiusV - } - - - popup: Popup - { - id: _popup - y: control.height + space.small - width: control.width -// implicitWidth: 100 * unit - implicitHeight: contentItem.implicitHeight + space.small - padding: unit * 2 - z: control.parent.z + 1 - - contentItem: ListView - { - clip: true - implicitHeight: contentHeight - model: control.popup.visible ? control.delegateModel : null - currentIndex: control.highlightedIndex - - ScrollIndicator.vertical: ScrollIndicator { } - } - - background: Rectangle - { - radius: radiusV - color: control.colorScheme.backgroundColor - border.color: control.colorScheme.borderColor - } - } -} diff --git a/src/controls/Dialog.qml b/src/controls/Dialog.qml index 2b162d7..1aac18d 100644 --- a/src/controls/Dialog.qml +++ b/src/controls/Dialog.qml @@ -1,197 +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.content + 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 headBarTitle: page.headBarTitle property alias closeButton: _closeButton signal accepted() signal rejected() maxWidth: unit * 300 - maxHeight: _pageContent.implicitHeight + page.footBar.height + page.margins + space.huge + 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 +// headBar.visible: headBar.count > 2 anchors.fill: parent - footBar.dropShadow: false - footBar.drawBorder: false - margins: space.big + 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.rightContent: Row - { - spacing: space.big - Button - { - id: _rejectButton - visible: defaultButtons - Kirigami.Theme.textColor: dangerColor -// Kirigami.Theme.borderColor: dangerColor - Kirigami.Theme.backgroundColor: "transparent" - - text: rejectText - onClicked: rejected() - - } +// 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" - Button - { - id: _acceptButton - visible: defaultButtons - Kirigami.Theme.backgroundColor: infoColor - Kirigami.Theme.textColor: "white" - text: acceptText - onClicked: accepted() - - } - } + 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 - - TextArea +contentHeight: body.implicitHeight + Label { id: body - padding: 0 - - width: parent.width - height: parent.height + 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/Drawer.qml b/src/controls/Drawer.qml deleted file mode 100644 index fbc2af1..0000000 --- a/src/controls/Drawer.qml +++ /dev/null @@ -1,76 +0,0 @@ -/* - * 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.0 as Kirigami -import org.kde.mauikit 1.0 as Maui -import QtGraphicalEffects 1.0 - -Drawer -{ - id: control - - property Item bg - - width: isMobile ? parent.width * 0.9 : Kirigami.Units.gridUnit * 17 - y: altToolBars ? 0 : root.headBar.height - height: parent.height - (((floatingBar || root.floatingBar) && !altToolBars) ? root.headBar.height : - headBar.height + footBar.height) - clip: true - - FastBlur - { - id: blur - height: parent.height - width: parent.width - radius: 90 - opacity: 0.25 - source: ShaderEffectSource - { - sourceItem: bg - sourceRect: control.edge === Qt.LeftEdge ? Qt.rect(0, - 0, - control.position * control.width, - control.height) : Qt.rect(bg.width-(control.position * control.width), - 0, - control.position * control.width, - control.height) - } - } - - background: Rectangle - { - color: backgroundColor - Kirigami.Separator - { - readonly property bool horizontal: control.edge === Qt.LeftEdge || control.edge === Qt.RightEdge - anchors - { - left: control.edge !== Qt.LeftEdge ? parent.left : undefined - right: control.edge !== Qt.RightEdge ? parent.right : undefined - top: control.edge !== Qt.TopEdge ? parent.top : undefined - bottom: control.edge !== Qt.BottomEdge ? parent.bottom : undefined - } - } - } - - -} diff --git a/src/controls/Editor.qml b/src/controls/Editor.qml index b1d1e99..eccc502 100644 --- a/src/controls/Editor.qml +++ b/src/controls/Editor.qml @@ -1,216 +1,214 @@ import QtQuick 2.9 import QtQuick.Controls 2.2 import QtQuick.Layouts 1.3 import org.kde.mauikit 1.0 as Maui import DocumentHandler 1.0 import "private" Maui.Page { id: control property bool showLineCount : true property alias body : body property alias document : document property alias scrollView: _scrollView property alias text: body.text property alias uppercase: document.uppercase property alias underline: document.underline property alias italic: document.italic property alias bold: document.bold property alias canRedo: body.canRedo - headBarExit: false headBar.visible: !body.readOnly - headBar.leftContent: [ ToolButton { icon.name: "edit-undo" enabled: body.canUndo onClicked: body.undo() opacity: enabled ? 1 : 0.5 }, ToolButton { icon.name: "edit-redo" enabled: body.canRedo onClicked: body.redo() opacity: enabled ? 1 : 0.5 }, ToolButton { icon.name: "format-text-bold" focusPolicy: Qt.TabFocus icon.color: checked ? highlightColor : textColor checkable: false checked: document.bold onClicked: document.bold = !document.bold }, ToolButton { icon.name: "format-text-italic" icon.color: checked ? highlightColor : textColor focusPolicy: Qt.TabFocus checkable: false checked: document.italic onClicked: document.italic = !document.italic }, ToolButton { icon.name: "format-text-underline" icon.color: checked ? highlightColor : textColor focusPolicy: Qt.TabFocus checkable: true checked: document.underline onClicked: document.underline = !document.underline }, ToolButton { icon.name: "format-text-uppercase" icon.color: checked ? highlightColor : textColor focusPolicy: Qt.TabFocus checkable: true checked: document.uppercase onClicked: document.uppercase = !document.uppercase } ] DocumentHandler { id: document document: body.textDocument cursorPosition: body.cursorPosition selectionStart: body.selectionStart selectionEnd: body.selectionEnd // textColor: TODO // onLoaded: { // body.text = text // } onError: { body.text = message body.visible = true } onLoaded: { body.text = text } } ScrollView { id: _scrollView anchors.fill: parent TextArea { id: body width: parent.width height: parent.height placeholderText: qsTr("Body") selectByKeyboard :!isMobile selectByMouse : !isMobile textFormat : TextEdit.AutoText color: control.colorScheme.textColor font.pointSize: fontSizes.large wrapMode: TextEdit.WrapAnywhere activeFocusOnPress: true activeFocusOnTab: true persistentSelection: true // background: Rectangle // { // color: "transparent" // } // onPressAndHold: isMobile ? documentMenu.popup() : undefined onPressed: { if(!isMobile && event.button === Qt.RightButton) documentMenu.popup() } Row { visible: showLineCount anchors { right: parent.right bottom: parent.bottom } width: implicitWidth height: implicitHeight Label { text: body.length + " / " + body.lineCount color: textColor opacity: 0.5 font.pointSize: fontSizes.medium } } Menu { id: documentMenu z: 999 MenuItem { text: qsTr("Copy") onTriggered: body.copy() enabled: body.selectedText.length } MenuItem { text: qsTr("Cut") onTriggered: body.cut() enabled: !body.readOnly && body.selectedText.length } MenuItem { text: qsTr("Paste") onTriggered: body.paste() enabled: !body.readOnly } MenuItem { text: qsTr("Select all") onTriggered: body.selectAll() } MenuItem { text: qsTr("Web search") onTriggered: Maui.FM.openUrl("https://www.google.com/search?q="+body.selectedText) enabled: body.selectedText.length } } } } } diff --git a/src/controls/FileBrowser.qml b/src/controls/FileBrowser.qml index 5b3e62e..a8b432e 100644 --- a/src/controls/FileBrowser.qml +++ b/src/controls/FileBrowser.qml @@ -1,1050 +1,1049 @@ import QtQuick 2.9 -import QtQuick.Controls 2.2 +import QtQuick.Controls 2.3 import QtQuick.Layouts 1.3 import org.kde.kirigami 2.7 as Kirigami import org.kde.mauikit 1.0 as Maui import "private" Maui.Page { id: control /* Controlc color scheming */ ColorScheme {id: colorScheme} property alias colorScheme : colorScheme /***************************/ property alias trackChanges: modelList.trackChanges property alias saveDirProps: modelList.saveDirProps property string currentPath: Maui.FM.homePath() property var copyItems : [] property var cutItems : [] property var indexHistory : [] property bool isCopy : false property bool isCut : false property bool selectionMode : false property bool group : false property bool showEmblems: true property alias selectionBar : selectionBarLoader.item property alias model : folderModel property alias list : modelList property alias browser : viewLoader.item property var currentFMList : modelList property alias previewer : previewer property alias menu : browserMenu.actions property alias itemMenu: itemMenu property alias holder: holder property alias dialog : dialogLoader.item property alias goUpButton : goUpButton property alias currentPathType : modelList.pathType property int thumbnailsSize : iconSizes.large signal itemClicked(int index) signal itemDoubleClicked(int index) signal itemRightClicked(int index) signal itemLeftEmblemClicked(int index) signal itemRightEmblemClicked(int index) signal rightClicked() signal newBookmark(var paths) - margins: 0 focus: true + Kirigami.Theme.backgroundColor: Kirigami.Theme.viewBackgroundColor Loader { id: dialogLoader } Component { id: removeDialogComponent Maui.Dialog { property var items: [] - + title: qsTr("Delete files?") message: qsTr("If you are sure you want to delete the files click on Accept, otherwise click on Cancel") rejectButton.text: qsTr("Cancel") acceptButton.text: qsTr("Accept") onRejected: close() onAccepted: { if(control.selectionBar && control.selectionBar.visible) { control.selectionBar.clear() control.selectionBar.animate("red") } control.remove(items) close() } } } Component { id: newFolderDialogComponent Maui.NewDialog { title: qsTr("New folder") message: qsTr("Create a new folder with a custom name") acceptButton.text: qsTr("Create") onFinished: list.createDir(text) rejectButton.visible: false } } Component { id: newFileDialogComponent Maui.NewDialog { title: qsTr("New file") message: qsTr("Create a new file with a custom name and extension") acceptButton.text: qsTr("Create") onFinished: Maui.FM.createFile(control.currentPath, text) rejectButton.visible: false } } Component { id: renameDialogComponent Maui.NewDialog { title: qsTr("Rename file") message: qsTr("Rename a file or folder to a new custom name") textEntry.text: list.get(browser.currentIndex).label textEntry.placeholderText: qsTr("New name...") onFinished: Maui.FM.rename(itemMenu.items[0].path, textEntry.text) onRejected: close() acceptText: qsTr("Rename") rejectText: qsTr("Cancel") } } Component { id: shareDialogComponent Maui.ShareDialog {} } Component { id: tagsDialogComponent Maui.TagsDialog { onTagsReady: composerList.updateToUrls(tags) } } BrowserMenu { id: browserMenu // width: unit *200 z : control.z +1 } Maui.FilePreviewer { id: previewer parent: parent onShareButtonClicked: control.shareFiles([url]) } Maui.BaseModel { id: folderModel list: modelList } Maui.FMList { id: modelList preview: true path: currentPath foldersFirst: true onSortByChanged: if(group) groupBy() onContentReadyChanged: console.log("CONTENT READY?", contentReady) onWarning: { notify("dialog-information", "An error happened", message) } onProgress: { if(percent === 100) _progressBar.value = 0 else _progressBar.value = percent/100 } } FileMenu { id: itemMenu width: unit *200 onBookmarkClicked: control.newBookmark([items[0].path]) onCopyClicked: { if(items.length) control.copy(items) } onCutClicked: { if(items.length) control.cut(items) } onTagsClicked: { if(items.length) { dialogLoader.sourceComponent = tagsDialogComponent if(items.length > 1 && control.selectionBar) dialog.composerList.urls = control.selectionBar.selectedPaths else dialog.composerList.urls = items[0].path dialog.open() } } onRenameClicked: { if(items.length === 1) { dialogLoader.sourceComponent = renameDialogComponent dialog.open() } } // onSaveToClicked: // { // fmDialog.saveDialog = false // fmDialog.multipleSelection = true // fmDialog.onlyDirs= true // var myPath = path // var paths = browser.selectionBar.selectedPaths // fmDialog.show(function(paths) // { // inx.copy(myPath, paths) // }) // } onRemoveClicked: { dialogLoader.sourceComponent= removeDialogComponent dialog.items = items dialog.open() } onShareClicked: { if(items.length) control.shareFiles([items[0].path]) } } Component { id: listViewBrowser Maui.ListBrowser { showPreviewThumbnails: modelList.preview showEmblem: selectionMode rightEmblem: isMobile ? "document-share" : "" leftEmblem: "list-add" showDetailsInfo: true // itemSize: thumbnailsSize model: folderModel section.delegate: Maui.LabelDelegate { id: delegate label: section labelTxt.font.pointSize: fontSizes.big isSection: true boldLabel: true height: toolBarHeightAlt } } } Component { id: gridViewBrowser Maui.GridBrowser { itemSize : thumbnailsSize + fontSizes.default showEmblem: selectionMode showPreviewThumbnails: modelList.preview rightEmblem: isMobile ? "document-share" : "" leftEmblem: "list-add" model: folderModel } } Component { id: millerViewBrowser Kirigami.ColumnView { id: _millerColumns // columnWidth: Kirigami.Units.gridUnit * 22 // fillWidth: true columnResizeMode: Kirigami.ColumnView.DynamicColumns signal itemClicked(int index) signal itemDoubleClicked(int index) signal itemRightClicked(int index) signal rightEmblemClicked(int index) signal leftEmblemClicked(int index) Maui.PathList { id: _millerList path: control.currentPath } Maui.BaseModel { id: _millerModel list: _millerList } Repeater { id: _repeater model: _millerModel onItemAdded: { // if(viewLoader.sourceComponent === millerViewBrowser) // _millerColumns.currentIndex = _millerColumns.count-1 } Item { Maui.FMList { id: _millersFMList preview: modelList.preview path: model.path foldersFirst: modelList.foldersFirst onWarning: { notify("dialog-information", "An error happened", message) } onProgress: { if(percent === 100) _progressBar.value = 0 else _progressBar.value = percent/100 } } Maui.ListBrowser { id: _millerListView anchors.fill: parent showPreviewThumbnails: modelList.preview showEmblem: selectionMode rightEmblem: isMobile ? "document-share" : "" leftEmblem: "list-add" showDetailsInfo: true // itemSize: thumbnailsSize onItemClicked: { control.currentFMList = _millersFMList _millerColumns.itemClicked(index) } // onItemDoubleClicked: // { // modelList.path = _millersFMList.path // _millerColumns.onItemDoubleClicked(index) // } onItemRightClicked: _millerColumns.itemRightClicked(index) onRightEmblemClicked: _millerColumns.rightEmblemClicked(index) onLeftEmblemClicked: _millerColumns.leftEmblemClicked(index) model: Maui.BaseModel { list: _millersFMList } section.delegate: Maui.LabelDelegate { id: delegate label: section labelTxt.font.pointSize: fontSizes.big isSection: true boldLabel: true height: toolBarHeightAlt } } } } } } Connections { target: browser onItemClicked: { browser.currentIndex = index indexHistory.push(index) control.itemClicked(index) } onItemDoubleClicked: { browser.currentIndex = index indexHistory.push(index) control.itemDoubleClicked(index) } onItemRightClicked: { itemMenu.show([modelList.get(index)]) control.itemRightClicked(index) } onLeftEmblemClicked: { control.addToSelection(modelList.get(index), true) control.itemLeftEmblemClicked(index) } onRightEmblemClicked: { isAndroid ? Maui.Android.shareDialog([modelList.get(index).path]) : shareDialog.show([modelList.get(index).path]) control.itemRightEmblemClicked(index) } onAreaClicked: { if(!isMobile && mouse.button === Qt.RightButton) browserMenu.show() else return control.rightClicked() } onAreaRightClicked: browserMenu.show() } Maui.Holder { id: holder anchors.fill : parent z: -1 visible: !modelList.pathExists || modelList.pathEmpty || !modelList.contentReady emoji: if(modelList.pathExists && modelList.pathEmpty) "qrc:/assets/MoonSki.png" else if(!modelList.pathExists) "qrc:/assets/ElectricPlug.png" else if(!modelList.contentReady && currentPathType === Maui.FMList.SEARCH_PATH) "qrc:/assets/animat-search-color.gif" else if(!modelList.contentReady) "qrc:/assets/animat-rocket-color.gif" isGif: !modelList.contentReady isMask: false title : if(modelList.pathExists && modelList.pathEmpty) qsTr("Folder is empty!") else if(!modelList.pathExists) qsTr("Folder doesn't exists!") else if(!modelList.contentReady && currentPathType === Maui.FMList.SEARCH_PATH) qsTr("Searching for content!") else if(!modelList.contentReady) qsTr("Loading content!") body: if(modelList.pathExists && modelList.pathEmpty) qsTr("You can add new files to it") else if(!modelList.pathExists) qsTr("Create Folder?") else if(!modelList.contentReady && currentPathType === Maui.FMList.SEARCH_PATH) qsTr("This might take a while!") else if(!modelList.contentReady) qsTr("Almost ready!") emojiSize: iconSizes.huge onActionTriggered: { if(!modelList.pathExists) { Maui.FM.createDir(control.currentPath.slice(0, control.currentPath.lastIndexOf("/")), control.currentPath.split("/").pop()) control.openFolder(modelList.parentPath) } } } Keys.onSpacePressed: previewer.show(modelList.get(browser.currentIndex).path) - - headBarExit: false headBar.visible: currentPathType !== Maui.FMList.APPS_PATH - altToolBars: isMobile + headBar.position: isMobile ? ToolBar.Footer : ToolBar.Header + +// headBar.stickyRightContent: true headBar.rightContent:[ ToolButton { icon.name: "view-list-icons" onClicked: list.viewType = Maui.FMList.ICON_VIEW checkable: false checked: list.viewType === Maui.FMList.ICON_VIEW icon.width: iconSizes.medium autoExclusive: true }, ToolButton { icon.name: "view-list-details" onClicked: list.viewType = Maui.FMList.LIST_VIEW icon.width: iconSizes.medium checked: list.viewType === Maui.FMList.LIST_VIEW autoExclusive: true }, ToolButton { icon.name: "view-file-columns" onClicked: list.viewType = Maui.FMList.MILLERS_VIEW icon.width: iconSizes.medium checked: list.viewType === Maui.FMList.MILLERS_VIEW autoExclusive: true }, Kirigami.ActionToolBar { position: Controls.ToolBar.Header Layout.fillWidth: false z: 999 - hiddenActions: browserMenu.actions + + hiddenActions: browserMenu.actions + // display: isMobile ? ToolButton.IconOnly : ToolButton.TextBesideIcon actions: [ Kirigami.Action { icon.name: "view-sort" text: qsTr("Sort") Kirigami.Action { text: qsTr("Folders first") checked: list.foldersFirst onTriggered: list.foldersFirst = !list.foldersFirst } Kirigami.Action { text: qsTr("Type") checked: list.sortBy === Maui.FMList.MIME onTriggered: list.sortBy = Maui.FMList.MIME } Kirigami.Action { text: qsTr("Date") checked: list.sortBy === Maui.FMList.DATE onTriggered: list.sortBy = Maui.FMList.DATE } Kirigami.Action { text: qsTr("Modified") checked: list.sortBy === Maui.FMList.MODIFIED onTriggered: list.sortBy = Maui.FMList.MODIFIED } Kirigami.Action { text: qsTr("Size") checked: list.sortBy === Maui.FMList.SIZE onTriggered: list.sortBy = Maui.FMList.SIZE } Kirigami.Action { text: qsTr("Name") checked: list.sortBy === Maui.FMList.LABEL onTriggered: list.sortBy = Maui.FMList.LABEL } Kirigami.Action { id: groupAction text: qsTr("Group") checked: group onTriggered: { group = !group if(group) groupBy() else browser.section.property = "" } - } - + } }, Kirigami.Action { text: qsTr("Select") icon.name: "item-select" checkable: false checked: selectionMode onTriggered: selectionMode = !selectionMode } ] } ] headBar.leftContent: [ ToolButton { icon.name: "go-previous" onClicked: control.goBack() }, ToolButton { id: goUpButton visible: true icon.name: "go-up" onClicked: control.goUp() }, ToolButton { icon.name: "go-next" onClicked: control.goNext() } ] footBar.visible: false Component { id: selectionBarComponent Maui.SelectionBar { anchors.fill: parent onIconClicked: _selectionBarmenu.popup() onExitClicked: clearSelection() Menu { id: _selectionBarmenu MenuItem { text: qsTr("Copy...") onTriggered: { if(control.selectionBar) control.selectionBar.animate("#6fff80") control.copy(selectedItems) console.log(selectedItems) _selectionBarmenu.close() } } MenuItem { text: qsTr("Cut...") onTriggered: { if(control.selectionBar) control.selectionBar.animate("#fff44f") control.cut(selectedItems) _selectionBarmenu.close() } } MenuItem { text: qsTr("Share") onTriggered: { control.shareFiles(selectedPaths) _selectionBarmenu.close() } } MenuSeparator{} MenuItem { text: qsTr("Remove...") Kirigami.Theme.textColor: dangerColor onTriggered: { dialogLoader.sourceComponent= removeDialogComponent dialog.items = selectedItems dialog.open() _selectionBarmenu.close() } } } } } ColumnLayout { anchors.fill: parent visible: !holder.visible z: holder.z + 1 spacing: 0 Loader { id: viewLoader z: holder.z + 1 sourceComponent: switch(list.viewType) { case Maui.FMList.ICON_VIEW: return gridViewBrowser case Maui.FMList.LIST_VIEW: return listViewBrowser case Maui.FMList.MILLERS_VIEW: return millerViewBrowser } onLoaded: { if(sourceComponent !== millerViewBrowser) control.currentFMList = modelList } Layout.topMargin: list.viewType == Maui.FMList.ICON_VIEW ? contentMargins * 2 : unit Layout.margins: 0 Layout.fillWidth: true Layout.fillHeight: true } Loader { id: selectionBarLoader Layout.fillWidth: true Layout.preferredHeight: control.selectionBar && control.selectionBar.visible ? control.selectionBar.barHeight: 0 Layout.leftMargin: contentMargins * (isMobile ? 3 : 2) Layout.rightMargin: contentMargins * (isMobile ? 3 : 2) Layout.bottomMargin: control.selectionBar && control.selectionBar.visible ? contentMargins*2 : 0 z: holder.z +1 } - ProgressBar { id: _progressBar Layout.fillWidth: true Layout.alignment: Qt.AlignBottom Layout.preferredHeight: visible ? iconSizes.medium : 0 visible: value > 0 - } - + } } // PinchArea // { // anchors.fill: parent // // property real initialWidth // property real initialHeight // // onPinchStarted: // { // console.log("pinch started") // } // // onPinchUpdated: // { // console.log(pinch.scale) // } // // onPinchFinished: // { // console.log("pinch finished") // } // } onThumbnailsSizeChanged: { if(trackChanges && saveDirProps) Maui.FM.setDirConf(currentPath+"/.directory", "MAUIFM", "IconSize", thumbnailsSize) else Maui.FM.saveSettings("IconSize", thumbnailsSize, "SETTINGS") if(list.viewType == Maui.FMList.ICON_VIEW) browser.adaptGrid() } function shareFiles(urls) { if(urls.length <= 0) return; if(isAndroid) Maui.Android.shareDialog(urls[0]) else { dialogLoader.sourceComponent= shareDialogComponent dialog.show(urls) } } function openItem(index) { var item = control.currentFMList.get(index) var path = item.path switch(currentPathType) { case Maui.FMList.APPS_PATH: if(item.path.endsWith("/")) populate(path) else Maui.FM.runApplication(path) break case Maui.FMList.CLOUD_PATH: if(item.mime === "inode/directory") control.openFolder(path) else Maui.FM.openCloudItem(item) break; default: if(selectionMode && !Maui.FM.isDir(item.path)) addToSelection(item, true) else { if(Maui.FM.isDir(path)) control.openFolder(path) else if(Maui.FM.isApp(path)) control.launchApp(path) else { if (isMobile) previewer.show(path) else control.openFile(path) } } } } function launchApp(path) { Maui.FM.runApplication(path, "") } function openFile(path) { Maui.FM.openUrl(path) } function openFolder(path) { populate(path) } function setPath(path) { currentPath = path } function populate(path) { if(!path.length) return; browser.currentIndex = 0 setPath(path) if(currentPathType === Maui.FMList.PLACES_PATH) { if(trackChanges && saveDirProps) { var conf = Maui.FM.dirConf(path+"/.directory") var iconsize = conf["iconsize"] || iconSizes.large thumbnailsSize = parseInt(iconsize) }else { thumbnailsSize = parseInt(Maui.FM.loadSettings("IconSize", "SETTINGS", thumbnailsSize)) } } if(list.viewType == Maui.FMList.ICON_VIEW) browser.adaptGrid() } function goBack() { populate(modelList.previousPath) browser.currentIndex = indexHistory.pop() // browser.positionViewAtIndex(browser.currentIndex, ListView.Center) } function goNext() { openFolder(modelList.posteriorPath) } function goUp() { openFolder(modelList.parentPath) } function refresh() { var pos = browser.contentY modelList.refresh() browser.contentY = pos } function addToSelection(item, append) { selectionBarLoader.sourceComponent= selectionBarComponent selectionBar.append(item) } function clearSelection() { clean() // selectionMode = false } function clean() { copyItems = [] cutItems = [] browserMenu.pasteFiles = 0 if(control.selectionBar && control.selectionBar.visible) selectionBar.clear() } function copy(items) { copyItems = items isCut = false isCopy = true } function cut(items) { cutItems = items isCut = true isCopy = false } function paste() { if(isCopy) list.copyInto(copyItems, currentPath) else if(isCut) { list.cutInto(cutItems, currentPath) clearSelection() } } function remove(items) { for(var i in items) Maui.FM.removeFile(items[i].path) } function bookmarkFolder(paths) { newBookmark(paths) } function zoomIn() { control.thumbnailsSize = control.thumbnailsSize + 8 } function zoomOut() { var newSize = control.thumbnailsSize - 8 if(newSize >= iconSizes.small) control.thumbnailsSize = newSize } function groupBy() { var prop = "" var criteria = ViewSection.FullString switch(modelList.sortBy) { case Maui.FMList.LABEL: prop = "label" criteria = ViewSection.FirstCharacter break; case Maui.FMList.MIME: prop = "mime" break; case Maui.FMList.SIZE: prop = "size" break; case Maui.FMList.DATE: prop = "date" break; case Maui.FMList.MODIFIED: prop = "modified" break; } list.viewType = Maui.FMList.LIST_VIEW if(!prop) { browser.section.property = "" return } browser.section.property = prop browser.section.criteria = criteria } } diff --git a/src/controls/FileDialog.qml b/src/controls/FileDialog.qml index d772862..a19a1af 100644 --- a/src/controls/FileDialog.qml +++ b/src/controls/FileDialog.qml @@ -1,303 +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 - page.margins: 0 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 - margins: 0 rightPadding: leftPadding topPadding: leftPadding bottomPadding: leftPadding - headBarExit: false - headBar.plegable: false - headBarTitleVisible: false 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 - altToolBars: false 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/GridView.qml b/src/controls/GridView.qml index 122682a..0b1d6be 100644 --- a/src/controls/GridView.qml +++ b/src/controls/GridView.qml @@ -1,160 +1,160 @@ /* * Copyright 2018 Camilo Higuita * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import QtQuick 2.0 import QtQuick.Controls 2.2 import QtQuick.Layouts 1.3 import QtQuick.Controls.impl 2.3 import org.kde.mauikit 1.0 as Maui import org.kde.kirigami 2.2 as Kirigami import QtGraphicalEffects 1.0 ScrollView { id: control property int cellWidth: unit * 200 property int cellHeight: unit * 200 spacing: space.medium property int itemSize: 0 property alias model : gridView.model property alias delegate : gridView.delegate property alias contentY: gridView.contentY property alias currentIndex : gridView.currentIndex property alias count : gridView.count property alias cacheBuffer : gridView.cacheBuffer property alias topMargin: gridView.topMargin property alias bottomMargin: gridView.bottomMargin property alias rightMargin: gridView.rightMargin property alias leftMarging: gridView.leftMargin property alias header : gridView.header property bool centerContent: false property bool adaptContent: false signal areaClicked(var mouse) signal areaRightClicked() GridView { id: gridView anchors { leftMargin: control.ScrollBar.visible ? 0 : control.ScrollBar.width } flow: GridView.FlowLeftToRight clip: true focus: true anchors.horizontalCenter: centerContent ? parent.horizontalCenter : undefined width: centerContent ? Math.min(model.count, Math.floor(parent.width/cellWidth))*cellWidth : parent.width height: parent.height cellWidth: control.cellWidth cellHeight: control.cellHeight // maximumFlickVelocity: albumSize*8 boundsBehavior: !isMobile? Flickable.StopAtBounds : Flickable.OvershootBounds flickableDirection: Flickable.AutoFlickDirection snapMode: GridView.SnapToRow highlightMoveDuration: 0 interactive: true onWidthChanged: adaptContent? control.adaptGrid() : undefined PinchArea { anchors.fill: parent z: -1 onPinchStarted: { console.log("pinch started") } onPinchUpdated: { } onPinchFinished: { console.log("pinch finished") resizeContent(pinch.scale) } MouseArea - { - anchors.fill: parent - propagateComposedEvents: true - acceptedButtons: Qt.RightButton | Qt.LeftButton - onClicked: control.areaClicked(mouse) - onPressAndHold: control.areaRightClicked() - - onWheel: + { + anchors.fill: parent + propagateComposedEvents: true + acceptedButtons: Qt.RightButton | Qt.LeftButton + onClicked: control.areaClicked(mouse) + onPressAndHold: control.areaRightClicked() + + onWheel: { if (wheel.modifiers & Qt.ControlModifier) { - if (wheel.angleDelta.y != 0) - { - var factor = 1 + wheel.angleDelta.y / 600; - control.resizeContent(factor) - } + if (wheel.angleDelta.y != 0) + { + var factor = 1 + wheel.angleDelta.y / 600; + control.resizeContent(factor) + } }else - wheel.accepted = false + wheel.accepted = false } - - } - } + + } + } } function resizeContent(factor) { if(factor > 1) { control.itemSize = control.itemSize + 10 control.cellHeight = control.cellHeight + 10 control.cellWidth = control.cellWidth + 10 } else if((control.itemSize - 10) > iconSizes.small) { control.itemSize = control.itemSize - 10 control.cellHeight = control.cellHeight - 10 control.cellWidth = control.cellWidth - 10 } if(adaptContent) control.adaptGrid() } function adaptGrid() { var amount = parseInt(gridView.width / (itemSize + spacing), 10) var leftSpace = parseInt(gridView.width - ( amount * (itemSize + spacing) ), 10) var size = parseInt((itemSize + spacing) + (parseInt(leftSpace/amount, 10)), 10) size = size > itemSize + spacing ? size : itemSize + spacing cellWidth = size } } diff --git a/src/controls/Item.qml b/src/controls/Item.qml deleted file mode 100644 index 9a4bc8e..0000000 --- a/src/controls/Item.qml +++ /dev/null @@ -1,19 +0,0 @@ -import QtQuick 2.9 -import "private" - -Item -{ - id: control - - /* Controlc color scheming */ - ColorScheme {id: colorScheme} - property alias colorScheme : colorScheme - /***************************/ - - Rectangle - { - anchors.fill: parent - color: control.colorScheme.backgroundColor - } - -} diff --git a/src/controls/Menu.qml b/src/controls/Menu.qml deleted file mode 100644 index 0a2b956..0000000 --- a/src/controls/Menu.qml +++ /dev/null @@ -1,24 +0,0 @@ -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 : control.contentData -} diff --git a/src/controls/MenuItem.qml b/src/controls/MenuItem.qml deleted file mode 100644 index 3bff1e4..0000000 --- a/src/controls/MenuItem.qml +++ /dev/null @@ -1,36 +0,0 @@ -/* - * 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 - /***************************/ - -} diff --git a/src/controls/Page.qml b/src/controls/Page.qml index b27dfbb..eb0608a 100644 --- a/src/controls/Page.qml +++ b/src/controls/Page.qml @@ -1,289 +1,70 @@ -/* - * 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 2.4 import QtQuick.Controls 2.2 -import QtQuick.Layouts 1.3 import org.kde.mauikit 1.0 as Maui import org.kde.kirigami 2.7 as Kirigami -import QtGraphicalEffects 1.0 -import QtQuick.Window 2.0 - -import "private" Page { - id: control - - /* Controlc color scheming */ - ColorScheme - { - id: colorScheme - backgroundColor: viewBackgroundColor - } - property alias colorScheme : colorScheme - /***************************/ - - property bool headBarExit : true - property bool headBarTitleVisible: headBarTitle - property string headBarExitIcon : "dialog-close" - property string headBarTitle: "" - - property int margins: contentMargins * 1.5 - property int topMargin: margins - property int rightMargin: margins - property int leftMargin: margins - property int bottomMargin: margins - - property alias headBar: topToolBar - property alias headBarItem: topToolBar.data - property alias footBar: bottomToolBar - property alias footBarItem: bottomToolBar.data - property alias floatingBar: bottomToolBar.floating - property alias flickable: flickable - - property int footBarAligment : Qt.AlignCenter - property bool altToolBars : false - property int footBarMargins : space.large - property bool footBarOverlap: false - property bool allowRiseContent: floatingBar && footBarOverlap && footBar.visible - - property bool contentIsRised: false - - signal exit(); - - default property alias content : mainContainer.data - property alias backContain: backContainer.data - - clip: true - - leftPadding: 0 - topPadding: leftPadding - rightPadding: leftPadding - bottomPadding: leftPadding - - background: Rectangle - { - color: colorScheme.backgroundColor - } - - GridLayout - { - id: rootLayout - anchors.fill: parent - rows: 3 - columns: 1 - rowSpacing: 0 - - - Maui.ToolBar - { - id: topToolBar - Layout.fillWidth: !folded - Layout.rightMargin: floating ? space.small : 0 - Layout.leftMargin: floating ? space.small : 0 - Layout.bottomMargin: 0 - Layout.topMargin: 0 - - Layout.row: altToolBars ? 3 : 1 - Layout.column: 1 - - Kirigami.Theme.backgroundColor: control.colorScheme.backgroundColor - - position: altToolBars ? ToolBar.Footer : ToolBar.Header - dropShadow: false - drawBorder: !dropShadow - - width: folded ? height : implicitWidth - implicitWidth: width - - Layout.preferredHeight: implicitHeight - implicitHeight: topToolBar.visible ? toolBarHeightAlt : 0 - visible: count > 0 - clip: false - z: container.z +1 - - leftContent: ToolButton - { - id: exitBtn - visible: headBarExit - icon.name : headBarExitIcon - onClicked : exit() - } - - middleContent: Label - { - visible: headBarTitleVisible - text : headBarTitle - Layout.fillWidth: true - elide : Text.ElideRight - font.bold : false - font.weight: Font.Bold - color : colorScheme.textColor - font.pointSize: fontSizes.big - horizontalAlignment : Text.AlignHCenter - verticalAlignment : Text.AlignVCenter - } - } - - Item - { - id: container - - Layout.fillWidth: true - Layout.fillHeight: true - - Layout.topMargin: topMargin - Layout.bottomMargin: bottomMargin - Layout.rightMargin: rightMargin - Layout.leftMargin: leftMargin - - Layout.row: altToolBars ? 1 : 2 - Layout.column: 1 - - clip: false - - anchors.margins: floatingBar && footBarOverlap ? margins : 0 - anchors.top: if(!floatingBar && !topToolBar.plegable) - undefined - else - { - if(!altToolBars && headBar.visible && !topToolBar.plegable) - topToolBar.bottom - - else if(!altToolBars && headBar.visible && topToolBar.plegable) - topToolBar.top - - else if(altToolBars && headBar.visible) - rootLayout.top - } - - anchors.bottom: if(!floatingBar && !topToolBar.plegable) - undefined - else - { - if(altToolBars && headBar.visible && (footBarOverlap && floatingBar && footBar.visible) && !topToolBar.plegable) - topToolBar.top/*.bottom*/ - - else if(altToolBars && headBar.visible && (!footBarOverlap && floatingBar && footBar.visible) && !topToolBar.plegable) - bottomToolBar.verticalCenter/*.bottom*/ - - else if(altToolBars && headBar.visible && (footBarOverlap && floatingBar && footBar.visible) && topToolBar.plegable) - topToolBar.bottom - - else if(altToolBars && headBar.visible && !footBar.visible && topToolBar.plegable) - topToolBar.verticalCenter - - else if(!footBarOverlap && !floatingBar && footBar.visible) - bottomToolBar.top - - else if(!altToolBars && floatingBar && footBarOverlap && footBar.visible) - rootLayout.bottom - - } - z: 1 - - Flickable - { - id: flickable - flickableDirection: Flickable.VerticalFlick - height: parent.height - width: parent.width - z: container.z - // boundsMovement: Flickable.StopAtBounds - boundsBehavior: Flickable.StopAtBounds - interactive: allowRiseContent - contentWidth: parent.width - contentHeight: allowRiseContent ? parent.height + footBar.height + footBarMargins + space.big : - parent.height - - onContentYChanged: control.contentIsRised = contentY > 0 - - - Item - { - id: mainContainer - z: container.z - width: container.width - height: contentIsRised ? container.height - (footBar.height + footBarMargins + space.big) : - container.height - y: contentIsRised ? flickable.contentY : 0 - - Item - { - id: backContainer - z: mainContainer.z - 1 - width: container.width - height: footBar.height + footBarMargins + space.big - anchors - { - left: parent.left - right: parent.right - top: parent.bottom - margins: space.big - } - } - } - } - } - - Maui.ToolBar - { - id: bottomToolBar - - visible: count > 0 - - readonly property int _margins : footBarMargins - - Layout.leftMargin: footBarAligment === Qt.AlignLeft ? _margins : (floating ? space.small : 0) - Layout.rightMargin: footBarAligment === Qt.AlignRight ? _margins : (floating ? space.small : 0) - Layout.bottomMargin: floating ? _margins : 0 - Layout.alignment: footBarAligment - Layout.fillWidth: true - Layout.preferredHeight: implicitHeight - // Layout.minimumWidth: parent.width * (floatingBar ? 0.4 : 1) - Layout.maximumWidth: floating ? middleLayout.implicitWidth + layout.implicitWidth : parent.width - Layout.row: altToolBars ? 2 : 3 - Layout.column: 1 - z: container.z +1 - position: ToolBar.Footer - clip: false - - colorScheme - { - backgroundColor: control.colorScheme.backgroundColor - textColor : control.colorScheme.textColor - } - - drawBorder: !floating - } - } - - function riseContent() - { - if(allowRiseContent) - flickable.flick(0, flickable.contentHeight* -2) - } - - function dropContent() - { - if(allowRiseContent) - flickable.flick(0, flickable.contentHeight* 2) - } + 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/PieButton.qml b/src/controls/PieButton.qml index a6bc532..02bf711 100644 --- a/src/controls/PieButton.qml +++ b/src/controls/PieButton.qml @@ -1,100 +1,100 @@ /* * 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.6 import QtQuick.Controls 2.2 import org.kde.mauikit 1.0 as Maui -import org.kde.kirigami 2.0 as Kirigami +import org.kde.kirigami 2.7 as Kirigami import "private" ToolButton { id: control /* Controlc color scheming */ ColorScheme {id: colorScheme} property alias colorScheme : colorScheme /***************************/ property int alignment : Qt.AlignLeft property int barHeight : 0 property int maxWidth : ApplicationWindow.overlay.width *( isMobile ? 1 : 0.5) property alias content : content.middleContent onClicked: popup.visible ? close(): open() layer.enabled: true clip: true z: 1 Popup { id: popup height: barHeight implicitWidth: content.middleLayout.implicitWidth + space.big + space.small width: implicitWidth > maxWidth ? maxWidth : (content.middleLayout.implicitWidth > ApplicationWindow.overlay.width ? ApplicationWindow.overlay.width : implicitWidth) padding: 0 margins: 0 x: alignment === Qt.AlignLeft ? (control.x - width) - space.big : (control.x + control.width) + space.big y: parent.height / 2 - height / 2 background: Rectangle { radius: radiusV color: colorScheme.backgroundColor border.color: colorScheme.borderColor } onFocusChanged: !activeFocus || !focus ? close() : undefined 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 } } Maui.ToolBar { id: content anchors.fill: parent implicitHeight: parent.height spacing: space.enormous - colorScheme.backgroundColor: "transparent" + Kirigami.Theme.backgroundColor: "transparent" drawBorder: false } } function open() { popup.open() } function close() { popup.close() } } diff --git a/src/controls/SearchBar.qml b/src/controls/SearchBar.qml deleted file mode 100644 index f507b08..0000000 --- a/src/controls/SearchBar.qml +++ /dev/null @@ -1,57 +0,0 @@ - -/* - * 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 org.kde.mauikit 1.0 as Maui - -Maui.ToolBar -{ - - id: control - height: 30 - - width: 30 - signal search(string query) - - leftContent: ToolButton - { - icon.name: "view-filter" - } - - middleContent: Maui.TextField - { - id: searchInput - placeholderText: qsTr("Search...") - width: footBar.middleLayout.width * 0.9 - - onAccepted: search(searchInput.text) - } - - rightContent : ToolButton - { - icon.name: "edit-clear" - Layout.alignment: Qt.AlignRight - onClicked: searchInput.clear() - } -} diff --git a/src/controls/SyncDialog.qml b/src/controls/SyncDialog.qml index 5839906..f732124 100644 --- a/src/controls/SyncDialog.qml +++ b/src/controls/SyncDialog.qml @@ -1,105 +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.Dialog { id: control property bool customServer: false acceptText: qsTr("Sign In") rejectText: qsTr("Cancel") rejectButton.visible: false property alias serverField: serverField property alias userField: userField property alias passwordField: passwordField maxHeight: unit * 300 maxWidth: maxHeight - footBar.leftContent: ToolButton - { - icon.name: "filename-space-amarok" -// text: qsTr("Custom server") - checkable: true - checked: customServer - onClicked: customServer = !customServer - } + + footBar.leftContent: ToolButton + { + icon.name: "filename-space-amarok" + // text: qsTr("Custom server") + checkable: true + checked: customServer + onClicked: customServer = !customServer + } + onRejected: close() Item { anchors.fill: parent ColumnLayout { anchors.centerIn: parent width: parent.width Image { visible: !customServer Layout.alignment: Qt.AlignCenter Layout.preferredWidth: width Layout.preferredHeight: height Layout.margins: space.big width: iconSizes.huge height: width sourceSize.width: width sourceSize.height: height source: "qrc:/assets/opendesktop.png" } Maui.TextField { id: serverField visible: customServer Layout.fillWidth: true placeholderText: qsTr("Server address...") text: "https://cloud.opendesktop.cc/remote.php/webdav/" } Maui.TextField { id: userField Layout.fillWidth: true placeholderText: qsTr("User name...") inputMethodHints: Qt.ImhNoAutoUppercase } Maui.TextField { id: passwordField Layout.fillWidth: true placeholderText: qsTr("User password...") echoMode: TextInput.PasswordEchoOnEdit inputMethodHints: Qt.ImhNoAutoUppercase } } } } 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 } } } diff --git a/src/controls/ToolBar.qml b/src/controls/ToolBar.qml index 30ac4b5..978452d 100644 --- a/src/controls/ToolBar.qml +++ b/src/controls/ToolBar.qml @@ -1,262 +1,251 @@ /* * 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.6 import QtQuick.Controls 2.2 import org.kde.kirigami 2.7 as Kirigami import org.kde.mauikit 1.0 as Maui import QtQuick.Layouts 1.3 import QtGraphicalEffects 1.0 import "private" ToolBar { id: control - /* Controlc color scheming */ - ColorScheme {id: colorScheme} - property alias colorScheme : colorScheme - /***************************/ - - clip: true implicitWidth: Math.max(background ? background.implicitWidth : 0, contentWidth + leftPadding + rightPadding) implicitHeight: visible ? (floating ? toolBarHeightAlt : toolBarHeight) : 0 width: floating ? implicitWidth : parent.width height: implicitHeight property alias stickyRightContent : rightRowContent.sticky property alias stickyLeftContent : leftRowContent.sticky property alias stickyMiddleContent : middleRowContent.sticky property alias leftContent : leftRowContent.data property alias middleContent : middleRowContent.data property alias rightContent : rightRowContent.data property alias middleLayout : middleRowContent property alias leftLayout : leftRowContent property alias rightLayout : rightRowContent property alias layout : layout property int margins: space.medium spacing: space.medium property int count : leftContent.length + middleContent.length + rightContent.length property bool dropShadow: false property bool drawBorder: false property bool floating: false property bool plegable: false //deprecrated property bool folded : false //deprecrated property bool flickable: true property bool strech : true property bool leftSretch: strech property bool rightSretch: strech property bool middleStrech: strech padding: 0 // leftPadding: Kirigami.Units.smallSpacing*2 // rightPadding: Kirigami.Units.smallSpacing*2 signal unfolded() // onPlegableChanged: folded = plegable // onVisibleChanged: // { // if(control.visible) // control.height= implicitHeight // else // control.height= 0 // // } // background: Rectangle // { // id: headBarBG // color: colorScheme.backgroundColor // implicitHeight: toolBarHeightAlt // radius: floating ? radiusV : 0 // border.color: floating ? colorScheme.borderColor : "transparent" // // SequentialAnimation on radius // { // ColorAnimation { to: colorScheme.backgroundColor ; duration: 1000 } // } // // Kirigami.Separator // { // visible: drawBorder // color: colorScheme.borderColor // height: unit // anchors // { // left: parent.left // right: parent.right // bottom: control.position == ToolBar.Footer ? undefined : parent.bottom // top: control.position == ToolBar.Footer ? parent.top : undefined // } // } // // layer.enabled: dropShadow // layer.effect: DropShadow // { // anchors.fill: headBarBG // horizontalOffset: 0 // verticalOffset: unit * (altToolBars ? -1 : 1) // radius: 8 // samples: 25 // color: Qt.darker(colorScheme.backgroundColor, 1.4) // source: headBarBG // } // } - + Rectangle { width: parent.height height: iconSizes.tiny visible: !mainFlickable.atXEnd && mainFlickable.interactive rotation: 270 opacity: 0.2 anchors { top: parent.top bottom: parent.bottom right: parent.right } z: 999 gradient: Gradient { GradientStop { position: 0.0 color: "transparent" } GradientStop { position: 1.0 - color: colorScheme.textColor + color: Kirigami.Theme.textColor } } } Rectangle { width: parent.height height: iconSizes.tiny visible: !mainFlickable.atXBeginning && mainFlickable.interactive rotation: 270 opacity: 0.2 anchors { top: parent.top bottom: parent.bottom left: parent.left } z: 999 gradient: Gradient { GradientStop { position: 0.0 - color: colorScheme.textColor + color: Kirigami.Theme.textColor } GradientStop { position: 1.0 color: "transparent" } } } Flickable { id: mainFlickable anchors.fill: parent anchors.leftMargin: margins anchors.rightMargin: margins flickableDirection: Flickable.HorizontalFlick interactive: (contentWidth > control.width) && control.flickable contentWidth: ((control.margins * 2) + space.medium) + (control.stickyLeftContent ? leftRowContent.implicitWidth : leftRowContent.width) + (control.stickyMiddleContent ? middleRowContent.implicitWidth : middleRowContent.width) + (control.stickyRightContent ? rightRowContent.implicitWidth : rightRowContent.width) boundsBehavior: isMobile ? Flickable.DragOverBounds : Flickable.StopAtBounds clip: true RowLayout { id: layout height: mainFlickable.height width: mainFlickable.width - RowLayout { id: leftRowContent property bool sticky : false Layout.leftMargin: rightRowContent.implicitWidth && implicitWidth === 0 && middleRowContent.implicitWidth && control.leftSretch ? rightRowContent.implicitWidth : undefined Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft spacing: leftContent.length > 0 ? control.spacing : 0 Layout.minimumWidth: !sticky ? undefined : implicitWidth - clip: true Layout.fillWidth: control.leftSretch && implicitWidth Layout.fillHeight: true } RowLayout { id: middleRowContent property bool sticky : false - Layout.alignment: Qt.AlignCenter - - clip: true + Layout.alignment: Qt.AlignCenter spacing: middleContent.length === 1 ? 0 : control.spacing Layout.minimumWidth: !sticky ? undefined : implicitWidth // Layout.maximumWidth: control.width - leftRowContent.implicitWidth - rightRowContent.implicitWidth Layout.fillWidth: control.middleStrech Layout.fillHeight: true } RowLayout { id: rightRowContent property bool sticky : false Layout.rightMargin: leftRowContent.implicitWidth && implicitWidth === 0 && middleRowContent.implicitWidth && control.rightSretch ? leftRowContent.implicitWidth : undefined Layout.alignment: Qt.AlignVCenter | Qt.AlignRight spacing: rightContent.length > 0 ? control.spacing : 0 - Layout.minimumWidth: !sticky ? undefined : implicitWidth - clip: true - Layout.fillWidth: implicitWidth + Layout.minimumWidth: implicitWidth + Layout.fillWidth: false Layout.fillHeight: true } } - ScrollBar.horizontal: ScrollBar { visible: false} +// ScrollBar.horizontal: ScrollBar { visible: false} } } diff --git a/src/controls/ToolButton.qml b/src/controls/ToolButton.qml deleted file mode 100644 index bc95abc..0000000 --- a/src/controls/ToolButton.qml +++ /dev/null @@ -1,211 +0,0 @@ -/* - * 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.6 -import QtQuick.Controls 2.2 -import QtQuick.Controls.impl 2.3 -import QtQuick.Layouts 1.3 - -import org.kde.kirigami 2.4 as Kirigami -import "private" - -ToolButton -{ - id: control - - readonly property var indicatorStyles : ({ - underline: 0, - box: 1 - }) - - focusPolicy: Qt.NoFocus - /* Controlc color scheming */ - ColorScheme - { - id: colorScheme - backgroundColor: "transparent" - borderColor: "transparent" - } - property alias colorScheme : colorScheme - /***************************/ - - // property alias backgroundRec: _background - - property bool isMask: true - property string iconName: "" - property string iconFallback: "" - property int size: iconSize - property color iconColor: control.active && control.indicatorStyle === control.indicatorStyles.box ? control.colorScheme.highlightColor : colorScheme.textColor - property bool anim: false - property string tooltipText : "" - property bool showIndicator: false - property bool active: false - property int indicatorStyle: indicatorStyles.box - hoverEnabled: false - - - - - // implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset, - // implicitContentWidth + leftPadding + rightPadding) - // implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset, - // implicitContentHeight + topPadding + bottomPadding) - - height: control.visible ? (control.display === ToolButton.IconOnly ? size + space.medium : implicitHeight) : 0 - width: control.visible ? (control.display === ToolButton.IconOnly ? height : implicitWidth + space.small) : 0 - - icon.name: control.iconName - icon.source: control.iconFallback - icon.width: control.size - icon.height: control.size - icon.color: !control.isMask ? "transparent" : (down || pressed || checked) ? colorScheme.highlightColor : iconColor - - onClicked: if(anim) animIcon.running = true - - flat: true - highlighted: !isMask - font.pointSize: control.display === ToolButton.TextUnderIcon ? fontSizes.small : undefined - - display: control.active ? (control.text.length > 0 ? (isWide ? ToolButton.TextBesideIcon : ToolButton.TextUnderIcon) : ToolButton.IconOnly) : ToolButton.IconOnly - spacing: space.tiny - Kirigami.Theme.textColor: control.icon.color - Rectangle - { - id: _indicator - color: control.colorScheme.highlightColor - height: control.indicatorStyle == indicatorStyles.box ? control.height : (indicatorStyle === indicatorStyles.underline ? unit * 5 : 0) - width: visible ? (control.width) : 0 - radius: control.indicatorStyle == indicatorStyles.box ? radiusV : 0 - opacity: control.indicatorStyle == indicatorStyles.box ? 0.3 : 1 - anchors.bottom: parent.bottom - anchors.horizontalCenter: control.horizontalCenter - visible: control.showIndicator && control.visible && control.active - z: background.z -1 - } - -// background: Rectangle -// { -// id: _background -// implicitHeight: control.visible ? control.size : 0 -// implicitWidth: control.visible ? control.size : 0 -// -// anchors.centerIn: control.icon -// color: /*(down || pressed || checked) */ checked && enabled ? -// Qt.lighter(colorScheme.highlightColor, 1.2) : colorScheme.backgroundColor -// radius: unit * 3 -// opacity: (down || pressed || checked) && enabled ? 0.5 : 1 -// border.color: colorScheme.borderColor -// } -// -// contentItem: IconLabel -// { -// id: _iconLabel -// spacing: control.display === ToolButton.TextUnderIcon ? space.tiny : control.spacing -// mirrored: control.mirrored -// display: control.display -// icon: control.icon -// text: control.text -// font: control.font -// color: control.icon.color -// } - - - // background: Rectangle - // { - // implicitHeight: control.visible ? control.height : 0 - // implicitWidth: control.visible ? control.width : 0 - // - // anchors.centerIn: control - // color: /*(down || pressed || checked) */ checked && enabled ? - // Qt.lighter(colorScheme.highlightColor, 1.2) : colorScheme.backgroundColor - // radius: unit * 3 - // opacity: (down || pressed || checked) && enabled ? 0.5 : 1 - // border.color: colorScheme.borderColor - // } - // - // contentItem: GridLayout - // { - // id: _contentLayout - // anchors.fill: control - // - // columns: (control.display === ToolButton.TextUnderIcon) || (control.display === ToolButton.IconOnly)? 1 : 2 - // rows: (control.display === ToolButton.TextUnderIcon) ? 2 : 1 - // - // columnSpacing: 0 - // rowSpacing: 0 - // - // Item - // { - // Layout.fillWidth: true - // Layout.fillHeight: true - // Layout.row: 1 - // Layout.column: 1 - // Layout.alignment: Qt.AlignBottom - // - // Kirigami.Icon - // { - // anchors.centerIn: parent - // source: control.iconName - // isMask: control.isMask - // height: size - // width: height - // color: isMask ? control.iconColor : "transparent" - // } - // } - // - // Item - // { - // visible: control.text.length && control.text - // Layout.fillWidth: true - // Layout.fillHeight: true - // Layout.row: (control.display === ToolButton.TextUnderIcon) ? 2 : 1 - // Layout.column: (control.display === ToolButton.TextUnderIcon) || (control.display === ToolButton.IconOnly)? 1 : 2 - // Layout.alignment: Qt.AlignTop - // - // Label - // { - // anchors.fill: parent - // font: control.font - // text: control.text - // color: control.iconColor - // horizontalAlignment: Qt.AlignHCenter - // verticalAlignment: Qt.AlignVCenter - // } - // } - // } - - SequentialAnimation - { - id: animIcon - PropertyAnimation - { - target: control - property: "icon.color" - easing.type: Easing.InOutQuad - from: colorScheme.highlightColor - to: iconColor - duration: 500 - } - } - - ToolTip.delay: 1000 - ToolTip.timeout: 5000 - ToolTip.visible: hovered && !isMobile && tooltipText.length > 0 - ToolTip.text: tooltipText -} diff --git a/src/controls/ToolButton2.qml b/src/controls/ToolButton2.qml deleted file mode 100644 index f6831ab..0000000 --- a/src/controls/ToolButton2.qml +++ /dev/null @@ -1,211 +0,0 @@ -/* - * 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.6 -import QtQuick.Controls 2.2 -import QtQuick.Controls.impl 2.3 -import QtQuick.Layouts 1.3 - -import org.kde.kirigami 2.4 as Kirigami -import "private" - -ToolButton -{ - id: control - - readonly property var indicatorStyles : ({ - underline: 0, - box: 1 - }) - - focusPolicy: Qt.NoFocus - /* Controlc color scheming */ - ColorScheme - { - id: colorScheme - backgroundColor: "transparent" - borderColor: "transparent" - } - property alias colorScheme : colorScheme - /***************************/ - - // property alias backgroundRec: _background - - property bool isMask: true - property string iconName: "" - property string iconFallback: "" - property int size: iconSize - property color iconColor: control.active && control.indicatorStyle === control.indicatorStyles.box ? control.colorScheme.highlightColor : colorScheme.textColor - property bool anim: false - property string tooltipText : "" - property bool showIndicator: false - property bool active: false - property int indicatorStyle: indicatorStyles.box - hoverEnabled: false - - - - - // implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset, - // implicitContentWidth + leftPadding + rightPadding) - // implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset, - // implicitContentHeight + topPadding + bottomPadding) - - height: control.visible ? (control.display === ToolButton.IconOnly ? size + space.medium : implicitHeight) : 0 - width: control.visible ? (control.display === ToolButton.IconOnly ? height : implicitWidth + space.small) : 0 - - icon.name: control.iconName - icon.source: control.iconFallback - icon.width: control.size - icon.height: control.size - icon.color: !control.isMask ? "transparent" : (down || pressed || checked) ? colorScheme.highlightColor : iconColor - - onClicked: if(anim) animIcon.running = true - - flat: true - highlighted: !isMask - font.pointSize: control.display === ToolButton.TextUnderIcon ? fontSizes.small : undefined - - display: control.active ? (control.text.length > 0 ? (isWide ? ToolButton.TextBesideIcon : ToolButton.TextUnderIcon) : ToolButton.IconOnly) : ToolButton.IconOnly - spacing: space.tiny - Kirigami.Theme.textColor: control.icon.color - Rectangle - { - id: _indicator - color: control.colorScheme.highlightColor - height: control.indicatorStyle == indicatorStyles.box ? control.height : (indicatorStyle === indicatorStyles.underline ? unit * 5 : 0) - width: visible ? (control.width) : 0 - radius: control.indicatorStyle == indicatorStyles.box ? radiusV : 0 - opacity: control.indicatorStyle == indicatorStyles.box ? 0.3 : 1 - anchors.bottom: parent.bottom - anchors.horizontalCenter: control.horizontalCenter - visible: control.showIndicator && control.visible && control.active - z: background.z -1 - } - - background: Rectangle - { - id: _background - implicitHeight: control.visible ? control.size : 0 - implicitWidth: control.visible ? control.size : 0 - - anchors.centerIn: control.icon - color: /*(down || pressed || checked) */ checked && enabled ? - Qt.lighter(colorScheme.highlightColor, 1.2) : colorScheme.backgroundColor - radius: unit * 3 - opacity: (down || pressed || checked) && enabled ? 0.5 : 1 - border.color: colorScheme.borderColor - } - - contentItem: IconLabel - { - id: _iconLabel - spacing: control.display === ToolButton.TextUnderIcon ? space.tiny : control.spacing - mirrored: control.mirrored - display: control.display - icon: control.icon - text: control.text - font: control.font - color: control.icon.color - } - - - // background: Rectangle - // { - // implicitHeight: control.visible ? control.height : 0 - // implicitWidth: control.visible ? control.width : 0 - // - // anchors.centerIn: control - // color: /*(down || pressed || checked) */ checked && enabled ? - // Qt.lighter(colorScheme.highlightColor, 1.2) : colorScheme.backgroundColor - // radius: unit * 3 - // opacity: (down || pressed || checked) && enabled ? 0.5 : 1 - // border.color: colorScheme.borderColor - // } - // - // contentItem: GridLayout - // { - // id: _contentLayout - // anchors.fill: control - // - // columns: (control.display === ToolButton.TextUnderIcon) || (control.display === ToolButton.IconOnly)? 1 : 2 - // rows: (control.display === ToolButton.TextUnderIcon) ? 2 : 1 - // - // columnSpacing: 0 - // rowSpacing: 0 - // - // Item - // { - // Layout.fillWidth: true - // Layout.fillHeight: true - // Layout.row: 1 - // Layout.column: 1 - // Layout.alignment: Qt.AlignBottom - // - // Kirigami.Icon - // { - // anchors.centerIn: parent - // source: control.iconName - // isMask: control.isMask - // height: size - // width: height - // color: isMask ? control.iconColor : "transparent" - // } - // } - // - // Item - // { - // visible: control.text.length && control.text - // Layout.fillWidth: true - // Layout.fillHeight: true - // Layout.row: (control.display === ToolButton.TextUnderIcon) ? 2 : 1 - // Layout.column: (control.display === ToolButton.TextUnderIcon) || (control.display === ToolButton.IconOnly)? 1 : 2 - // Layout.alignment: Qt.AlignTop - // - // Label - // { - // anchors.fill: parent - // font: control.font - // text: control.text - // color: control.iconColor - // horizontalAlignment: Qt.AlignHCenter - // verticalAlignment: Qt.AlignVCenter - // } - // } - // } - - SequentialAnimation - { - id: animIcon - PropertyAnimation - { - target: control - property: "icon.color" - easing.type: Easing.InOutQuad - from: colorScheme.highlightColor - to: iconColor - duration: 500 - } - } - - ToolTip.delay: 1000 - ToolTip.timeout: 5000 - ToolTip.visible: hovered && !isMobile && tooltipText.length > 0 - ToolTip.text: tooltipText -} diff --git a/src/controls/private/AccountsHelper.qml b/src/controls/private/AccountsHelper.qml index c5c3b2a..a2f6b51 100644 --- a/src/controls/private/AccountsHelper.qml +++ b/src/controls/private/AccountsHelper.qml @@ -1,169 +1,173 @@ import QtQuick 2.9 import QtQuick.Controls 2.2 import QtQuick.Layouts 1.3 import org.kde.kirigami 2.6 as Kirigami import org.kde.mauikit 1.0 as Maui import SyncingModel 1.0 import SyncingList 1.0 Maui.Dialog { - + id: control defaultButtons: false - - maxHeight: 300* unit - maxWidth: maxHeight - - property alias model : _syncingModel - property alias list : _syncingList - - Maui.SyncDialog - { - id: _syncDialog - onAccepted: + + maxHeight: 300* unit + maxWidth: maxHeight + + property alias model : _syncingModel + property alias list : _syncingList + + Maui.SyncDialog { - control.addAccount(serverField.text, userField.text, passwordField.text); - close(); + id: _syncDialog + onAccepted: + { + control.addAccount(serverField.text, userField.text, passwordField.text); + close(); + } } - } - - footBar.margins: 0 - footBar.middleContent: Button - { - Kirigami.Theme.textColor: "white" - Kirigami.Theme.backgroundColor: suggestedColor - text: qsTr("Add account") - onClicked: _syncDialog.open() - } - - SyncingModel - { - id: _syncingModel - list: _syncingList - } - - SyncingList - { - id: _syncingList - } - - Maui.Dialog - { - id: _removeDialog - maxWidth: unit * 400 - title: qsTr("Remove account?") - message: qsTr("Are you sure you want to remove this account?") + // footBar.margins: 0 - acceptButton.text: qsTr("Delete account") - rejectButton.visible: false + footBar.middleContent: Button + { + Kirigami.Theme.textColor: "white" + Kirigami.Theme.backgroundColor: suggestedColor + text: qsTr("Add account") + onClicked: _syncDialog.open() + } - onAccepted: + + SyncingModel { - var account = _syncingList.get(_listView.currentIndex) - console.log(account.label) - control.removeAccount(account.server, account.user) - close() + id: _syncingModel + list: _syncingList } - footBar.rightContent: Button + SyncingList { - text: qsTr("Delete account and files") - onClicked: + id: _syncingList + } + + Maui.Dialog + { + id: _removeDialog + + maxWidth: unit * 400 + title: qsTr("Remove account?") + message: qsTr("Are you sure you want to remove this account?") + + acceptButton.text: qsTr("Delete account") + rejectButton.visible: false + + onAccepted: { var account = _syncingList.get(_listView.currentIndex) - control.removeAccountAndFiles(account.server, account.user) + console.log(account.label) + control.removeAccount(account.server, account.user) close() } + + + footBar.rightContent: Button + { + text: qsTr("Delete account and files") + onClicked: + { + var account = _syncingList.get(_listView.currentIndex) + control.removeAccountAndFiles(account.server, account.user) + close() + } + } + } - } - - Menu - { - id: _menu -// Maui.MenuItem -// { -// text: qsTr("Edit...") -// onTriggered: -// { -// previewer.show(control.items[0].path) -// close() -// } -// } -// - MenuItem - { - text: qsTr("Remove...") - Kirigami.Theme.textColor: dangerColor + + Menu + { + id: _menu + // Maui.MenuItem + // { + // text: qsTr("Edit...") + // onTriggered: + // { + // previewer.show(control.items[0].path) + // close() + // } + // } + // + MenuItem + { + text: qsTr("Remove...") + Kirigami.Theme.textColor: dangerColor + + onTriggered: _removeDialog.open() + } - onTriggered: _removeDialog.open() } - } - - ListView - { - id: _listView - anchors.fill: parent - model: _syncingModel - delegate: Maui.ListDelegate + ListView { - id: delegate - label: model.label - radius: radiusV - Connections + id: _listView + anchors.fill: parent + model: _syncingModel + delegate: Maui.ListDelegate { - target: delegate - onClicked: - { - _listView.currentIndex = index - } - - onPressAndHold: - { - _listView.currentIndex = index - _menu.popup() - } - - onRightClicked: + id: delegate + label: model.label + radius: radiusV + Connections { - _listView.currentIndex = index - _menu.popup() + target: delegate + onClicked: + { + _listView.currentIndex = index + } + + onPressAndHold: + { + _listView.currentIndex = index + _menu.popup() + } + + onRightClicked: + { + _listView.currentIndex = index + _menu.popup() + } + } - } + + Maui.Holder + { + visible: _listView.count == 0 + isMask: false + isGif: false + emojiSize: iconSizes.huge + title: qsTr("No accounts yet!") + body: qsTr("Start adding new accounts to sync your files, music, contacts, images, notes, etc...") + } + } - Maui.Holder + function addAccount(server, user, password) { - visible: _listView.count == 0 - isMask: false - isGif: false - emojiSize: iconSizes.huge - title: qsTr("No accounts yet!") - body: qsTr("Start adding new accounts to sync your files, music, contacts, images, notes, etc...") + if(user.length) + _syncingList.insert({server: server, user: user, password: password}) } - } - - function addAccount(server, user, password) - { - if(user.length) - _syncingList.insert({server: server, user: user, password: password}) - } - - function removeAccount(server, user) - { - if(server.length && user.length) - _syncingList.removeAccount(server, user) - } - - function removeAccountAndFiles(server, user) - { - if(server.length && user.length) - _syncingList.removeAccountAndFiles(server, user) - } + function removeAccount(server, user) + { + if(server.length && user.length) + _syncingList.removeAccount(server, user) + } + + function removeAccountAndFiles(server, user) + { + if(server.length && user.length) + _syncingList.removeAccountAndFiles(server, user) + } }