blob: 4ecfa093a149d064df55ca8630d18220543a2248 [file] [log] [blame]
Sébastien Blin1f915762020-08-03 13:27:42 -04001/*
2 * Copyright (C) 2020 by Savoir-faire Linux
3 * Author: Yang Wang <yang.wang@savoirfairelinux.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <https://www.gnu.org/licenses/>.
17 */
18
19import QtQuick 2.14
20import QtQuick.Layouts 1.3
21import QtQuick.Controls 2.14
22
23import "../../constant"
24import "../../commoncomponents"
25
Sébastien Blinc75335f2020-08-04 20:54:02 -040026Rectangle {
27 id: root
28
Sébastien Blin1f915762020-08-03 13:27:42 -040029 property alias text_usernameManagerEditAlias: usernameManagerEdit.text
30 property alias text_passwordManagerEditAlias: passwordManagerEdit.text
31 property alias text_accountManagerEditAlias: accountManagerEdit.text
Sébastien Blinc75335f2020-08-04 20:54:02 -040032 property string errorText: ""
Sébastien Blin1f915762020-08-03 13:27:42 -040033
34 function initializeOnShowUp() {
35 clearAllTextFields()
36 }
37
38 function clearAllTextFields() {
39 usernameManagerEdit.clear()
40 passwordManagerEdit.clear()
41 accountManagerEdit.clear()
Sébastien Blinc75335f2020-08-04 20:54:02 -040042 errorText = ""
Sébastien Blin1f915762020-08-03 13:27:42 -040043 }
44
Sébastien Blinc75335f2020-08-04 20:54:02 -040045 anchors.fill: parent
Sébastien Blin1f915762020-08-03 13:27:42 -040046
Sébastien Blinc75335f2020-08-04 20:54:02 -040047 color: JamiTheme.backgroundColor
48
49 signal leavePage
50 signal createAccount
Sébastien Blin1f915762020-08-03 13:27:42 -040051
52 ColumnLayout {
Sébastien Blin1f915762020-08-03 13:27:42 -040053 spacing: 12
54
Sébastien Blinc75335f2020-08-04 20:54:02 -040055 anchors.horizontalCenter: parent.horizontalCenter
56 anchors.verticalCenter: parent.verticalCenter
57 Layout.preferredWidth: parent.width
58 Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
Sébastien Blin1f915762020-08-03 13:27:42 -040059
Sébastien Blinc75335f2020-08-04 20:54:02 -040060 RowLayout {
61 spacing: 12
62 height: 48
63
64 Layout.fillWidth: true
65 anchors.left: connectBtn.left
66 anchors.right: connectBtn.right
67
68 Label {
69 text: qsTr("Enter URL of management server")
70 }
71
72 Label {
73 text: qsTr("Required")
74 color: "#ff1f62"
75 padding: 8
76 anchors.right: parent.right
77
78 background: Rectangle {
79 color: "#fee4e9"
80 radius: 24
81 anchors.fill: parent
82 }
83 }
Sébastien Blin1f915762020-08-03 13:27:42 -040084 }
85
Sébastien Blinc75335f2020-08-04 20:54:02 -040086 MaterialLineEdit {
87 id: accountManagerEdit
Sébastien Blin1f915762020-08-03 13:27:42 -040088
Sébastien Blinc75335f2020-08-04 20:54:02 -040089 selectByMouse: true
90 placeholderText: qsTr("Jami management server URL")
91 font.pointSize: 10
92 font.kerning: true
93
94 borderColorMode: MaterialLineEdit.NORMAL
95
96 fieldLayoutWidth: connectBtn.width
97 }
98
99 Text {
100 anchors.left: connectBtn.left
101 anchors.right: connectBtn.right
102
103 text: qsTr("Enter your organization credentials")
104 wrapMode: Text.Wrap
105 }
106
107 MaterialLineEdit {
108 id: usernameManagerEdit
Sébastien Blin1f915762020-08-03 13:27:42 -0400109
110 selectByMouse: true
111 placeholderText: qsTr("Username")
Sébastien Blinc75335f2020-08-04 20:54:02 -0400112 font.pointSize: 10
113 font.kerning: true
114
115 borderColorMode: MaterialLineEdit.NORMAL
116
117 fieldLayoutWidth: connectBtn.width
Sébastien Blin1f915762020-08-03 13:27:42 -0400118 }
119
Sébastien Blinc75335f2020-08-04 20:54:02 -0400120 MaterialLineEdit {
Sébastien Blin1f915762020-08-03 13:27:42 -0400121 id: passwordManagerEdit
122
Sébastien Blin1f915762020-08-03 13:27:42 -0400123 selectByMouse: true
Sébastien Blin1f915762020-08-03 13:27:42 -0400124 placeholderText: qsTr("Password")
Sébastien Blinc75335f2020-08-04 20:54:02 -0400125 font.pointSize: 10
126 font.kerning: true
127
128 echoMode: TextInput.Password
129
130 borderColorMode: MaterialLineEdit.NORMAL
131
132 fieldLayoutWidth: connectBtn.width
Sébastien Blin1f915762020-08-03 13:27:42 -0400133 }
134
Sébastien Blinc75335f2020-08-04 20:54:02 -0400135 MaterialButton {
136 id: connectBtn
137 text: qsTr("CONNECT")
138 enabled: accountManagerEdit.text.length !== 0
139 && usernameManagerEdit.text.length !== 0
140 && passwordManagerEdit.text.length !== 0
141 color: enabled? JamiTheme.wizardBlueButtons : JamiTheme.buttonTintedGreyInactive
Sébastien Blin1f915762020-08-03 13:27:42 -0400142
Sébastien Blinc75335f2020-08-04 20:54:02 -0400143 onClicked: {
144 errorText = ""
145 createAccount()
146 }
147 }
148
149 Label {
150 text: errorText
151
152 anchors.left: connectBtn.left
153 anchors.right: connectBtn.right
Sébastien Blin1f915762020-08-03 13:27:42 -0400154 Layout.alignment: Qt.AlignHCenter
155
Sébastien Blinc75335f2020-08-04 20:54:02 -0400156 font.pointSize: JamiTheme.textFontSize
157 color: "red"
158
159 height: 32
Sébastien Blin1f915762020-08-03 13:27:42 -0400160 }
161 }
162
Sébastien Blinc75335f2020-08-04 20:54:02 -0400163 HoverableButton {
164 id: cancelButton
165 z: 2
166
167 anchors.right: parent.right
168 anchors.top: parent.top
169
170 rightPadding: 90
171 topPadding: 90
172
173 Layout.preferredWidth: 96
174 Layout.preferredHeight: 96
175
176 backgroundColor: "transparent"
177 onEnterColor: "transparent"
178 onPressColor: "transparent"
179 onReleaseColor: "transparent"
180 onExitColor: "transparent"
181
182 buttonImageHeight: 48
183 buttonImageWidth: 48
184 source: "qrc:/images/icons/ic_close_white_24dp.png"
185 radius: 48
186 baseColor: "#7c7c7c"
187 toolTipText: qsTr("Return to welcome page")
188
189 Action {
190 enabled: parent.visible
191 shortcut: StandardKey.Cancel
192 onTriggered: leavePage()
193 }
194
195 onClicked: {
196 leavePage()
197 }
Sébastien Blin1f915762020-08-03 13:27:42 -0400198 }
199}