Sébastien Blin | c75335f | 2020-08-04 20:54:02 -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 | |
| 26 | Rectangle { |
| 27 | id: root |
| 28 | |
| 29 | function initializeOnShowUp() { |
| 30 | clearAllTextFields() |
| 31 | boothImgBase64 = "" |
| 32 | readyToSaveDetails = false |
| 33 | } |
| 34 | |
| 35 | function clearAllTextFields() { |
| 36 | aliasEdit.clear() |
| 37 | } |
| 38 | |
| 39 | anchors.fill: parent |
| 40 | |
| 41 | color: JamiTheme.backgroundColor |
| 42 | |
| 43 | signal leavePage |
| 44 | signal saveProfile |
| 45 | |
| 46 | property var readyToSaveDetails: false |
| 47 | property var showBottom: false |
| 48 | property alias boothImgBase64: setAvatarWidget.imgBase64 |
| 49 | property alias displayName: aliasEdit.text |
| 50 | |
| 51 | ColumnLayout { |
| 52 | spacing: 12 |
| 53 | |
| 54 | anchors.horizontalCenter: parent.horizontalCenter |
| 55 | anchors.verticalCenter: parent.verticalCenter |
| 56 | Layout.preferredWidth: parent.width |
| 57 | Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter |
| 58 | |
| 59 | |
| 60 | RowLayout { |
| 61 | spacing: 12 |
| 62 | height: 48 |
| 63 | |
| 64 | Layout.preferredWidth: saveProfileBtn.width |
| 65 | |
| 66 | Label { |
| 67 | text: qsTr("Profile is only shared with contacts") |
| 68 | |
| 69 | font.pointSize: JamiTheme.textFontSize + 3 |
| 70 | } |
| 71 | |
| 72 | Label { |
| 73 | text: qsTr("Optional") |
| 74 | color: "white" |
| 75 | Layout.alignment: Qt.AlignRight |
| 76 | padding: 8 |
| 77 | |
| 78 | background: Rectangle { |
| 79 | color: "#28b1ed" |
| 80 | radius: 24 |
| 81 | anchors.fill: parent |
| 82 | } |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | PhotoboothView { |
| 87 | id: setAvatarWidget |
| 88 | |
| 89 | Layout.alignment: Qt.AlignHCenter |
| 90 | |
| 91 | Layout.maximumWidth: 256 |
| 92 | Layout.preferredWidth: 256 |
| 93 | Layout.minimumWidth: 256 |
| 94 | Layout.maximumHeight: 256 |
| 95 | Layout.preferredHeight: 256 |
| 96 | Layout.minimumHeight: 256 |
| 97 | } |
| 98 | |
| 99 | MaterialLineEdit { |
| 100 | id: aliasEdit |
| 101 | |
| 102 | selectByMouse: true |
| 103 | placeholderText: qsTr("Enter your name") |
| 104 | font.pointSize: 10 |
| 105 | font.kerning: true |
| 106 | |
| 107 | borderColorMode: MaterialLineEdit.NORMAL |
| 108 | |
| 109 | fieldLayoutWidth: saveProfileBtn.width |
| 110 | } |
| 111 | |
| 112 | MaterialButton { |
| 113 | id: saveProfileBtn |
| 114 | enabled: readyToSaveDetails |
| 115 | text: enabled? qsTr("Save Profile") : qsTr("Generating account…") |
| 116 | color: enabled? JamiTheme.wizardBlueButtons : JamiTheme.buttonTintedGreyInactive |
| 117 | |
| 118 | onClicked: { |
| 119 | saveProfile() |
| 120 | } |
| 121 | } |
| 122 | |
| 123 | MaterialButton { |
| 124 | text: qsTr("SKIP") |
| 125 | enabled: saveProfileBtn.enabled |
| 126 | color: enabled? JamiTheme.buttonTintedGrey : JamiTheme.buttonTintedGreyInactive |
| 127 | outlined: true |
| 128 | |
| 129 | onClicked: { |
| 130 | leavePage() |
| 131 | } |
| 132 | } |
| 133 | |
| 134 | RowLayout { |
| 135 | id: bottomLayout |
| 136 | height: 48 |
| 137 | spacing: 12 |
| 138 | visible: showBottom |
| 139 | |
| 140 | Layout.preferredWidth: saveProfileBtn.width |
| 141 | Layout.topMargin: 12 |
| 142 | Layout.alignment: Qt.AlignHCenter |
| 143 | |
| 144 | Item { |
| 145 | Layout.fillWidth: true |
| 146 | } |
| 147 | |
| 148 | Rectangle { |
| 149 | color: "grey" |
| 150 | radius: height / 2 |
| 151 | height: 12 |
| 152 | width: 12 |
| 153 | } |
| 154 | |
| 155 | Rectangle { |
| 156 | color: "grey" |
| 157 | radius: height / 2 |
| 158 | height: 12 |
| 159 | width: 12 |
| 160 | } |
| 161 | |
| 162 | Rectangle { |
| 163 | color: JamiTheme.wizardBlueButtons |
| 164 | radius: height / 2 |
| 165 | height: 12 |
| 166 | width: 12 |
| 167 | } |
| 168 | |
| 169 | Item { |
| 170 | Layout.fillWidth: true |
| 171 | } |
| 172 | } |
| 173 | |
| 174 | } |
| 175 | |
| 176 | HoverableButton { |
| 177 | id: cancelButton |
| 178 | z: 2 |
| 179 | visible: readyToSaveDetails |
| 180 | |
| 181 | anchors.right: parent.right |
| 182 | anchors.top: parent.top |
| 183 | |
| 184 | rightPadding: 90 |
| 185 | topPadding: 90 |
| 186 | |
| 187 | Layout.preferredWidth: 96 |
| 188 | Layout.preferredHeight: 96 |
| 189 | |
| 190 | backgroundColor: "transparent" |
| 191 | onEnterColor: "transparent" |
| 192 | onPressColor: "transparent" |
| 193 | onReleaseColor: "transparent" |
| 194 | onExitColor: "transparent" |
| 195 | |
| 196 | buttonImageHeight: 48 |
| 197 | buttonImageWidth: 48 |
| 198 | source: "qrc:/images/icons/ic_close_white_24dp.png" |
| 199 | radius: 48 |
| 200 | baseColor: "#7c7c7c" |
| 201 | toolTipText: qsTr("Close") |
| 202 | |
| 203 | Action { |
| 204 | enabled: parent.visible |
| 205 | shortcut: StandardKey.Cancel |
| 206 | onTriggered: leavePage() |
| 207 | } |
| 208 | |
| 209 | onClicked: { |
| 210 | leavePage() |
| 211 | } |
| 212 | } |
| 213 | } |