diff --git a/src/accountview/accountview.qrc b/src/accountview/accountview.qrc index 4c99eb9b..93dcf155 100644 --- a/src/accountview/accountview.qrc +++ b/src/accountview/accountview.qrc @@ -1,19 +1,20 @@ qml/accountlist.qml qml/presenceselector.qml qml/accounts.qml qml/accountdialog.qml qml/securitylevel.qml qml/securitytip.qml + qml/deleter.qml qml/pages/basic.qml qml/pages/advanced.qml qml/pages/network.qml qml/pages/codecs.qml qml/pages/credentials.qml qml/pages/devices.qml qml/pages/security.qml qml/pages/ringtones.qml qml/pages/profiles.qml diff --git a/src/accountview/accountviewplugin.cpp b/src/accountview/accountviewplugin.cpp index 7a8b5586..afb78b1a 100644 --- a/src/accountview/accountviewplugin.cpp +++ b/src/accountview/accountviewplugin.cpp @@ -1,46 +1,47 @@ /*************************************************************************** * Copyright (C) 2017 by Bluesystems * * Author : Emmanuel Lepage Vallee * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 3 of the License, 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 General Public License * * along with this program. If not, see . * **************************************************************************/ #include "accountviewplugin.h" // Qt #include #include #include #include void JamiAccountView::registerTypes(const char *uri) { static QByteArray pageUri = QByteArray(uri)+".pages"; qmlRegisterType(QStringLiteral("qrc:/account/qml/accountlist.qml"), uri, 1, 0, "AccountList"); qmlRegisterType(QStringLiteral("qrc:/account/qml/presenceselector.qml"), uri, 1, 0, "PresenceSelector"); qmlRegisterType(QStringLiteral("qrc:/account/qml/accounts.qml"), uri, 1, 0, "Accounts"); qmlRegisterType(QStringLiteral("qrc:/account/qml/accountdialog.qml"), uri, 1, 0, "AccountDialog"); qmlRegisterType(QStringLiteral("qrc:/account/qml/securitylevel.qml"), uri, 1, 0, "SecurityLevel"); qmlRegisterType(QStringLiteral("qrc:/account/qml/securitytip.qml"), uri, 1, 0, "SecurityTip"); + qmlRegisterType(QStringLiteral("qrc:/account/qml/deleter.qml"), uri, 1, 0, "Deleter"); qmlRegisterType(QStringLiteral("qrc:/account/qml/pages/basic.qml"), pageUri, 1, 0, "Basic"); qmlRegisterType(QStringLiteral("qrc:/account/qml/pages/advanced.qml"), pageUri, 1, 0, "Advanced"); qmlRegisterType(QStringLiteral("qrc:/account/qml/pages/network.qml"), pageUri, 1, 0, "Network"); qmlRegisterType(QStringLiteral("qrc:/account/qml/pages/codecs.qml"), pageUri, 1, 0, "Codecs"); qmlRegisterType(QStringLiteral("qrc:/account/qml/pages/credentials.qml"), pageUri, 1, 0, "Credentials"); qmlRegisterType(QStringLiteral("qrc:/account/qml/pages/devices.qml"), pageUri, 1, 0, "Devices"); qmlRegisterType(QStringLiteral("qrc:/account/qml/pages/security.qml"), pageUri, 1, 0, "Security"); qmlRegisterType(QStringLiteral("qrc:/account/qml/pages/ringtones.qml"), pageUri, 1, 0, "Ringtones"); qmlRegisterType(QStringLiteral("qrc:/account/qml/pages/profiles.qml"), pageUri, 1, 0, "Profiles"); } diff --git a/src/accountview/qml/accountlist.qml b/src/accountview/qml/accountlist.qml index f334bd21..f9931fb0 100644 --- a/src/accountview/qml/accountlist.qml +++ b/src/accountview/qml/accountlist.qml @@ -1,297 +1,264 @@ /*************************************************************************** * Copyright (C) 2018 by Bluesystems * * Author : Emmanuel Lepage Vallee * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 3 of the License, 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 General Public License * * along with this program. If not, see . * **************************************************************************/ import QtQuick 2.7 import QtQuick.Layouts 1.0 import QtQuick.Controls 2.2 as Controls import org.kde.ringkde.genericutils 1.0 as GenericUtils import org.kde.ringkde.jamicontactview 1.0 as JamiContactView +import org.kde.ringkde.jamiaccountview 1.0 as JamiAccountView import org.kde.kirigami 2.2 as Kirigami import org.kde.playground.kquickitemviews 1.0 as KQuickItemViews import net.lvindustries.ringqtquick 1.0 as RingQtQuick ListView { id: accountList interactive: false height: totalHeight implicitHeight: totalHeight model: RingSession.accountModel property real totalHeight: footerItem + contentHeight + headerItem + 10 property real footerItem: 0 property real headerItem: 0 property bool enableAdd: true Component { id: accountErrorComponent RowLayout { anchors.fill: parent Image { Layout.fillHeight: true fillMode: Image.PreserveAspectFit width: parent.width sourceSize.width: 22 sourceSize.height: 22 horizontalAlignment: Image.AlignHCenter source: "image://SymbolicColorizer/:/sharedassets/outline/warning.svg" } Controls.Label { Layout.fillWidth: true Layout.fillHeight: true text: error color: Kirigami.Theme.textColor wrapMode: Text.WordWrap width: parent.width } } } Component { id: defaultAccountComponent RowLayout { Controls.CheckBox { Layout.fillHeight: true Layout.preferredWidth: Kirigami.Units.fontMetrics.height * 2 Layout.minimumWidth: Kirigami.Units.fontMetrics.height * 2 checked: obj.enabled onClicked: { obj.enabled = checked obj.performAction(RingQtQuick.Account.SAVE) } } Rectangle { height: Kirigami.Units.fontMetrics.height * 0.66 width: Kirigami.Units.fontMetrics.height * 0.66 radius: 99 color: obj.registrationState == RingQtQuick.Account.READY ? Kirigami.Theme.positiveTextColor : ( obj.registrationState == RingQtQuick.Account.TRYING ? Kirigami.Theme.neutralTextColor : Kirigami.Theme.negativeTextColor ) } Controls.Label { Layout.fillHeight: true Layout.fillWidth: true text: obj.alias } Item { Layout.fillHeight: true KQuickItemViews.DecorationAdapter { pixmap: secIcon anchors.verticalCenter: parent.verticalCenter height: (Kirigami.Units.fontMetrics.height * 2) - 6 width: (Kirigami.Units.fontMetrics.height * 2) - 6 } } // Do not cover the handle Item { width: (Kirigami.Units.fontMetrics.height * 2) } } } Component { id: errorComponent RowLayout { anchors.fill: parent Controls.CheckBox { Layout.fillHeight: true Layout.preferredWidth: Kirigami.Units.fontMetrics.height * 2 Layout.minimumWidth: Kirigami.Units.fontMetrics.height * 2 checked: obj.enabled onClicked: { obj.enabled = checked obj.performAction(RingQtQuick.Account.SAVE) } } Rectangle { height: Kirigami.Units.fontMetrics.height * 0.66 width: Kirigami.Units.fontMetrics.height * 0.66 radius: 99 color: obj.registrationState == RingQtQuick.Account.READY ? Kirigami.Theme.positiveTextColor : ( obj.registrationState == RingQtQuick.Account.TRYING ? Kirigami.Theme.neutralTextColor : Kirigami.Theme.negativeTextColor ) } ColumnLayout { Layout.fillHeight: true Layout.fillWidth: true Loader { property string error: obj.lastErrorMessage property int code: obj.lastErrorCode id: accountError Layout.minimumHeight: active ? Kirigami.Units.fontMetrics.height * 1.5 : 0 Layout.fillWidth: true active: true sourceComponent: accountErrorComponent } Controls.Label { Layout.fillHeight: true Layout.fillWidth: true text: obj.alias } } KQuickItemViews.DecorationAdapter { pixmap: secIcon anchors.verticalCenter: parent.verticalCenter height: (Kirigami.Units.fontMetrics.height * 2) - 6 width: (Kirigami.Units.fontMetrics.height * 2) - 6 } // Do not cover the handle Item { width: (Kirigami.Units.fontMetrics.height * 2) } } } - Loader { + JamiAccountView.Deleter { id: accountDeleter - property string name: "" - property var account: "" - active: false - sourceComponent: Controls.Dialog { - height: 150 - parent: applicationWindow().contentItem - x: applicationWindow().contentItem.width / 2 - width/2 - y: applicationWindow().contentItem.height / 2 - height/2 - standardButtons: Controls.Dialog.Ok | Controls.Dialog.Cancel - closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutsideParent - modal: true - title: i18n("Delete an account") - - Controls.Label { - text: i18n("
Are you sure you want to delete the account called ") - + name + i18n(".

This cannot be undone and you will lose the account permanently
") - } - - onAccepted: { - accountDeleter.active = false - RingSession.accountModel.remove(account) - RingSession.accountModel.save() - accountDeleter.account = null - } - - onRejected: { - accountDeleter.active = false - accountDeleter.account = null - } - } } delegate: Kirigami.SwipeListItem { property bool hasProblems: object.enabled && registrationState != RingQtQuick.Account.READY height: Kirigami.Units.fontMetrics.height * (hasProblems ? 3.5 : 2) width: accountList.width actions: [ Kirigami.Action { iconName: "message-news" text: i18n("Status logs") onTriggered: { object.performAction(RingQtQuick.Account.RELOAD) } }, Kirigami.Action { iconName: "document-share" text: i18n("Share") onTriggered: { //TODO } }, Kirigami.Action { iconName: "edit-delete" text: i18n("Delete") onTriggered: { - accountDeleter.name = alias - accountDeleter.account = object - accountDeleter.active = true - accountDeleter.item.open() - //applicationWindow().globalDrawer.drawerOpen = false //FIXME + accountDeleter.deleteAccount(object) } }, Kirigami.Action { iconName: "view-refresh" text: i18n("Reload") onTriggered: { object.performAction(RingQtQuick.Account.RELOAD) } } ] Loader { anchors.fill: parent property QtObject obj: object property var secIcon: securityLevelIcon sourceComponent: hasProblems ? errorComponent : defaultAccountComponent } } header: Kirigami.Heading { level: 2 text: i18n("Accounts") Component.onCompleted: { headerItem = Math.max(height, implicitHeight) } onHeightChanged: { headerItem = Math.max(height, implicitHeight) } } footer: GenericUtils.OutlineButton { id: mainArea height: enableAdd ? fontMetrics.height * 3.5 : 0 expandedHeight: fontMetrics.height * 3.5 sideMargin: 2 width: parent.width label: i18n("Add an account") topPadding: 2 visible: enableAdd onClicked: { applicationWindow().globalDrawer.drawerOpen = false ActionCollection.showWizard.trigger() } Component.onCompleted: { footerItem = Math.max(height, implicitHeight) } onHeightChanged: { footerItem = Math.max(height, implicitHeight) } } } diff --git a/src/accountview/qml/accounts.qml b/src/accountview/qml/accounts.qml index 25148257..0257f022 100644 --- a/src/accountview/qml/accounts.qml +++ b/src/accountview/qml/accounts.qml @@ -1,179 +1,186 @@ /*************************************************************************** * Copyright (C) 2017 by Bluesystems * * Author : Emmanuel Lepage Vallee * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 3 of the License, 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 General Public License * * along with this program. If not, see . * **************************************************************************/ import QtQuick 2.8 import org.kde.kirigami 2.5 as Kirigami -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.2 as Controls import QtQuick.Layouts 1.0 import org.kde.playground.kquickitemviews 1.0 as KQuickItemViews import net.lvindustries.ringqtquick 1.0 as RingQtQuick +import org.kde.ringkde.jamiaccountview 1.0 as JamiAccountView import org.kde.ringkde.genericutils 1.0 as GenericUtils ListView { id: accountList property QtObject selectedAccount: null spacing : 10 model: RingSession.profileModel delegate: codecDelegate + JamiAccountView.Deleter { + id: deleter + } + Component { id: codecDelegate Kirigami.Card { id: card x: 5 width: accountList.width - 10 height: content.height + 20 implicitHeight: content.height + 20 property var pModel : RingSession.profileModel.profilesForPerson(model.object) ColumnLayout { id: content height: implicitHeight width: parent.width Kirigami.Heading { text: model.display level:4 } ListView { id: profileList interactive: false model: pModel implicitHeight: contentHeight height: contentHeight width: parent.width delegate: Kirigami.SwipeListItem { id: listItem width: card.width background: Rectangle { id: background property var listItem: parent color: listItem.checked || listItem.highlighted || ( listItem.supportsMouseEvents && listItem.pressed && !listItem.checked && !listItem.sectionDelegate ) ? listItem.activeBackgroundColor : listItem.backgroundColor visible: listItem.ListView.view ? listItem.ListView.view.highlight === null : true Rectangle { id: internal property bool indicateActiveFocus: listItem.pressed || listItem.activeFocus || (listItem.ListView.view ? listItem.ListView.view.activeFocus : false) anchors.fill: parent visible: !listItem.supportsMouseEvents color: listItem.activeBackgroundColor opacity: (listItem.hovered || listItem.highlighted || listItem.activeFocus) && !listItem.pressed ? 0.5 : 0 Behavior on opacity { NumberAnimation { duration: Kirigami.Units.longDuration } } } Rectangle { opacity: 0.9 anchors.fill: parent color: object == accountList.selectedAccount ? Kirigami.Theme.highlightColor : registrationStateColor } KQuickItemViews.DecorationAdapter { width: check.implicitHeight height: check.implicitHeight anchors.right: parent.right anchors.verticalCenter: parent.verticalCenter pixmap: securityLevelIcon } readonly property bool __separatorVisible: listItem.separatorVisible on__SeparatorVisibleChanged: { if (__separatorVisible) { var newObject = Qt.createQmlObject('import QtQuick 2.0; import org.kde.kirigami 2.4; Separator {anchors {left: parent.left; right: parent.right; bottom: parent.top} visible: listItem.separatorVisible}', background); newObject = Qt.createQmlObject('import QtQuick 2.0; import org.kde.kirigami 2.4; Separator {anchors {left: parent.left; right: parent.right; bottom: parent.bottom} visible: listItem.separatorVisible}', background); } } } RowLayout { width: parent.width height: check.implicitHeight*2 - CheckBox { + Controls.CheckBox { id: check width: height checked: model.enabled } KQuickItemViews.DecorationAdapter { height: check.implicitHeight width: check.implicitHeight pixmap: decoration } - Label { + Controls.Label { text: alias Layout.fillWidth: true } } actions: [ Kirigami.Action { text: i18n("Remove") iconName: "list-remove" - onTriggered: {} + onTriggered: { + deleter.deleteAccount(object) + } } ] onPressedChanged: { //TODO add a popup if (accountList.selectedAccount) { accountList.selectedAccount.performAction( RingQtQuick.Account.CANCEL ) } accountList.selectedAccount = object } } } } } } RingQtQuick.AccountBuilder { id: accountBuilder } footer: GenericUtils.OutlineButtons { function callback(index) { selectedAccount = accountBuilder.buildFor(index) } width: accountList.width rows: 2 padding: 5 model: accountBuilder action: callback } Component.onCompleted: { accountList.selectedAccount = RingSession.availableAccountModel.currentDefaultAccount() } }