Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 1 | |
| 2 | /* |
| 3 | * Copyright (C) 2020 by Savoir-faire Linux |
| 4 | * Author: Mingrui Zhang <mingrui.zhang@savoirfairelinux.com> |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; either version 3 of the License, or |
| 9 | * (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program. If not, see <https://www.gnu.org/licenses/>. |
| 18 | */ |
| 19 | import QtQuick 2.14 |
| 20 | import QtQuick.Controls 2.14 |
| 21 | import QtQuick.Layouts 1.14 |
| 22 | import net.jami.Models 1.0 |
| 23 | |
| 24 | import "../../commoncomponents" |
| 25 | |
| 26 | Rectangle { |
| 27 | id: welcomeRect |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 28 | property int buttonPreferredSize: 30 |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 29 | anchors.fill: parent |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 30 | |
ababi | 69f5dfc | 2020-08-25 15:07:57 +0200 | [diff] [blame^] | 31 | function updateWelcomePage(){ |
| 32 | jamiShareWithFriendText.visible = accountListModel.data(accountListModel.index(0, 0), 260) === 1 |
| 33 | jamiRegisteredNameRect.visible = accountListModel.data(accountListModel.index(0, 0), 260) === 1 |
| 34 | textMetricsjamiRegisteredNameText.text = accountListModel.data(accountListModel.index(0, 0), 258) |
| 35 | } |
| 36 | |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 37 | Rectangle { |
| 38 | id: welcomeRectComponentsGroup |
| 39 | |
| 40 | anchors.centerIn: parent |
| 41 | |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 42 | width: Math.max(mainViewStackPreferredWidth, welcomeRect.width - 100) |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 43 | height: mainViewWindow.minimumHeight |
| 44 | |
| 45 | ColumnLayout { |
| 46 | id: welcomeRectComponentsGroupColumnLayout |
| 47 | |
| 48 | Image { |
| 49 | id: jamiLogoImage |
| 50 | |
| 51 | Layout.alignment: Qt.AlignCenter |
| 52 | Layout.preferredWidth: welcomeRectComponentsGroup.width |
| 53 | Layout.preferredHeight: 100 |
| 54 | Layout.topMargin: 50 |
| 55 | Layout.bottomMargin: 10 |
| 56 | |
| 57 | fillMode: Image.PreserveAspectFit |
| 58 | source: "qrc:/images/logo-jami-standard-coul.png" |
| 59 | mipmap: true |
| 60 | } |
| 61 | |
| 62 | Label { |
| 63 | id: jamiIntroText |
| 64 | |
| 65 | Layout.alignment: Qt.AlignCenter |
| 66 | Layout.preferredWidth: welcomeRectComponentsGroup.width |
| 67 | Layout.preferredHeight: 100 |
| 68 | Layout.bottomMargin: 5 |
| 69 | |
| 70 | wrapMode: Text.WordWrap |
| 71 | font.pointSize: JamiTheme.textFontSize + 1 |
| 72 | |
| 73 | horizontalAlignment: Text.AlignHCenter |
| 74 | verticalAlignment: Text.AlignVCenter |
| 75 | |
| 76 | text: qsTr("Jami is a free software for universal communication which repects the freedoms and privacy of its user.") |
| 77 | } |
| 78 | |
| 79 | Label { |
| 80 | id: jamiShareWithFriendText |
| 81 | |
| 82 | Layout.alignment: Qt.AlignCenter |
| 83 | Layout.preferredWidth: welcomeRectComponentsGroup.width |
| 84 | Layout.preferredHeight: 50 |
| 85 | |
| 86 | wrapMode: Text.WordWrap |
ababi | df651a2 | 2020-07-30 13:38:57 +0200 | [diff] [blame] | 87 | font.pointSize: JamiTheme.textFontSize |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 88 | |
| 89 | horizontalAlignment: Text.AlignHCenter |
| 90 | verticalAlignment: Text.AlignVCenter |
| 91 | |
| 92 | visible: accountListModel.data(accountListModel.index( |
ababi | 69f5dfc | 2020-08-25 15:07:57 +0200 | [diff] [blame^] | 93 | 0, 0), |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 94 | 260) === 1 |
ababi | 69f5dfc | 2020-08-25 15:07:57 +0200 | [diff] [blame^] | 95 | |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 96 | text: qsTr("This is your ID.\nCopy and share it with your friends") |
| 97 | color: JamiTheme.faddedFontColor |
| 98 | } |
| 99 | |
| 100 | Rectangle { |
| 101 | id: jamiRegisteredNameRect |
| 102 | |
| 103 | Layout.alignment: Qt.AlignCenter |
| 104 | Layout.preferredWidth: welcomeRectComponentsGroup.width |
| 105 | Layout.preferredHeight: 65 |
| 106 | Layout.bottomMargin: 5 |
| 107 | |
| 108 | visible: accountListModel.data(accountListModel.index( |
ababi | 69f5dfc | 2020-08-25 15:07:57 +0200 | [diff] [blame^] | 109 | 0, 0), |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 110 | 260) === 1 |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 111 | ColumnLayout { |
| 112 | id: jamiRegisteredNameRectColumnLayout |
| 113 | |
| 114 | spacing: 0 |
| 115 | |
| 116 | Text { |
| 117 | id: jamiRegisteredNameText |
| 118 | |
| 119 | Layout.alignment: Qt.AlignCenter |
| 120 | Layout.preferredWidth: welcomeRectComponentsGroup.width |
| 121 | Layout.preferredHeight: 30 |
| 122 | |
ababi | df651a2 | 2020-07-30 13:38:57 +0200 | [diff] [blame] | 123 | font.pointSize: JamiTheme.textFontSize + 1 |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 124 | |
| 125 | horizontalAlignment: Text.AlignHCenter |
| 126 | verticalAlignment: Text.AlignVCenter |
| 127 | |
| 128 | text: textMetricsjamiRegisteredNameText.elidedText |
| 129 | |
| 130 | TextMetrics { |
| 131 | id: textMetricsjamiRegisteredNameText |
| 132 | |
| 133 | font: jamiRegisteredNameText.font |
| 134 | text: accountListModel.data( |
| 135 | accountListModel.index( |
| 136 | currentAccountIndex, 0), 258) |
| 137 | elideWidth: welcomeRectComponentsGroup.width |
| 138 | elide: Qt.ElideMiddle |
| 139 | } |
| 140 | } |
| 141 | |
ababi | df651a2 | 2020-07-30 13:38:57 +0200 | [diff] [blame] | 142 | HoverableButton { |
| 143 | id: copyRegisterednameButton |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 144 | |
| 145 | Layout.alignment: Qt.AlignCenter |
ababi | df651a2 | 2020-07-30 13:38:57 +0200 | [diff] [blame] | 146 | Layout.preferredWidth: buttonPreferredSize |
| 147 | Layout.preferredHeight: buttonPreferredSize |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 148 | |
ababi | df651a2 | 2020-07-30 13:38:57 +0200 | [diff] [blame] | 149 | radius: 30 |
| 150 | source: "qrc:/images/icons/ic_content_copy.svg" |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 151 | |
ababi | df651a2 | 2020-07-30 13:38:57 +0200 | [diff] [blame] | 152 | onClicked: { |
| 153 | ClientWrapper.utilsAdaptor.setText( |
| 154 | textMetricsjamiRegisteredNameText.text) |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 155 | } |
| 156 | } |
| 157 | } |
| 158 | } |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 159 | } |
| 160 | } |
| 161 | |
| 162 | CustomBorder { |
| 163 | commonBorder: false |
| 164 | lBorderwidth: 1 |
| 165 | rBorderwidth: 0 |
| 166 | tBorderwidth: 0 |
| 167 | bBorderwidth: 0 |
| 168 | borderColor: JamiTheme.tabbarBorderColor |
| 169 | } |
ababi | 69f5dfc | 2020-08-25 15:07:57 +0200 | [diff] [blame^] | 170 | |
| 171 | Component.onCompleted: { |
| 172 | updateWelcomePage() |
| 173 | } |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 174 | } |