Warning, /network/tokodon/src/content/ui/Settings/AccountsPage.qml is written in an unsupported language. File is not indexed.

0001 // SPDX-FileCopyrightText: 2020 Tobias Fella <fella@posteo.de>
0002 // SPDX-FileCopyrightText: 2022 Carl Schwan <carl@carlschwan.eu>
0003 // SPDX-License-Identifier: GPL-2.0-or-later
0004 
0005 pragma ComponentBehavior: Bound
0006 
0007 import QtQuick
0008 import QtQuick.Controls 2 as QQC2
0009 import QtQuick.Layouts
0010 
0011 import org.kde.kirigami 2 as Kirigami
0012 import org.kde.kirigamiaddons.formcard 1 as FormCard
0013 import org.kde.kirigamiaddons.components 1 as KirigamiComponents
0014 
0015 import org.kde.tokodon
0016 
0017 FormCard.FormCardPage {
0018     id: root
0019 
0020     FormCard.FormCard {
0021         id: accountsCard
0022 
0023         Layout.topMargin: Kirigami.Units.largeSpacing
0024 
0025         Repeater {
0026             model: AccountManager
0027             delegate: FormCard.AbstractFormDelegate {
0028                 id: delegate
0029 
0030                 required property var account
0031                 required property string description
0032                 required property string displayName
0033 
0034                 Layout.fillWidth: true
0035                 onClicked: applicationWindow().pageStack.layers.push("./ProfileEditor.qml", {
0036                     account: delegate.account
0037                 })
0038 
0039                 contentItem: RowLayout {
0040                     KirigamiComponents.Avatar {
0041                         source: delegate.account.identity.avatarUrl
0042                         name: delegate.displayName
0043                         Layout.rightMargin: Kirigami.Units.largeSpacing
0044                         implicitWidth: Kirigami.Units.iconSizes.medium
0045                         implicitHeight: Kirigami.Units.iconSizes.medium
0046                     }
0047 
0048                     ColumnLayout {
0049                         Layout.fillWidth: true
0050                         spacing: Kirigami.Units.smallSpacing
0051 
0052                         QQC2.Label {
0053                             Layout.fillWidth: true
0054                             text: delegate.displayName
0055                             textFormat: Text.RichText
0056                             elide: Text.ElideRight
0057                             wrapMode: Text.Wrap
0058                             maximumLineCount: 2
0059                             color: Kirigami.Theme.textColor
0060                         }
0061 
0062                         QQC2.Label {
0063                             Layout.fillWidth: true
0064                             text: `${delegate.description} (${delegate.account.instanceName})`
0065                             color: Kirigami.Theme.disabledTextColor
0066                             font: Kirigami.Theme.smallFont
0067                             elide: Text.ElideRight
0068                         }
0069                     }
0070 
0071                     QQC2.ToolButton {
0072                         text: i18n("Logout")
0073                         icon.name: "im-kick-user"
0074 
0075                         Kirigami.PromptDialog {
0076                             id: logoutPrompt
0077 
0078                             title: i18nc("@title", "Logout")
0079                             subtitle: i18nc("@label", "Are you sure you want to log out of %1?", delegate.displayName)
0080                             standardButtons: Kirigami.Dialog.Ok | Kirigami.Dialog.Cancel
0081                             showCloseButton: false
0082 
0083                             onAccepted: {
0084                                 AccountManager.removeAccount(delegate.account);
0085                                 if (!AccountManager.hasAccounts) {
0086                                     root.Window.window.close();
0087                                 }
0088                             }
0089                         }
0090 
0091                         onClicked: logoutPrompt.open();
0092                     }
0093 
0094                     FormCard.FormArrow {
0095                         Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
0096                         direction: Qt.RightArrow
0097                     }
0098                 }
0099             }
0100         }
0101 
0102         FormCard.FormDelegateSeparator {
0103             below: addAccountDelegate
0104         }
0105 
0106         FormCard.FormButtonDelegate {
0107             id: addAccountDelegate
0108             text: i18n("Add Account")
0109             icon.name: "list-add"
0110             onClicked: pageStack.pushDialogLayer(Qt.createComponent("org.kde.tokodon", "WelcomePage"))
0111         }
0112     }
0113 }