diff --git a/src/controls/ItemDelegate.qml b/src/controls/ItemDelegate.qml index cebcafd..a899f3c 100644 --- a/src/controls/ItemDelegate.qml +++ b/src/controls/ItemDelegate.qml @@ -1,140 +1,153 @@ /* * 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.5 +import QtQuick 2.12 import QtQuick.Controls 2.2 import QtQuick.Layouts 1.3 import org.kde.kirigami 2.7 as Kirigami import org.kde.mauikit 1.0 as Maui import QtGraphicalEffects 1.0 import "private" ItemDelegate { id: control default property alias content : _content.data - - property alias mouseArea : _mouseArea + + property alias mouseArea : _mouseArea +// property alias tapArea : _tapArea property bool draggable: false property bool isCurrentItem : false property int radius: Maui.Style.radiusV highlighted: isCurrentItem //override the itemdelegate default signals to allow dragging content signal pressed(var mouse) signal pressAndHold(var mouse) signal clicked(var mouse) signal rightClicked(var mouse) signal doubleClicked(var mouse) - Kirigami.Theme.inherit: false + Kirigami.Theme.inherit: false Kirigami.Theme.backgroundColor: "transparent" hoverEnabled: !Kirigami.Settings.isMobile padding: 0 bottomPadding: padding rightPadding: padding leftPadding: padding topPadding: padding MouseArea { id: _mouseArea +// enabled: !Kirigami.Settings.isMobile anchors.fill: parent acceptedButtons: Qt.RightButton | Qt.LeftButton drag.target: control.draggable && !Kirigami.Settings.isMobile ? parent : undefined property int startX property int startY onClicked: { if(!Kirigami.Settings.isMobile && mouse.button === Qt.RightButton) control.rightClicked(mouse) else control.clicked(mouse) } onDoubleClicked: control.doubleClicked(mouse) onPressed: { if(control.draggable && !Kirigami.Settings.isMobile ) control.grabToImage(function(result) { parent.Drag.imageSource = result.url }) - - startX = control.x - startY = control.y + + startX = control.x + startY = control.y control.pressed(mouse) } onReleased : { - control.x = startX + control.x = startX control.y = startY } onPressAndHold : control.pressAndHold(mouse) } + +// TapHandler +// { +// id: _tapArea +// enabled: Kirigami.Settings.isMobile +// acceptedButtons: Qt.RightButton +// onSingleTapped: control.clicked(eventPoint) +// onDoubleTapped: control.doubleClicked(eventPoint) +// onLongPressed: control.pressAndHold(eventPoint) +// } contentItem: Item {} - Item{ - id: _content - - anchors - { - fill: control - topMargin: control.topPadding - bottomMargin: control.bottomPadding - leftMargin: control.leftPadding - rightMargin: control.rightPadding - margins: control.padding - } - } - - background: Rectangle + Item + { + id: _content + + anchors + { + fill: control + topMargin: control.topPadding + bottomMargin: control.bottomPadding + leftMargin: control.leftPadding + rightMargin: control.rightPadding + margins: control.padding + } + } + + background: Rectangle { anchors { fill: control topMargin: control.topPadding bottomMargin: control.bottomPadding leftMargin: control.leftPadding rightMargin: control.rightPadding margins: control.padding - } - - Behavior on color - { - ColorAnimation - { - duration: Kirigami.Units.longDuration - } - } + } + + Behavior on color + { + ColorAnimation + { + duration: Kirigami.Units.shortDuration + } + } color: control.isCurrentItem || control.hovered ? Qt.rgba(control.Kirigami.Theme.highlightColor.r, control.Kirigami.Theme.highlightColor.g, control.Kirigami.Theme.highlightColor.b, 0.2) : control.Kirigami.Theme.backgroundColor radius: control.radius border.color: control.isCurrentItem ? control.Kirigami.Theme.highlightColor : "transparent" } } diff --git a/src/controls/private/AccountsHelper.qml b/src/controls/private/AccountsHelper.qml index 40aeaf3..d14e54e 100644 --- a/src/controls/private/AccountsHelper.qml +++ b/src/controls/private/AccountsHelper.qml @@ -1,145 +1,146 @@ 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 Maui.Dialog { - id: control - - maxHeight: 300* Maui.Style.unit - maxWidth: maxHeight - - property alias model : _syncingModel - property alias list : _syncingModel.list - - Maui.SyncDialog - { - id: _syncDialog - onAccepted: - { - control.addAccount(serverField.text, userField.text, passwordField.text); - close(); - } - } - rejectButton.visible: false - acceptButton.text: qsTr("Add account") - onAccepted: _syncDialog.open() - - Maui.BaseModel - { - id: _syncingModel - list: Maui.App.accounts - } - - Maui.Dialog - { - id: _removeDialog - - maxWidth: Maui.Style.unit * 400 - title: qsTr("Remove account?") - message: qsTr("Are you sure you want to remove this account?") - - rejectButton.text: qsTr("Delete account") - // rejectButton.visible: false - - onRejected: - { - var account = Maui.App.accounts.get(_listView.currentIndex) - console.log(account.label) - control.removeAccount(account.server, account.user) - close() - } - - - footBar.rightContent: Button - { - text: qsTr("Delete account and files") - onClicked: - { - var account = Maui.App.accounts.get(_listView.currentIndex) - control.removeAccountAndFiles(account.server, account.user) - close() - } - } - } - - Menu - { - id: _menu - - MenuItem - { - text: qsTr("Remove...") - Kirigami.Theme.textColor: Kirigami.Theme.negativeTextColor - - onTriggered: _removeDialog.open() - } - - } - - ListView - { - id: _listView - anchors.fill: parent - model: _syncingModel - delegate: Maui.ListDelegate - { - id: delegate - label: model.label - radius: Maui.Style.radiusV - Connections - { - 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: Maui.Style.iconSizes.huge - title: qsTr("No accounts yet!") - body: qsTr("Start adding new accounts to sync your files, music, contacts, images, notes, etc...") - } - - } - - function addAccount(server, user, password) - { + id: control + + maxHeight: 300* Maui.Style.unit + maxWidth: maxHeight + + property alias model : _syncingModel + property alias list : _syncingModel.list + + Maui.SyncDialog + { + id: _syncDialog + onAccepted: + { + control.addAccount(serverField.text, userField.text, passwordField.text); + close(); + } + } + rejectButton.visible: false + acceptButton.text: qsTr("Add account") + onAccepted: _syncDialog.open() + + Maui.BaseModel + { + id: _syncingModel + list: Maui.App.accounts + } + + Maui.Dialog + { + id: _removeDialog + + maxWidth: Maui.Style.unit * 400 + title: qsTr("Remove account?") + message: qsTr("Are you sure you want to remove this account?") + + rejectButton.text: qsTr("Delete account") + // rejectButton.visible: false + + onRejected: + { + var account = Maui.App.accounts.get(_listView.currentIndex) + console.log(account.label) + control.removeAccount(account.server, account.user) + close() + } + + + footBar.rightContent: Button + { + text: qsTr("Delete account and files") + onClicked: + { + var account = Maui.App.accounts.get(_listView.currentIndex) + control.removeAccountAndFiles(account.server, account.user) + close() + } + } + } + + Menu + { + id: _menu + + MenuItem + { + text: qsTr("Remove...") + Kirigami.Theme.textColor: Kirigami.Theme.negativeTextColor + + onTriggered: _removeDialog.open() + } + + } + + ListView + { + id: _listView + anchors.fill: parent + model: _syncingModel + delegate: Maui.ListDelegate + { + id: delegate + label: model.label + radius: Maui.Style.radiusV + Connections + { + 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: Maui.Style.iconSizes.huge + emoji: "qrc:/assets/dialog-information.svg" + title: qsTr("No accounts yet!") + body: qsTr("Start adding new accounts to sync your files, music, contacts, images, notes, and more...") + } + + } + + function addAccount(server, user, password) + { if(user.length) Maui.App.accounts.registerAccount({server: server, user: user, password: password}) - } - - function removeAccount(server, user) - { - if(server.length && user.length) - Maui.App.accounts.removeAccount(server, user) - } - - function removeAccountAndFiles(server, user) - { - if(server.length && user.length) - Maui.App.accounts.removeAccountAndFiles(server, user) - } + } + + function removeAccount(server, user) + { + if(server.length && user.length) + Maui.App.accounts.removeAccount(server, user) + } + + function removeAccountAndFiles(server, user) + { + if(server.length && user.length) + Maui.App.accounts.removeAccountAndFiles(server, user) + } }