Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 1 | /* |
| 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 | |
| 19 | import QtQuick 2.14 |
| 20 | import QtQuick.Layouts 1.3 |
| 21 | import QtQuick.Controls 2.14 |
| 22 | |
| 23 | import "../../constant" |
| 24 | import "../../commoncomponents" |
| 25 | |
Sébastien Blin | c75335f | 2020-08-04 20:54:02 -0400 | [diff] [blame] | 26 | Rectangle { |
| 27 | id: root |
| 28 | |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 29 | property alias text_usernameManagerEditAlias: usernameManagerEdit.text |
| 30 | property alias text_passwordManagerEditAlias: passwordManagerEdit.text |
| 31 | property alias text_accountManagerEditAlias: accountManagerEdit.text |
Sébastien Blin | c75335f | 2020-08-04 20:54:02 -0400 | [diff] [blame] | 32 | property string errorText: "" |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 33 | |
| 34 | function initializeOnShowUp() { |
| 35 | clearAllTextFields() |
| 36 | } |
| 37 | |
| 38 | function clearAllTextFields() { |
| 39 | usernameManagerEdit.clear() |
| 40 | passwordManagerEdit.clear() |
| 41 | accountManagerEdit.clear() |
Sébastien Blin | c75335f | 2020-08-04 20:54:02 -0400 | [diff] [blame] | 42 | errorText = "" |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 43 | } |
| 44 | |
Sébastien Blin | c75335f | 2020-08-04 20:54:02 -0400 | [diff] [blame] | 45 | anchors.fill: parent |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 46 | |
Sébastien Blin | c75335f | 2020-08-04 20:54:02 -0400 | [diff] [blame] | 47 | color: JamiTheme.backgroundColor |
| 48 | |
| 49 | signal leavePage |
| 50 | signal createAccount |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 51 | |
| 52 | ColumnLayout { |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 53 | spacing: 12 |
| 54 | |
Sébastien Blin | c75335f | 2020-08-04 20:54:02 -0400 | [diff] [blame] | 55 | anchors.horizontalCenter: parent.horizontalCenter |
| 56 | anchors.verticalCenter: parent.verticalCenter |
| 57 | Layout.preferredWidth: parent.width |
| 58 | Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 59 | |
Sébastien Blin | c75335f | 2020-08-04 20:54:02 -0400 | [diff] [blame] | 60 | 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 Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 84 | } |
| 85 | |
Sébastien Blin | c75335f | 2020-08-04 20:54:02 -0400 | [diff] [blame] | 86 | MaterialLineEdit { |
| 87 | id: accountManagerEdit |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 88 | |
Sébastien Blin | c75335f | 2020-08-04 20:54:02 -0400 | [diff] [blame] | 89 | 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 Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 109 | |
| 110 | selectByMouse: true |
| 111 | placeholderText: qsTr("Username") |
Sébastien Blin | c75335f | 2020-08-04 20:54:02 -0400 | [diff] [blame] | 112 | font.pointSize: 10 |
| 113 | font.kerning: true |
| 114 | |
| 115 | borderColorMode: MaterialLineEdit.NORMAL |
| 116 | |
| 117 | fieldLayoutWidth: connectBtn.width |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 118 | } |
| 119 | |
Sébastien Blin | c75335f | 2020-08-04 20:54:02 -0400 | [diff] [blame] | 120 | MaterialLineEdit { |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 121 | id: passwordManagerEdit |
| 122 | |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 123 | selectByMouse: true |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 124 | placeholderText: qsTr("Password") |
Sébastien Blin | c75335f | 2020-08-04 20:54:02 -0400 | [diff] [blame] | 125 | font.pointSize: 10 |
| 126 | font.kerning: true |
| 127 | |
| 128 | echoMode: TextInput.Password |
| 129 | |
| 130 | borderColorMode: MaterialLineEdit.NORMAL |
| 131 | |
| 132 | fieldLayoutWidth: connectBtn.width |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 133 | } |
| 134 | |
Sébastien Blin | c75335f | 2020-08-04 20:54:02 -0400 | [diff] [blame] | 135 | 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 Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 142 | |
Sébastien Blin | c75335f | 2020-08-04 20:54:02 -0400 | [diff] [blame] | 143 | 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 Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 154 | Layout.alignment: Qt.AlignHCenter |
| 155 | |
Sébastien Blin | c75335f | 2020-08-04 20:54:02 -0400 | [diff] [blame] | 156 | font.pointSize: JamiTheme.textFontSize |
| 157 | color: "red" |
| 158 | |
| 159 | height: 32 |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 160 | } |
| 161 | } |
| 162 | |
Sébastien Blin | c75335f | 2020-08-04 20:54:02 -0400 | [diff] [blame] | 163 | 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 Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 198 | } |
| 199 | } |