blob: bd7d26e2dd1f9eff22ae7dc96ab1c259c78db72c [file] [log] [blame]
Sébastien Blin1f915762020-08-03 13:27:42 -04001/*
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
19import QtQuick 2.14
20import QtQuick.Layouts 1.3
21import QtQuick.Controls 2.14
22import Qt.labs.platform 1.1
23
24import "../../constant"
25import "../../commoncomponents"
26
27ColumnLayout {
28 property alias text_passwordFromBackupEditAlias: passwordFromBackupEdit.text
29 property string fileImportBtnText: qsTr("Archive(none)")
30
31 signal importFromFile_Dialog_Accepted(string fileDir)
32
33 function clearAllTextFields() {
34 passwordFromBackupEdit.clear()
35 fileImportBtnText = qsTr("Archive(none)")
36 }
37
38 JamiFileDialog {
39 id: importFromFile_Dialog
40
41 mode: JamiFileDialog.OpenFile
42 title: qsTr("Open File")
43 folder: StandardPaths.writableLocation(StandardPaths.HomeLocation) + "/Desktop"
44
45 nameFilters: [qsTr("Jami archive files") + " (*.gz)", qsTr(
46 "All files") + " (*)"]
47
48 onAccepted: {
49 importFromFile_Dialog_Accepted(file)
50 }
51 }
52
53 Layout.fillWidth: true
54 Layout.fillHeight: true
55
56 Item {
57 Layout.alignment: Qt.AlignHCenter
58 Layout.fillWidth: true
59 Layout.fillHeight: true
60 }
61
62 ColumnLayout {
63 Layout.alignment: Qt.AlignCenter
64 Layout.maximumWidth: 366
65
66 spacing: 12
67
68 RowLayout {
69 Layout.fillWidth: true
70 Layout.maximumHeight: 24
71 spacing: 0
72
73 Item {
74 Layout.alignment: Qt.AlignVCenter
75 Layout.fillWidth: true
76 Layout.fillHeight: true
77 }
78
79 Label {
80 id: importFromBackupLabel
81 Layout.minimumHeight: 24
82 Layout.minimumWidth: 234
83 text: qsTr("Import from backup")
84 font.pointSize: 13
85 font.kerning: true
86 horizontalAlignment: Qt.AlignLeft
87 verticalAlignment: Qt.AlignVCenter
88 }
89
90 HoverableRadiusButton {
91 id: backupInfoBtn
92
93 buttonImageHeight: height
94 buttonImageWidth: width
95
96 Layout.alignment: Qt.AlignVCenter
97 Layout.minimumWidth: 24
98 Layout.preferredWidth: 24
99 Layout.maximumWidth: 24
100
101 Layout.minimumHeight: 24
102 Layout.preferredHeight: 24
103 Layout.maximumHeight: 24
104
105 radius: height / 2
106 icon.source: "/images/icons/info-24px.svg"
107 icon.height: 24
108 icon.width: 24
109
110 backgroundColor: JamiTheme.releaseColor
111 onClicked: {
112 backupInfoLabel.visible = !backupInfoLabel.visible
113 }
114 }
115 Item {
116 Layout.alignment: Qt.AlignVCenter
117 Layout.fillWidth: true
118 Layout.fillHeight: true
119 }
120 }
121
122 HoverableGradientButton {
123 id: fileImportBtn
124
125 Layout.alignment: Qt.AlignHCenter
126 Layout.maximumWidth: 256
127 Layout.preferredWidth: 256
128
129 Layout.maximumHeight: 30
130 Layout.preferredHeight: 30
131 Layout.minimumHeight: 30
132
133 text: fileImportBtnText
134 font.pointSize: 10
135 font.kerning: true
136
137 radius: height / 2
138 backgroundColor: JamiTheme.releaseColor
139
140 onClicked: {
141 importFromFile_Dialog.open()
142 }
143 }
144
145 InfoLineEdit {
146 id: passwordFromBackupEdit
147
148 Layout.alignment: Qt.AlignHCenter
149
150 selectByMouse: true
151 echoMode: TextInput.Password
152 placeholderText: qsTr("Password")
153 }
154
155 Label {
156 id: backupInfoLabel
157
158 Layout.alignment: Qt.AlignHCenter
159 Layout.maximumWidth: 366
160 Layout.preferredWidth: 366
161
162 text: qsTr("You can obtain an archive by clicking on \"Export account\" in the account settings. This will create a .gz file on your device.")
163 wrapMode: Text.WordWrap
164 horizontalAlignment: Text.AlignHCenter
165 verticalAlignment: Text.AlignVCenter
166
167 visible: false
168 }
169 }
170
171 Item {
172 Layout.alignment: Qt.AlignHCenter
173 Layout.fillWidth: true
174 Layout.fillHeight: true
175 }
176}