Changeset View
Changeset View
Standalone View
Standalone View
src/kcm/package/contents/ui/AvailableAccounts.qml
1 | /* | 1 | /* | ||
---|---|---|---|---|---|
2 | * Copyright 2019 Nicolas Fella <nicolas.fella@gmx.de> | 2 | * Copyright 2019 Nicolas Fella <nicolas.fella@gmx.de> | ||
3 | * Copyright 2020 Dan Leinir Turthra Jensen <admin@leinir.dk> | ||||
3 | * | 4 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | 5 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU Library General Public License as | 6 | * it under the terms of the GNU Library General Public License as | ||
6 | * published by the Free Software Foundation; either version 2 or | 7 | * published by the Free Software Foundation; either version 2 or | ||
7 | * (at your option) any later version. | 8 | * (at your option) any later version. | ||
8 | * | 9 | * | ||
9 | * This program is distributed in the hope that it will be useful, | 10 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU Library General Public License for more details | 13 | * GNU Library General Public License for more details | ||
13 | * | 14 | * | ||
14 | * You should have received a copy of the GNU Library General Public | 15 | * You should have received a copy of the GNU Library General Public | ||
15 | * License along with this program; if not, write to the | 16 | * License along with this program; if not, write to the | ||
16 | * Free Software Foundation, Inc., | 17 | * Free Software Foundation, Inc., | ||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
18 | */ | 19 | */ | ||
19 | 20 | | |||
20 | import QtQuick 2.7 | 21 | import QtQuick 2.7 | ||
21 | import QtQuick.Layouts 1.11 | 22 | import QtQuick.Layouts 1.11 | ||
22 | import QtQuick.Controls 2.0 as Controls | 23 | import QtQuick.Controls 2.0 as Controls | ||
23 | import org.kde.kirigami 2.4 as Kirigami | 24 | import org.kde.kirigami 2.4 as Kirigami | ||
24 | import org.kde.kaccounts 1.0 | 25 | import org.kde.kaccounts 1.2 as KAccounts | ||
25 | import org.kde.kcm 1.2 | 26 | import org.kde.kcm 1.2 | ||
26 | import Ubuntu.OnlineAccounts 0.1 as OA | | |||
27 | 27 | | |||
28 | ScrollViewKCM { | 28 | ScrollViewKCM { | ||
29 | id: root | 29 | id: root | ||
30 | title: i18n("Add new Account") | 30 | title: i18n("Add New Account") | ||
31 | 31 | | |||
32 | view: ListView { | 32 | view: ListView { | ||
33 | model: OA.ProviderModel {} | 33 | model: KAccounts.ProvidersModel {} | ||
34 | 34 | delegate: Kirigami.AbstractListItem { | |||
35 | delegate: Kirigami.BasicListItem { | 35 | id: accountDelegate | ||
36 | icon: model.iconName | 36 | width: ListView.view.width | ||
37 | label: model.displayName | 37 | enabled: model.supportsMultipleAccounts === true || model.accountsCount === 0 | ||
38 | width: parent.width | 38 | | ||
39 | 39 | contentItem: RowLayout { | |||
40 | implicitWidth: accountDelegate.ListView.view.width | ||||
41 | implicitHeight: Kirigami.Units.iconSizes.large + Kirigami.Units.smallSpacing * 2 | ||||
42 | spacing: Kirigami.Units.smallSpacing | ||||
43 | Kirigami.Icon { | ||||
44 | source: model.iconName | ||||
45 | Layout.preferredWidth: Kirigami.Units.iconSizes.large | ||||
46 | Layout.preferredHeight: Kirigami.Units.iconSizes.large | ||||
47 | Item { | ||||
48 | visible: model.accountsCount > 0 | ||||
49 | anchors { | ||||
50 | bottom: parent.bottom | ||||
51 | right: parent.right | ||||
52 | } | ||||
53 | height: parent.height / 3 | ||||
54 | width: height | ||||
55 | Rectangle { | ||||
56 | anchors.fill: parent | ||||
57 | radius: height / 2 | ||||
58 | color: Kirigami.Theme.highlightColor | ||||
59 | border { | ||||
60 | width: 1 | ||||
61 | color: Kirigami.Theme.highlightedTextColor | ||||
62 | } | ||||
63 | } | ||||
64 | Controls.Label { | ||||
65 | anchors.fill: parent | ||||
66 | horizontalAlignment: Text.AlignHCenter | ||||
67 | verticalAlignment: Text.AlignVCenter | ||||
68 | color: Kirigami.Theme.highlightedTextColor | ||||
69 | text: model.accountsCount | ||||
70 | } | ||||
71 | } | ||||
72 | } | ||||
73 | Controls.Label { | ||||
74 | Layout.fillWidth: true | ||||
75 | text: model.displayName + "\n" + model.description; | ||||
76 | } | ||||
77 | } | ||||
40 | onClicked: { | 78 | onClicked: { | ||
41 | var job = jobComponent.createObject(root, { "providerName": providerId }) | 79 | var job = jobComponent.createObject(root, { "providerName": model.name }) | ||
42 | job.start() | 80 | job.start() | ||
43 | } | 81 | } | ||
44 | } | 82 | } | ||
45 | } | 83 | } | ||
46 | 84 | | |||
47 | Component { | 85 | Component { | ||
48 | id: jobComponent | 86 | id: jobComponent | ||
49 | CreateAccountJob { | 87 | KAccounts.CreateAccountJob { | ||
50 | onFinished: kcm.pop() | 88 | onFinished: kcm.pop() | ||
51 | } | 89 | } | ||
52 | } | 90 | } | ||
53 | } | 91 | } |