Debian Codegraph @

online-accounts-plugins/lib/module/qml6/ServiceItem.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
21 import SSO.OnlineAccounts 0.1
22
23 Column {
24 property var accountServiceHandle
25
26 signal applicationAdded(string applicationId)
27 signal applicationRemoved(string applicationId)
28
29 anchors.left: parent.left
30 anchors.right: parent.right
31
32 Repeater {
33 resources: AccountService {
34 id: accountService
35 objectHandle: accountServiceHandle
36 }
37
38 model: ApplicationModel {
39 service: accountService.service.id
40 }
41
42 delegate: ServiceItemBase {
43 text: model.displayName ? model.displayName : model.applicationId
44 subText: ApplicationManager.applicationInfo(model.applicationId, "unconfined").displayId
45 iconSource: model.iconName.indexOf("/") === 0 ?
46 model.iconName : "image://theme/" + model.iconName
47 checked: accountService.serviceEnabled
48 onCheckedChanged: {
49 if (checked != accountService.serviceEnabled) {
50 if (checked) {
51 applicationAdded(model.applicationId)
52 } else {
53 applicationRemoved(model.applicationId)
54 }
55 accountService.updateServiceEnabled(checked)
56 }
57 }
58 }
59 }
60 }