Debian Codegraph @

online-accounts-ui/src/qml5/AuthorizationPage.qml

raw
1 /*
2 * Copyright (C) 2013-2015 Canonical Ltd.
3 *
4 * Contact: Alberto Mardegan <[email protected]>
5 *
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 3, as published
8 * by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranties of
12 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
13 * PURPOSE. See the GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19 import QtQuick 2.9
20 import Lomiri.Components 1.3
21 import Lomiri.Components.ListItems 1.3 as ListItem
22
23 Flickable {
24 id: root
25
26 property var model
27 property var application
28 property var provider
29 property bool canAddAnotherAccount: true
30
31 signal allowed(int accountId)
32 signal denied
33 signal createAccount
34
35 anchors.fill: parent
36 contentHeight: bottomColumn.y + bottomColumn.height + bottomColumn.anchors.margins
37
38 Column {
39 id: topColumn
40 anchors.left: parent.left
41 anchors.right: parent.right
42 anchors.top: parent.top
43 anchors.margins: units.gu(1)
44 spacing: units.gu(1)
45
46 ProportionalShape {
47 id: iconShape
48 anchors.horizontalCenter: parent.horizontalCenter
49 aspect: LomiriShape.DropShadow
50 width: units.gu(8)
51 source: Image {
52 sourceSize.width: iconShape.width
53 sourceSize.height: iconShape.height
54 source: application.icon.indexOf("/") === 0 ?
55 "file://" + application.icon : "image://theme/" + application.icon
56 }
57 }
58
59 Column {
60 anchors { left: parent.left; right: parent.right; margins: units.gu(1) }
61
62 Label {
63 objectName: "appLabel"
64 anchors.left: parent.left
65 anchors.right: parent.right
66 horizontalAlignment: Text.AlignHCenter
67 elide: Text.ElideRight
68 text: application.displayName
69 wrapMode: Text.Wrap
70 maximumLineCount: 2
71 }
72 Label {
73 objectName: "pkgLabel"
74 anchors.left: parent.left
75 anchors.right: parent.right
76 horizontalAlignment: Text.AlignHCenter
77 color: theme.palette.normal.backgroundText
78 elide: Text.ElideMiddle
79 text: application.displayId
80 }
81 }
82
83 Label {
84 objectName: "msgLabel"
85 anchors.left: parent.left
86 anchors.right: parent.right
87 text: i18n.tr("wants to access your %2 account").
88 arg(provider.displayName);
89 wrapMode: Text.WordWrap
90 horizontalAlignment: Text.AlignHCenter
91 }
92
93 Label {
94 id: accountLabel
95 objectName: "accountLabel"
96 anchors.left: parent.left
97 anchors.right: parent.right
98 visible: model.count == 1
99 horizontalAlignment: Text.AlignHCenter
100 text: model.get(0, "displayName")
101 }
102
103 OptionSelector {
104 id: accountSelector
105 objectName: "accountSelector"
106 anchors.left: parent.left
107 anchors.right: parent.right
108 anchors.leftMargin: units.gu(1)
109 anchors.rightMargin: units.gu(1)
110 visible: !accountLabel.visible
111 model: root.model
112 delegate: OptionSelectorDelegate {
113 property string modelData: model.displayName
114 }
115 }
116 }
117
118 Column {
119 id: bottomColumn
120 anchors.top: topColumn.bottom
121 anchors.margins: units.gu(2)
122 anchors.left: parent.left
123 anchors.right: parent.right
124 spacing: units.gu(1)
125
126 Button {
127 objectName: "allowButton"
128 anchors.left: parent.left
129 anchors.right: parent.right
130 color: theme.palette.normal.positive
131 text: i18n.tr("Allow")
132 onClicked: root.allowed(root.model.get(accountSelector.selectedIndex, "accountId"))
133 }
134
135 Button {
136 objectName: "addAnotherButton"
137 anchors.left: parent.left
138 anchors.right: parent.right
139 visible: canAddAnotherAccount
140 text: i18n.tr("Add another account…")
141 onClicked: root.createAccount()
142 }
143
144 Button {
145 objectName: "denyButton"
146 anchors.left: parent.left
147 anchors.right: parent.right
148 text: i18n.tr("Don't allow")
149 onClicked: root.denied()
150 }
151 }
152 }