Warning, /maui/mauikit-accounts/src/controls.5/AccountsDialog.qml is written in an unsupported language. File is not indexed.
0001
0002 import QtQuick 2.14
0003 import QtQuick.Controls 2.14
0004 import QtQuick.Layouts 1.3
0005
0006 import org.mauikit.controls 1.3 as Maui
0007 import org.mauikit.accounts 1.0 as MA
0008
0009 Maui.PopupPage
0010 {
0011 id: control
0012
0013 maxHeight: 350
0014 maxWidth: maxHeight
0015 // footBar.visible: false
0016 title: i18nd("mauikitaccounts","Accounts")
0017
0018 /**
0019 *
0020 */
0021 property alias model : _syncingModel
0022
0023 /**
0024 *
0025 */
0026 property alias list : _syncingModel.list
0027
0028 MA.CredentialsDialog
0029 {
0030 id: _syncDialog
0031 onAccepted:
0032 {
0033 control.addAccount(serverField.text, userField.text, passwordField.text);
0034 close();
0035 }
0036 }
0037
0038 actions: Action
0039 {
0040 text: i18nd("mauikitaccounts","Add")
0041 onTriggered: _syncDialog.open()
0042 }
0043
0044 // headBar.rightContent: ToolButton
0045 // {
0046 // icon.name: "documentinfo"
0047 // onClicked: Qt.openUrlExternally("https://mauikit.org/cloud")
0048 // }
0049
0050 Maui.InfoDialog
0051 {
0052 id: _removeDialog
0053
0054 title: i18nd("mauikitaccounts","Remove Account")
0055 message: i18nd("mauikitaccounts","Are you sure you want to remove this account?")
0056
0057 // rejectButton.text: i18nd("mauikitaccounts","Delete Account")
0058 // rejectButton.visible: false
0059
0060 onRejected:
0061 {
0062 var account = MA.Accounts.get(_listView.currentIndex)
0063 console.log(account.label)
0064 control.removeAccount(account.server, account.user)
0065 close()
0066 }
0067
0068
0069 // footBar.rightContent: Button
0070 // {
0071 // text: i18nd("mauikitaccounts","Delete Account and Files")
0072 // onClicked:
0073 // {
0074 // var account = MA.Accounts.get(_listView.currentIndex)
0075 // control.removeAccountAndFiles(account.server, account.user)
0076 // close()
0077 // }
0078 // }
0079 }
0080
0081 Menu
0082 {
0083 id: _menu
0084
0085 MenuItem
0086 {
0087 text: i18nd("mauikitaccounts","Remove...")
0088 Maui.Theme.textColor: Maui.Theme.negativeTextColor
0089
0090 onTriggered: _removeDialog.open()
0091 }
0092 }
0093
0094 stack: Maui.ListBrowser
0095 {
0096 id: _listView
0097 Layout.fillHeight: true
0098 Layout.fillWidth: true
0099
0100 model: Maui.BaseModel
0101 {
0102 id: _syncingModel
0103 list: MA.Accounts
0104 }
0105
0106 delegate: Maui.ListDelegate
0107 {
0108 id: delegate
0109 width: ListView.view.width
0110 label: model.label
0111 label2: model.server
0112
0113 radius: Maui.Style.radiusV
0114
0115 onClicked:
0116 {
0117 _listView.currentIndex = index
0118 }
0119
0120 onPressAndHold:
0121 {
0122 _listView.currentIndex = index
0123 _menu.popup()
0124 }
0125
0126 onRightClicked:
0127 {
0128 _listView.currentIndex = index
0129 _menu.popup()
0130 }
0131 }
0132
0133 Maui.Holder
0134 {
0135 visible: _listView.count == 0
0136 anchors.fill: parent
0137 isMask: true
0138 emoji: "qrc:/assets/dialog-information.svg"
0139 title: i18nd("mauikitaccounts","No accounts yet!")
0140 body: i18nd("mauikitaccounts","Start adding new accounts to sync your files, music, contacts, images, notes, etc...")
0141 }
0142 }
0143
0144 function addAccount(server, user, password)
0145 {
0146 if(user.length)
0147 MA.Accounts.registerAccount({server: server, user: user, password: password})
0148 }
0149
0150 function removeAccount(server, user)
0151 {
0152 if(server.length && user.length)
0153 MA.Accounts.removeAccount(server, user)
0154 }
0155
0156 function removeAccountAndFiles(server, user)
0157 {
0158 if(server.length && user.length)
0159 MA.Accounts.removeAccountAndFiles(server, user)
0160 }
0161 }