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 | |
| 25 | ColumnLayout { |
| 26 | Layout.fillWidth: true |
| 27 | Layout.fillHeight: true |
| 28 | spacing: 6 |
| 29 | |
| 30 | property bool successState: true |
| 31 | property string progressLabelEditText: "Generating your Jami account" |
| 32 | |
| 33 | Item { |
| 34 | Layout.alignment: Qt.AlignHCenter |
| 35 | Layout.preferredHeight: 40 |
| 36 | Layout.fillWidth: true |
| 37 | Layout.fillHeight: true |
| 38 | } |
| 39 | Label { |
| 40 | id: spinnerLabel |
| 41 | Layout.alignment: Qt.AlignHCenter |
| 42 | Layout.minimumWidth: 200 |
| 43 | Layout.minimumHeight: 200 |
| 44 | |
| 45 | Layout.maximumWidth: 16777215 |
| 46 | Layout.maximumHeight: 16777215 |
| 47 | |
| 48 | property string spinnerDisplyState: successState ? "spinnerLabel_Regular" : "spinnerLabel_Failure" |
| 49 | onSpinnerDisplyStateChanged: { |
| 50 | switch (spinnerDisplyState) { |
| 51 | case "spinnerLabel_Regular": |
| 52 | background = Qt.createQmlObject("import QtQuick 2.14; |
| 53 | AnimatedImage { |
| 54 | source: \"qrc:/images/jami_eclipse_spinner.gif\" |
| 55 | |
| 56 | playing: true |
| 57 | paused: false |
| 58 | fillMode: Image.PreserveAspectFit |
| 59 | mipmap: true |
| 60 | }", spinnerLabel) |
| 61 | break |
| 62 | case "spinnerLabel_Failure": |
| 63 | background = Qt.createQmlObject("import QtQuick 2.14; |
| 64 | import \"qrc:/src/constant/\"; |
| 65 | Image { |
| 66 | anchors.fill: parent; |
| 67 | source:\"image://tintedPixmap/\" + (\"qrc:/images/icons/baseline-error_outline-24px.svg\").replace(\"qrc:/images/icons/\", \"\") + \"+\" + JamiTheme.urgentOrange_; |
| 68 | mipmap: true;}", spinnerLabel) |
| 69 | break |
| 70 | } |
| 71 | } |
| 72 | } |
| 73 | Item { |
| 74 | Layout.alignment: Qt.AlignHCenter |
| 75 | Layout.preferredHeight: 40 |
| 76 | Layout.fillWidth: true |
| 77 | Layout.fillHeight: true |
| 78 | } |
| 79 | Label { |
| 80 | id: progressLabel |
| 81 | Layout.alignment: Qt.AlignHCenter |
| 82 | text: successState ? progressLabelEditText : "Error creating account" |
| 83 | font.pointSize: 11 |
| 84 | font.kerning: true |
| 85 | |
| 86 | property string progressLabelState: successState ? "color_success" : "color_fail" |
| 87 | onProgressLabelStateChanged: { |
| 88 | switch (progressLabelState) { |
| 89 | case "color_success": |
| 90 | background = Qt.createQmlObject( |
| 91 | "import QtQuick 2.14; Rectangle { anchors.fill: parent; color: \"transparent\"; }", |
| 92 | progressLabel) |
| 93 | break |
| 94 | case "color_fail": |
| 95 | background = Qt.createQmlObject( |
| 96 | "import QtQuick 2.14; Rectangle { anchors.fill: parent; color: \"red\"; }", |
| 97 | progressLabel) |
| 98 | break |
| 99 | } |
| 100 | } |
| 101 | } |
| 102 | Item { |
| 103 | Layout.alignment: Qt.AlignHCenter |
| 104 | Layout.minimumHeight: 20 |
| 105 | Layout.maximumHeight: 20 |
| 106 | Layout.preferredHeight: 20 |
| 107 | Layout.fillWidth: true |
| 108 | Layout.fillHeight: false |
| 109 | } |
| 110 | } |