MauiKit Accounts

CredentialsDialog.qml
1/*
2 * Copyright 2018 Camilo Higuita <milo.h@aol.com>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Library General Public License as
6 * published by the Free Software Foundation; either version 2, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details
13 *
14 * You should have received a copy of the GNU Library General Public
15 * License along with this program; if not, write to the
16 * Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 */
19
20import QtQuick
21import QtQuick.Controls
22import QtQuick.Layouts
23import org.mauikit.controls as Maui
24
25/**
26 * @inherit org::mauikit::control::PopupPage
27 * @brief A dialog for enetering the credentials for an online account.
28 *
29 * @image html credentialsdialog.png "Accounts dialog"
30 *
31 * @code
32 *
33 * @endcode
34 */
35Maui.PopupPage
36{
37 id: control
38
39 maxWidth: 350
41 title: i18nd("mauikitaccounts","New Account")
42
43 /**
44 * @brief customServer : bool
45 */
46 property bool customServer: false
47
48 /**
49 * @brief serverField : TextField
50 */
51 readonly property alias serverField: _serverField
52
53 /**
54 * userField : TextField
55 */
56 readonly property alias userField: _userField
57
58 /**
59 * passwordField : TextField
60 */
61 readonly property alias passwordField: _passwordField
62
63 signal accepted()
64
65 actions: [
66 Action
67 {
68 text: i18nd("mauikitaccounts","Sign up")
69 enabled: !customServer
70 onTriggered: Qt.openUrlExternally("https://www.opendesktop.org/register")
71 },
72
73 Action
74 {
75 text: i18nd("mauikitaccounts","Sign in")
76 onTriggered: control.accepted()
77 }
78 ]
79
80 Loader
81 {
82 asynchronous: true
83 active: !customServer
84
85 Layout.alignment: Qt.AlignCenter
86 Layout.preferredWidth: Maui.Style.iconSizes.huge
87 Layout.preferredHeight: Maui.Style.iconSizes.huge
88 Layout.margins: Maui.Style.space.medium
89
90 sourceComponent: Image
91 {
92 sourceSize.width: width
93 sourceSize.height: height
94
95 source: "qrc:/assets/opendesktop.png"
96 }
97 }
98
99 Label
100 {
101 visible: !customServer
102 Layout.fillWidth: true
103 horizontalAlignment: Qt.AlignHCenter
104 Layout.preferredHeight: Maui.Style.rowHeight
105 text: "opendesktop.org"
106 elide: Text.ElideNone
107 wrapMode: Text.NoWrap
108 font.weight: Font.Bold
109 font.bold: true
110 font.pointSize: Maui.Style.fontSizes.big
111 }
112
113 Maui.TextField
114 {
115 id: _userField
116 Layout.fillWidth: true
117 placeholderText: i18nd("mauikitaccounts","Username")
118 icon.source: "im-user"
119 inputMethodHints: Qt.ImhNoAutoUppercase | Qt.ImhSensitiveData
120 }
121
123 {
124 id: _passwordField
125 Layout.fillWidth: true
126 placeholderText: i18nd("mauikitaccounts","Password")
127 }
128
129 Maui.TextField
130 {
131 id: _serverField
132 visible: customServer
133 icon.source: "link"
134 Layout.fillWidth: true
135 placeholderText: i18nd("mauikitaccounts","Server address")
136 inputMethodHints: Qt.ImhUrlCharactersOnly | Qt.ImhNoAutoUppercase
137 text: customServer ? "" : "https://cloud.opendesktop.cc/cloud/remote.php/webdav/"
138 }
139
140 Button
141 {
142 Layout.fillWidth: true
143 icon.name: "filename-space-amarok"
144 text: customServer ? i18nd("mauikitaccounts","opendesktop") : i18nd("mauikitaccounts","Custom server")
145 onClicked: customServer = !customServer
146 }
147}
QString i18nd(const char *domain, const char *text, const TYPE &arg...)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 29 2024 11:58:27 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.