blob: ad48871743f7b1069b1689510e9e129b98505c06 [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
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(
ababi69f5dfc2020-08-25 15:07:57 +0200109 0, 0),
Sébastien Blin1f915762020-08-03 13:27:42 -0400110 260) === 1
Sébastien Blin1f915762020-08-03 13:27:42 -0400111 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
ababidf651a22020-07-30 13:38:57 +0200123 font.pointSize: JamiTheme.textFontSize + 1
Sébastien Blin1f915762020-08-03 13:27:42 -0400124
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
ababidf651a22020-07-30 13:38:57 +0200142 HoverableButton {
143 id: copyRegisterednameButton
Sébastien Blin1f915762020-08-03 13:27:42 -0400144
145 Layout.alignment: Qt.AlignCenter
ababidf651a22020-07-30 13:38:57 +0200146 Layout.preferredWidth: buttonPreferredSize
147 Layout.preferredHeight: buttonPreferredSize
Sébastien Blin1f915762020-08-03 13:27:42 -0400148
ababidf651a22020-07-30 13:38:57 +0200149 radius: 30
150 source: "qrc:/images/icons/ic_content_copy.svg"
Sébastien Blin1f915762020-08-03 13:27:42 -0400151
ababidf651a22020-07-30 13:38:57 +0200152 onClicked: {
153 ClientWrapper.utilsAdaptor.setText(
154 textMetricsjamiRegisteredNameText.text)
Sébastien Blin1f915762020-08-03 13:27:42 -0400155 }
156 }
157 }
158 }
Sébastien Blin1f915762020-08-03 13:27:42 -0400159 }
160 }
161
162 CustomBorder {
163 commonBorder: false
164 lBorderwidth: 1
165 rBorderwidth: 0
166 tBorderwidth: 0
167 bBorderwidth: 0
168 borderColor: JamiTheme.tabbarBorderColor
169 }
ababi69f5dfc2020-08-25 15:07:57 +0200170
171 Component.onCompleted: {
172 updateWelcomePage()
173 }
Sébastien Blin1f915762020-08-03 13:27:42 -0400174}