Warning, /network/kaccounts-integration/src/kcm/ui/main.qml is written in an unsupported language. File is not indexed.

0001 /*
0002  *   SPDX-FileCopyrightText: 2015 Martin Klapetek <mklapetek@kde.org>
0003  *   SPDX-FileCopyrightText: 2020 Dan Leinir Turthra Jensen <admin@leinir.dk>
0004  *
0005  *   SPDX-License-Identifier: LGPL-2.0-or-later
0006  */
0007 
0008 import QtQuick
0009 import QtQuick.Controls as Controls
0010 import QtQuick.Layouts
0011 
0012 import org.kde.kirigami as Kirigami
0013 import org.kde.kcmutils as KCM
0014 
0015 import org.kde.kaccounts as KAccounts
0016 
0017 KCM.ScrollViewKCM {
0018     id: kaccountsRoot
0019 
0020     implicitHeight: Kirigami.Units.gridUnit * 28
0021     implicitWidth: Kirigami.Units.gridUnit * 28
0022 
0023     // Existing accounts
0024     view: ListView {
0025 
0026         clip: true
0027 
0028         model: KAccounts.AccountsModel { }
0029 
0030         delegate: Kirigami.SwipeListItem {
0031             id: delegate
0032             width: ListView.view.width
0033 
0034             contentItem: Kirigami.IconTitleSubtitle {
0035                 Layout.fillWidth: true
0036 
0037                 icon.name: model.iconName
0038                 title: {
0039                     if (model.displayName.length > 0 && model.providerName.length > 0) {
0040                         return i18nd("kaccounts-integration", "%1 (%2)", model.displayName, model.providerDisplayName)
0041                     } else if (model.displayName.length > 0) {
0042                         return model.displayName
0043                     } else {
0044                         return i18nd("kaccounts-integration", "%1 account", model.providerName)
0045                     }
0046                 }
0047                 selected: delegate.highlighted
0048                 font: delegate.font
0049             }
0050 
0051             actions: [
0052                 Kirigami.Action {
0053                     text: i18ndc("kaccounts-integration", "Tooltip for an action which will offer the user to remove the mentioned account", "Remove %1", delegate.contentItem.text)
0054                     icon.name: "edit-delete-remove"
0055                     onTriggered: {
0056                         accountRemover.accountId = model.id;
0057                         accountRemover.displayName = model.displayName;
0058                         accountRemover.providerName = model.providerName;
0059                         accountRemover.open();
0060                     }
0061                 }
0062             ]
0063             onClicked: kcm.push("AccountDetails.qml", {model: model.services})
0064         }
0065 
0066         Kirigami.PlaceholderMessage {
0067             visible: view.count === 0
0068             anchors.centerIn: parent
0069             width: parent.width - (Kirigami.Units.largeSpacing * 4)
0070             text: i18ndc("kaccounts-integration", "A text shown when a user has not yet added any accounts", "No accounts added yet")
0071             explanation: xi18ndc("kaccounts-integration", "@info", "Click the <interface>Add New Account...</interface> button below to add one")
0072         }
0073     }
0074 
0075     RemoveAccountDialog {
0076         id: accountRemover
0077         parent: kaccountsRoot
0078     }
0079 
0080     footer: RowLayout {
0081         Controls.Button {
0082             Layout.alignment: Qt.AlignRight
0083             text: i18nd("kaccounts-integration", "Add New Account...")
0084             icon.name: "contact-new"
0085             onClicked: kcm.push("AvailableAccounts.qml")
0086         }
0087     }
0088 }