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