blob: 49d8061d80a95414efe99e5dda95f347505e032e [file] [log] [blame]
Sébastien Blin1f915762020-08-03 13:27:42 -04001
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 */
19import QtQuick 2.14
20import QtQuick.Controls 2.14
21import QtQuick.Layouts 1.14
22import net.jami.Models 1.0
23
24import "../../commoncomponents"
25
26Rectangle {
27 id: welcomeRect
Sébastien Blin1f915762020-08-03 13:27:42 -040028 property int buttonPreferredSize: 30
ababia284cae2020-08-10 12:33:34 +020029 anchors.fill: parent
Sébastien Blin1f915762020-08-03 13:27:42 -040030
ababi69f5dfc2020-08-25 15:07:57 +020031 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 Blin1f915762020-08-03 13:27:42 -040037 Rectangle {
38 id: welcomeRectComponentsGroup
39
40 anchors.centerIn: parent
41
ababia284cae2020-08-10 12:33:34 +020042 width: Math.max(mainViewStackPreferredWidth, welcomeRect.width - 100)
Sébastien Blin1f915762020-08-03 13:27:42 -040043 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
ababidf651a22020-07-30 13:38:57 +020087 font.pointSize: JamiTheme.textFontSize
Sébastien Blin1f915762020-08-03 13:27:42 -040088
89 horizontalAlignment: Text.AlignHCenter
90 verticalAlignment: Text.AlignVCenter
91
92 visible: accountListModel.data(accountListModel.index(
ababi69f5dfc2020-08-25 15:07:57 +020093 0, 0),
Sébastien Blin1f915762020-08-03 13:27:42 -040094 260) === 1
ababi69f5dfc2020-08-25 15:07:57 +020095
Sébastien Blin1f915762020-08-03 13:27:42 -040096 text: qsTr("This is your ID.\nCopy and share it with your friends")
97 color: JamiTheme.faddedFontColor
98 }
99
100 Rectangle {
101 id: jamiRegisteredNameRect
Sébastien Blin1f915762020-08-03 13:27:42 -0400102 Layout.alignment: Qt.AlignCenter
103 Layout.preferredWidth: welcomeRectComponentsGroup.width
104 Layout.preferredHeight: 65
105 Layout.bottomMargin: 5
Sébastien Blin1f915762020-08-03 13:27:42 -0400106 visible: accountListModel.data(accountListModel.index(
ababi69f5dfc2020-08-25 15:07:57 +0200107 0, 0),
Sébastien Blin1f915762020-08-03 13:27:42 -0400108 260) === 1
Sébastien Blin1f915762020-08-03 13:27:42 -0400109 ColumnLayout {
110 id: jamiRegisteredNameRectColumnLayout
Sébastien Blin1f915762020-08-03 13:27:42 -0400111 spacing: 0
Sébastien Blin1f915762020-08-03 13:27:42 -0400112 Text {
113 id: jamiRegisteredNameText
Sébastien Blin1f915762020-08-03 13:27:42 -0400114 Layout.alignment: Qt.AlignCenter
115 Layout.preferredWidth: welcomeRectComponentsGroup.width
116 Layout.preferredHeight: 30
ababidf651a22020-07-30 13:38:57 +0200117 font.pointSize: JamiTheme.textFontSize + 1
Sébastien Blin1f915762020-08-03 13:27:42 -0400118 horizontalAlignment: Text.AlignHCenter
119 verticalAlignment: Text.AlignVCenter
Sébastien Blin1f915762020-08-03 13:27:42 -0400120 text: textMetricsjamiRegisteredNameText.elidedText
Sébastien Blin1f915762020-08-03 13:27:42 -0400121 TextMetrics {
122 id: textMetricsjamiRegisteredNameText
Sébastien Blin1f915762020-08-03 13:27:42 -0400123 font: jamiRegisteredNameText.font
124 text: accountListModel.data(
125 accountListModel.index(
126 currentAccountIndex, 0), 258)
127 elideWidth: welcomeRectComponentsGroup.width
128 elide: Qt.ElideMiddle
129 }
130 }
ababidf651a22020-07-30 13:38:57 +0200131 HoverableButton {
132 id: copyRegisterednameButton
Sébastien Blin1f915762020-08-03 13:27:42 -0400133 Layout.alignment: Qt.AlignCenter
ababidf651a22020-07-30 13:38:57 +0200134 Layout.preferredWidth: buttonPreferredSize
135 Layout.preferredHeight: buttonPreferredSize
ababidf651a22020-07-30 13:38:57 +0200136 radius: 30
137 source: "qrc:/images/icons/ic_content_copy.svg"
ababidf651a22020-07-30 13:38:57 +0200138 onClicked: {
139 ClientWrapper.utilsAdaptor.setText(
140 textMetricsjamiRegisteredNameText.text)
Sébastien Blin1f915762020-08-03 13:27:42 -0400141 }
142 }
143 }
144 }
Sébastien Blin1f915762020-08-03 13:27:42 -0400145 }
146 }
147
Sébastien Blina84e5fd2020-08-16 17:39:15 -0400148
149 Button {
150 anchors.bottom: parent.bottom
151 anchors.horizontalCenter: parent.horizontalCenter
152 background: Rectangle {
153 color: "transparent"
154 }
155 anchors.bottomMargin: 12
156 contentItem: Text {
157 text: qsTr("About Jami")
158 color: "grey"
159 }
160
161 onClicked: {
162 aboutPopUpDialog.open()
163 }
164 }
165
Sébastien Blin1f915762020-08-03 13:27:42 -0400166 CustomBorder {
167 commonBorder: false
168 lBorderwidth: 1
169 rBorderwidth: 0
170 tBorderwidth: 0
171 bBorderwidth: 0
172 borderColor: JamiTheme.tabbarBorderColor
173 }
ababi69f5dfc2020-08-25 15:07:57 +0200174
175 Component.onCompleted: {
176 updateWelcomePage()
177 }
Sébastien Blin1f915762020-08-03 13:27:42 -0400178}