Changeset View
Standalone View
src/kcm/package/contents/ui/Accounts.qml
Show All 20 Lines | |||||
21 | 21 | | |||
22 | 22 | | |||
23 | import QtQuick 2.7 | 23 | import QtQuick 2.7 | ||
24 | import QtQuick.Layouts 1.11 | 24 | import QtQuick.Layouts 1.11 | ||
25 | import QtQuick.Controls 2.0 as Controls | 25 | import QtQuick.Controls 2.0 as Controls | ||
26 | 26 | | |||
27 | import org.kde.kirigami 2.7 as Kirigami | 27 | import org.kde.kirigami 2.7 as Kirigami | ||
28 | 28 | | |||
29 | import org.kde.kaccounts 1.0 | 29 | import org.kde.kaccounts 1.2 as KAccounts | ||
30 | import org.kde.kcm 1.2 | 30 | import org.kde.kcm 1.2 | ||
31 | 31 | | |||
32 | import Ubuntu.OnlineAccounts 0.1 as OA | | |||
33 | | ||||
34 | ScrollViewKCM { | 32 | ScrollViewKCM { | ||
35 | id: kaccountsRoot | 33 | id: kaccountsRoot | ||
36 | 34 | | |||
37 | // Existing accounts | 35 | // Existing accounts | ||
38 | view: ListView { | 36 | view: ListView { | ||
39 | model: OA.AccountServiceModel { | 37 | model: KAccounts.AccountsModel { } | ||
40 | id: accountsModel | | |||
41 | service: "global" | | |||
42 | includeDisabled: true | | |||
43 | } | | |||
44 | 38 | | |||
45 | delegate: Kirigami.SwipeListItem { | 39 | delegate: Kirigami.SwipeListItem { | ||
46 | id: accountDelegate | 40 | id: accountDelegate | ||
47 | width: ListView.view.width | 41 | width: ListView.view.width | ||
48 | 42 | | |||
49 | contentItem: Controls.Label { | 43 | contentItem: RowLayout { | ||
44 | implicitWidth: accountDelegate.ListView.view.width | ||||
45 | implicitHeight: Kirigami.Units.iconSizes.large + Kirigami.Units.smallSpacing * 2 | ||||
46 | spacing: Kirigami.Units.smallSpacing | ||||
47 | Kirigami.Icon { | ||||
48 | source: model.iconName | ||||
49 | Layout.preferredWidth: Kirigami.Units.iconSizes.large | ||||
nicolasfella: IMO large is too large, but it should use whatever comes out of T12789 | |||||
Yeah, this wants a central decision before just sort of... picking another one :) For now i'm thinking internal consistency is better, since there's no general consensus (yet!) - once there is, it's an easy fix :) leinir: Yeah, this wants a central decision before just sort of... picking another one :) For now i'm… | |||||
50 | Layout.preferredHeight: Kirigami.Units.iconSizes.large | ||||
Here you are essentially recreating Kirigami.BasicListItem. I guess you have to because of the SwipeListItem, but maybe that's something that should be addressed in Kirigami nicolasfella: Here you are essentially recreating Kirigami.BasicListItem. I guess you have to because of the… | |||||
Pretty much that, yes - and definitely wants doing in Kirigami (not sure if BasicSwipeListItem wants to happen, or if it just needs to be in SwipeListItem... thinking the former, as the latter might just well end up being a bit heavy, carrying about those objects that would end up replaced by a lot of apps anyway, in what is already a heavy component...) leinir: Pretty much that, yes - and definitely wants doing in Kirigami (not sure if BasicSwipeListItem… | |||||
51 | } | ||||
52 | Controls.Label { | ||||
53 | Layout.fillWidth: true | ||||
50 | text: { | 54 | text: { | ||
51 | if (model.displayName.length > 0 && model.providerName.length > 0) { | 55 | if (model.displayName.length > 0 && model.providerName.length > 0) { | ||
52 | return i18n("%1 (%2)", model.displayName, model.providerName) | 56 | return i18n("%1 (%2)", model.displayName, model.providerName) | ||
53 | } else if (model.displayName.length > 0) { | 57 | } else if (model.displayName.length > 0) { | ||
54 | return model.displayName | 58 | return model.displayName | ||
55 | } else { | 59 | } else { | ||
56 | return i18n("%1 account", model.providerName) | 60 | return i18n("%1 account", model.providerName) | ||
57 | } | 61 | } | ||
58 | } | 62 | } | ||
59 | | ||||
60 | OA.Account { | | |||
61 | id: account | | |||
62 | objectHandle: model.accountHandle | | |||
63 | } | 63 | } | ||
64 | } | 64 | } | ||
65 | actions: [ | 65 | actions: [ | ||
66 | Kirigami.Action { | 66 | Kirigami.Action { | ||
67 | text: i18nc("Tooltip for an action which will offer the user to remove the mentioned account", "Remove %1", accountDelegate.contentItem.text) | 67 | text: i18nc("Tooltip for an action which will offer the user to remove the mentioned account", "Remove %1", accountDelegate.contentItem.text) | ||
68 | iconName: "edit-delete-remove" | 68 | iconName: "edit-delete-remove" | ||
69 | onTriggered: { | 69 | onTriggered: { | ||
70 | accountRemovalDlg.account = account; | 70 | accountRemovalDlg.accountId = model.id; | ||
71 | accountRemovalDlg.displayName = model.displayName; | 71 | accountRemovalDlg.displayName = model.displayName; | ||
72 | accountRemovalDlg.providerName = model.providerName; | 72 | accountRemovalDlg.providerName = model.providerName; | ||
73 | accountRemovalDlg.open(); | 73 | accountRemovalDlg.open(); | ||
74 | } | 74 | } | ||
75 | } | 75 | } | ||
76 | ] | 76 | ] | ||
77 | onClicked: kcm.push("AvailableServices.qml", {accountId: model.accountId}) | 77 | onClicked: kcm.push("AccountDetails.qml", {model: model.services}) | ||
78 | } | 78 | } | ||
79 | Controls.Label { | 79 | Controls.Label { | ||
80 | anchors { | 80 | visible: view.count === 0 | ||
81 | fill: parent | 81 | anchors.fill: parent | ||
82 | margins: Kirigami.Units.largeSpacing | 82 | clip: true | ||
83 | } | | |||
84 | verticalAlignment: Text.AlignVCenter | | |||
85 | horizontalAlignment: Text.AlignHCenter | 83 | horizontalAlignment: Text.AlignHCenter | ||
84 | verticalAlignment: Text.AlignVCenter | ||||
86 | wrapMode: Text.Wrap | 85 | wrapMode: Text.Wrap | ||
87 | visible: parent.count === 0 | 86 | textFormat: Text.RichText | ||
88 | opacity: 0.5 | 87 | text: i18nc("A text shown when a user has not yet added any accounts", "You have not added any accounts yet.<br /><br />Click on <a href=\"add-new-account\">\"Add New Account...\"</a> to do so.") | ||
89 | text: i18nc("A text shown when a user has not yet added any accounts", "You have not added any accounts yet.\nClick the \"Add new Account\" button below to do so.") | 88 | onLinkActivated: kcm.push("AvailableAccounts.qml") | ||
90 | } | 89 | } | ||
91 | } | 90 | } | ||
91 | | ||||
92 | MessageBoxSheet { | 92 | MessageBoxSheet { | ||
This code is effectively duplicated between two files. It would probably be better to move it into a separate "RemoveAccountDialog" or so. ahiemstra: This code is effectively duplicated between two files. It would probably be better to move it… | |||||
Thanks for the reminder, yeah, i wanted to do that before and kind of... just forgot, i guess :) leinir: Thanks for the reminder, yeah, i wanted to do that before and kind of... just forgot, i guess :) | |||||
93 | id: accountRemovalDlg | 93 | id: accountRemovalDlg | ||
94 | parent: kaccountsRoot | 94 | parent: kaccountsRoot | ||
95 | property QtObject account | 95 | property int accountId | ||
96 | property string displayName | 96 | property string displayName | ||
97 | property string providerName | 97 | property string providerName | ||
98 | title: i18nc("The title for a dialog which lets you remove an account", "Remove Account?") | 98 | title: i18nc("The title for a dialog which lets you remove an account", "Remove Account?") | ||
99 | text: { | 99 | text: { | ||
100 | if (accountRemovalDlg.displayName.length > 0 && accountRemovalDlg.providerName.length > 0) { | 100 | if (accountRemovalDlg.displayName.length > 0 && accountRemovalDlg.providerName.length > 0) { | ||
101 | return i18nc("The text for a dialog which lets you remove an account when both provider name and account name are available", "Are you sure you wish to remove the \"%1\" account \"%2\"?", accountRemovalDlg.providerName, accountRemovalDlg.displayName) | 101 | return i18nc("The text for a dialog which lets you remove an account when both provider name and account name are available", "Are you sure you wish to remove the \"%1\" account \"%2\"?", accountRemovalDlg.providerName, accountRemovalDlg.displayName) | ||
102 | } else if (accountRemovalDlg.displayName.length > 0) { | 102 | } else if (accountRemovalDlg.displayName.length > 0) { | ||
103 | return i18nc("The text for a dialog which lets you remove an account when only the account name is available", "Are you sure you wish to remove the account \"%1\"?", accountRemovalDlg.displayName) | 103 | return i18nc("The text for a dialog which lets you remove an account when only the account name is available", "Are you sure you wish to remove the account \"%1\"?", accountRemovalDlg.displayName) | ||
104 | } else { | 104 | } else { | ||
105 | return i18nc("The text for a dialog which lets you remove an account when only the provider name is available", "Are you sure you wish to remove this \"%1\" account?", accountRemovalDlg.providerName) | 105 | return i18nc("The text for a dialog which lets you remove an account when only the provider name is available", "Are you sure you wish to remove this \"%1\" account?", accountRemovalDlg.providerName) | ||
106 | } | 106 | } | ||
107 | } | 107 | } | ||
108 | actions: [ | 108 | actions: [ | ||
109 | Kirigami.Action { | 109 | Kirigami.Action { | ||
110 | text: i18nc("The label for a button which will cause the removal of a specified account", "Remove Account") | 110 | text: i18nc("The label for a button which will cause the removal of a specified account", "Remove Account") | ||
111 | onTriggered: { accountRemovalDlg.account.remove(); } | 111 | onTriggered: { | ||
112 | var job = accountRemovalJob.createObject(kaccountsRoot, { "accountId": accountRemovalDlg.accountId }); | ||||
113 | job.start(); | ||||
114 | } | ||||
112 | } | 115 | } | ||
113 | ] | 116 | ] | ||
114 | } | 117 | } | ||
115 | 118 | | |||
119 | Component { | ||||
120 | id: accountRemovalJob | ||||
121 | KAccounts.RemoveAccountJob { } | ||||
122 | } | ||||
123 | | ||||
116 | footer: RowLayout { | 124 | footer: RowLayout { | ||
117 | Controls.Button { | 125 | Controls.Button { | ||
118 | Layout.alignment: Qt.AlignRight | 126 | Layout.alignment: Qt.AlignRight | ||
119 | text: i18n("Add new Account") | 127 | text: i18n("Add New Account...") | ||
120 | icon.name: "contact-new" | 128 | icon.name: "contact-new" | ||
121 | onClicked: kcm.push("AvailableAccounts.qml") | 129 | onClicked: kcm.push("AvailableAccounts.qml") | ||
122 | } | 130 | } | ||
123 | } | 131 | } | ||
124 | } | 132 | } |
IMO large is too large, but it should use whatever comes out of T12789