MauiKit Accounts

AccountsDialog.qml
1
2import QtQuick
3import QtQuick.Controls
4import QtQuick.Layouts
5
6import org.mauikit.controls as Maui
7import org.mauikit.accounts as MA
8
9/**
10 * @inherit org::mauikit::controls::PopupPage
11 * @brief A dialog listing all the available online accounts.
12 *
13 * @image html accountsdialog.png "Accounts dialog"
14 *
15 * @code
16 *
17 * @endcode
18 *
19 */
20Maui.PopupPage
21{
22 id: control
23
24 maxHeight: 350
25 maxWidth: maxHeight
26
27 title: i18nd("mauikitaccounts","Accounts")
28
29 /**
30 * @brief Alias to the MauiKit BaseModel handling the data
31 * @property MauiKit::MauiModel AccountsDialog::model
32 */
33 readonly property alias model : _syncingModel
34
35 /**
36 * @brief Alias to the list containing the data of the accounts.
37 * @property Accounts AccountsDialog::list
38 */
39 readonly property alias list : _syncingModel.list
40
42 {
43 id: _syncDialog
44 onAccepted:
45 {
46 control.addAccount(serverField.text, userField.text, passwordField.text)
47 close()
48 }
49 }
50
51 actions: Action
52 {
53 text: i18nd("mauikitaccounts","Add")
54 onTriggered: _syncDialog.open()
55 }
56
58 {
59 id: _removeDialog
60
61 title: i18nd("mauikitaccounts","Remove Account")
62 message: i18nd("mauikitaccounts","Are you sure you want to remove this account?")
63
64 standardButtons: Dialog.Ok | Dialog.Cancel
65
66 onRejected: close()
67 onAccepted:
68 {
69 var account = MA.Accounts.get(_listView.currentIndex)
70 console.log(account.label)
71 control.removeAccount(account.server, account.user)
72 close()
73 }
74 }
75
76 Maui.ContextualMenu
77 {
78 id: _menu
79
80 MenuItem
81 {
82 text: i18nd("mauikitaccounts","Remove...")
83 Maui.Theme.textColor: Maui.Theme.negativeTextColor
84
85 onTriggered: _removeDialog.open()
86 }
87 }
88
89 stack: Maui.ListBrowser
90 {
91 id: _listView
92 Layout.fillHeight: true
93 Layout.fillWidth: true
94
95 model: Maui.BaseModel
96 {
97 id: _syncingModel
98 list: MA.Accounts
99 }
100
101 delegate: Maui.ListDelegate
102 {
103 id: delegate
104 width: ListView.view.width
105 label: model.label
106 label2: model.server
107
108 radius: Maui.Style.radiusV
109
110 onClicked:
111 {
112 _listView.currentIndex = index
113 }
114
115 onPressAndHold:
116 {
117 _listView.currentIndex = index
118 _menu.show()
119 }
120
121 onRightClicked:
122 {
123 _listView.currentIndex = index
124 _menu.show()
125 }
126 }
127
128 holder.visible: _listView.count == 0
129 anchors.fill: parent
130 holder.isMask: true
131 holder.emoji: "qrc:/assets/dialog-information.svg"
132 holder.title: i18nd("mauikitaccounts","No accounts yet!")
133 holder.body: i18nd("mauikitaccounts","Start adding new accounts to sync your files, music, contacts, images, notes, etc...")
134
135 }
136
137 /**
138 * @brief Add a new account
139 * @param server the remote server address
140 * @param user the user name
141 * @param password password for the user in the remote server provided
142 */
143 function addAccount(server, user, password)
144 {
145 if(user.length)
146 MA.Accounts.registerAccount({server: server, user: user, password: password})
147 }
148
149 /**
150 * @brief Remove an account for the given user in the given server address
151 * @param server the server remote address
152 * @param user the user name
153 */
154 function removeAccount(server, user)
155 {
156 if(server.length && user.length)
157 MA.Accounts.removeAccount(server, user)
158 }
159
160 /**
161 * @brief Remove an account for the given user in the given server address, and remove all the local cached files
162 * @param server the server remote address
163 * @param user the user name
164 */
165 function removeAccountAndFiles(server, user)
166 {
167 if(server.length && user.length)
168 MA.Accounts.removeAccountAndFiles(server, user)
169 }
170}
A dialog for enetering the credentials for an online account.
QString i18nd(const char *domain, const char *text, const TYPE &arg...)
KIOCORE_EXPORT QStringList list(const QString &fileClass)
QString label(StandardShortcut id)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 22 2024 12:12:01 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.