blob: 315e3ed7ff7a7234a10739f86717f04c8eb1c10e [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.Window 2.14
21import QtQuick.Controls 2.14
22import QtQuick.Layouts 1.14
23import QtQuick.Controls.Universal 2.12
24import QtGraphicalEffects 1.14
25import net.jami.Models 1.0
26
27
28/*
29 * Import qml component files.
30 */
31import "components"
Sébastien Blinc75335f2020-08-04 20:54:02 -040032import "../wizardview"
Sébastien Blin1f915762020-08-03 13:27:42 -040033import "../settingsview"
ababia284cae2020-08-10 12:33:34 +020034import "../settingsview/components"
Sébastien Blin1f915762020-08-03 13:27:42 -040035
36Window {
37 id: mainViewWindow
38
Sébastien Blin8cb4e442020-08-24 14:28:11 -040039 property int minWidth: 400
Sébastien Blin1f915762020-08-03 13:27:42 -040040 property int minHeight: aboutPopUpDialog.contentHeight
41
ababia284cae2020-08-10 12:33:34 +020042 property int mainViewWindowPreferredWidth: 650
43 property int mainViewWindowPreferredHeight: 600
Sébastien Blin8cb4e442020-08-24 14:28:11 -040044 property int sidePanelViewStackPreferredWidth: 250
ababia284cae2020-08-10 12:33:34 +020045 property int mainViewStackPreferredWidth: 250
Sébastien Blina84e5fd2020-08-16 17:39:15 -040046 property int aboutPopUpPreferredWidth: 400
Sébastien Blin1f915762020-08-03 13:27:42 -040047
ababidf651a22020-07-30 13:38:57 +020048 property int savedSidePanelViewMinWidth: 0
49 property int savedSidePanelViewMaxWidth: 0
50 property int savedWelcomeViewMinWidth: 0
51 property int savedWelcomeViewMaxWidth: 0
ababia284cae2020-08-10 12:33:34 +020052 property bool sidePanelHidden: false
Sébastien Blin1f915762020-08-03 13:27:42 -040053
54 /*
55 * To calculate tab bar bottom border hidden rect left margin.
56 */
57 property int tabBarLeftMargin: 8
58 property int tabButtonShrinkSize: 8
ababia284cae2020-08-10 12:33:34 +020059 property bool inSettingsView: false
60 property bool needToShowCallStack: false
61 property bool needToCloseCallStack: false
Sébastien Blin1f915762020-08-03 13:27:42 -040062
Sébastien Blin1f915762020-08-03 13:27:42 -040063 signal closeApp
Sébastien Blinc75335f2020-08-04 20:54:02 -040064 signal noAccountIsAvailable
Sébastien Blin1f915762020-08-03 13:27:42 -040065
ababia284cae2020-08-10 12:33:34 +020066 function pushCallStackView(){
67 if (mainViewStack.visible) {
68 mainViewStack.pop(null, StackView.Immediate)
69 mainViewStack.push(callStackView, StackView.Immediate)
70 } else {
71 sidePanelViewStack.pop(null, StackView.Immediate)
72 sidePanelViewStack.push(callStackView, StackView.Immediate)
73 }
74 }
75
76 function pushCommunicationMessageWebView(){
77 if (mainViewStack.visible) {
78 mainViewStack.pop(null, StackView.Immediate)
79 mainViewStack.push(communicationPageMessageWebView,
80 StackView.Immediate)
81 } else {
82 sidePanelViewStack.pop(null, StackView.Immediate)
83 sidePanelViewStack.push(
84 communicationPageMessageWebView,
85 StackView.Immediate)
86 }
87 }
88
Sébastien Blin1f915762020-08-03 13:27:42 -040089 function newAccountAdded(index) {
90 mainViewWindowSidePanel.refreshAccountComboBox(index)
91 }
92
ababia284cae2020-08-10 12:33:34 +020093 function recursionStackViewItemMove(stackOne, stackTwo, depth=1) {
Sébastien Blin1f915762020-08-03 13:27:42 -040094
95 /*
96 * Move all items (expect the bottom item) to stacktwo by the same order in stackone.
97 */
ababia284cae2020-08-10 12:33:34 +020098 if (stackOne.depth === depth) {
Sébastien Blin1f915762020-08-03 13:27:42 -040099 return
100 }
101
102 var tempItem = stackOne.pop(StackView.Immediate)
ababia284cae2020-08-10 12:33:34 +0200103 recursionStackViewItemMove(stackOne, stackTwo, depth)
Sébastien Blin1f915762020-08-03 13:27:42 -0400104 stackTwo.push(tempItem, StackView.Immediate)
105 }
106
ababia284cae2020-08-10 12:33:34 +0200107 function toggleSettingsView() {
108
109 if (!inSettingsView) {
110
111 if (sidePanelHidden){
112 recursionStackViewItemMove(sidePanelViewStack, mainViewStack, 1)
113 mainViewStack.push(settingsView, StackView.Immediate)
114 sidePanelViewStack.push(leftPanelSettingsView, StackView.Immediate)
115 recursionStackViewItemMove(mainViewStack, sidePanelViewStack, 1)
116 } else {
117 mainViewStack.push(settingsView, StackView.Immediate)
118 sidePanelViewStack.push(leftPanelSettingsView, StackView.Immediate)
119 }
120
121 } else {
122
123 if (!sidePanelHidden) {
124 sidePanelViewStack.pop(mainViewWindowSidePanel, StackView.Immediate)
125 mainViewStack.pop(StackView.Immediate)
126 } else {
127 recursionStackViewItemMove(sidePanelViewStack, mainViewStack, 2)
128 sidePanelViewStack.pop(StackView.Immediate)
129 mainViewStack.pop(StackView.Immediate)
130 recursionStackViewItemMove(mainViewStack, sidePanelViewStack, 1)
131 }
132
133 if (needToCloseCallStack) {
134 pushCommunicationMessageWebView()
135 needToShowCallStack = false
136 needToCloseCallStack = false
137 }
138 }
139 inSettingsView = !inSettingsView
140 }
141
Sébastien Blin1f915762020-08-03 13:27:42 -0400142 title: "Jami"
143 visible: true
ababia284cae2020-08-10 12:33:34 +0200144 width: mainViewWindowPreferredWidth
145 height: mainViewWindowPreferredHeight
Sébastien Blin1f915762020-08-03 13:27:42 -0400146 minimumWidth: minWidth
147 minimumHeight: minHeight
148
149 Connections {
150 target: CallAdapter
151
152 function onShowCallStack(accountId, convUid, forceReset) {
ababia284cae2020-08-10 12:33:34 +0200153
154 needToShowCallStack = true
Sébastien Blin1f915762020-08-03 13:27:42 -0400155 if (forceReset) {
156 callStackView.responsibleAccountId = accountId
157 callStackView.responsibleConvUid = convUid
158 }
159
160
161 /*
162 * Check if it is coming from the current responsible call,
163 * and push views onto the correct stackview
164 */
165 if (callStackView.responsibleAccountId === accountId
166 && callStackView.responsibleConvUid === convUid) {
ababia284cae2020-08-10 12:33:34 +0200167 pushCallStackView()
Sébastien Blin1f915762020-08-03 13:27:42 -0400168 }
169 }
170
171 function onCloseCallStack(accountId, convUid) {
172
Sébastien Blin1f915762020-08-03 13:27:42 -0400173 /*
174 * Check if call stack view is on any of the stackview.
175 */
ababia284cae2020-08-10 12:33:34 +0200176 if (callStackView.responsibleAccountId === accountId
177 && callStackView.responsibleConvUid === convUid) {
178 if (mainViewStack.find(function (item, index) {
Sébastien Blin1f915762020-08-03 13:27:42 -0400179 return item.objectName === "callStackViewObject"
180 }) || sidePanelViewStack.find(function (item, index) {
181 return item.objectName === "callStackViewObject"
ababia284cae2020-08-10 12:33:34 +0200182 }) || (inSettingsView && needToShowCallStack)) {
Sébastien Blin1f915762020-08-03 13:27:42 -0400183 callStackView.needToCloseInCallConversationAndPotentialWindow()
ababia284cae2020-08-10 12:33:34 +0200184
185 if (!inSettingsView) {
186 pushCommunicationMessageWebView()
187 needToShowCallStack = false
Sébastien Blin1f915762020-08-03 13:27:42 -0400188 } else {
ababia284cae2020-08-10 12:33:34 +0200189 needToCloseCallStack = true
Sébastien Blin1f915762020-08-03 13:27:42 -0400190 }
191 }
192 }
193 }
194
195 function onIncomingCallNeedToSetupMainView(accountId, convUid) {
196
Sébastien Blin1f915762020-08-03 13:27:42 -0400197 /*
198 * Set up the call stack view that is needed by call overlay.
199 */
ababia284cae2020-08-10 12:33:34 +0200200 if (!inSettingsView) {
201 mainViewStack.pop(null, StackView.Immediate)
202 sidePanelViewStack.pop(null, StackView.Immediate)
203 } else {
204 toggleSettingsView()
205 }
Sébastien Blin1f915762020-08-03 13:27:42 -0400206
207 var index = ClientWrapper.utilsAdaptor.getCurrAccList().indexOf(accountId)
208 var name = ClientWrapper.utilsAdaptor.getBestName(accountId, convUid)
209 var id = ClientWrapper.utilsAdaptor.getBestId(accountId, convUid)
210
211 communicationPageMessageWebView.headerUserAliasLabelText = name
212 communicationPageMessageWebView.headerUserUserNameLabelText = (name !== id) ? id : ""
213
214 callStackView.needToCloseInCallConversationAndPotentialWindow()
Sébastien Blin8940f3c2020-07-23 17:03:11 -0400215 callStackView.setLinkedWebview(
Sébastien Blin1f915762020-08-03 13:27:42 -0400216 communicationPageMessageWebView)
217
218 callStackView.responsibleAccountId = accountId
219 callStackView.responsibleConvUid = convUid
220 callStackView.updateCorrspondingUI()
221
222 mainViewWindowSidePanel.needToChangeToAccount(accountId, index)
223 ConversationsAdapter.selectConversation(accountId, convUid)
224
225 MessagesAdapter.setupChatView(convUid)
226 }
227 }
228
Sébastien Blinc75335f2020-08-04 20:54:02 -0400229 WizardView {
Ming Rui Zhanga70e1302020-08-28 13:31:26 -0400230 id: wizardView
Sébastien Blinc75335f2020-08-04 20:54:02 -0400231
Ming Rui Zhanga70e1302020-08-28 13:31:26 -0400232 anchors.fill: parent
Sébastien Blinc75335f2020-08-04 20:54:02 -0400233
Ming Rui Zhanga70e1302020-08-28 13:31:26 -0400234 onNeedToShowMainViewWindow: {
235 mainViewLoader.newAddedAccountIndex = accountIndex
236 if (mainViewLoader.source.toString() !== "qrc:/src/mainview/MainView.qml") {
237 mainViewLoader.loaded.disconnect(slotNewAccountAdded)
238 mainViewLoader.loaded.connect(slotNewAccountAdded)
239 mainViewLoader.setSource("qrc:/src/mainview/MainView.qml")
240 } else {
241 slotNewAccountAdded()
Sébastien Blinc75335f2020-08-04 20:54:02 -0400242 }
Ming Rui Zhanga70e1302020-08-28 13:31:26 -0400243 mainViewStackLayout.currentIndex = 0
Sébastien Blinc75335f2020-08-04 20:54:02 -0400244 }
245
Ming Rui Zhanga70e1302020-08-28 13:31:26 -0400246 onWizardViewIsClosed: {
247 mainViewStackLayout.currentIndex = 0
248 }
249 }
250
Sébastien Blin1f915762020-08-03 13:27:42 -0400251 StackLayout {
252 id: mainViewStackLayout
253
254 anchors.fill: parent
255
256 currentIndex: 0
257
258 SplitView {
259 id: splitView
260
261 Layout.fillWidth: true
262 Layout.fillHeight: true
263
264 width: mainViewWindow.width
265 height: mainViewWindow.height
266
267 handle: Rectangle {
ababia284cae2020-08-10 12:33:34 +0200268 implicitWidth: JamiTheme.splitViewHandlePreferredWidth
Sébastien Blin1f915762020-08-03 13:27:42 -0400269 implicitHeight: splitView.height
ababi6fa08612020-08-10 19:13:28 +0200270 color:"white"
ababidf651a22020-07-30 13:38:57 +0200271 Rectangle {
272 implicitWidth: 1
273 implicitHeight: splitView.height
274 color: SplitHandle.pressed ? JamiTheme.pressColor : (SplitHandle.hovered ? JamiTheme.hoverColor : JamiTheme.tabbarBorderColor)
275 }
Sébastien Blin1f915762020-08-03 13:27:42 -0400276 }
277
ababia284cae2020-08-10 12:33:34 +0200278 Rectangle {
279 id: mainViewSidePanelRect
280 SplitView.minimumWidth: sidePanelViewStackPreferredWidth
281 SplitView.maximumWidth: (sidePanelHidden ? splitView.width :
282 splitView.width - sidePanelViewStackPreferredWidth)
Sébastien Blin1f915762020-08-03 13:27:42 -0400283 SplitView.fillHeight: true
284
ababia284cae2020-08-10 12:33:34 +0200285 /*
286 * AccountComboBox is always visible
287 */
288 AccountComboBox {
289 id: accountComboBox
290
291 anchors.top: mainViewSidePanelRect.top
292 width: mainViewSidePanelRect.width
293 height: 64
294
295 visible: (mainViewWindowSidePanel.visible || leftPanelSettingsView.visible)
296
297 currentIndex: 0
298
299 Connections {
300 target: ClientWrapper.accountAdaptor
301
ababia284cae2020-08-10 12:33:34 +0200302 function onUpdateConversationForAddedContact() {
303 mainViewWindowSidePanel.needToUpdateConversationForAddedContact()
304 }
305
306 function onAccountStatusChanged() {
307 accountComboBox.updateAccountListModel()
308 }
309 }
310
311 onSettingBtnClicked: {
312 toggleSettingsView()
313 }
314
315 onAccountChanged: {
ababi69f5dfc2020-08-25 15:07:57 +0200316 mainViewWindowSidePanel.refreshAccountComboBox(index)
ababia284cae2020-08-10 12:33:34 +0200317 settingsView.slotAccountListChanged()
318 settingsView.setSelected(settingsView.selectedMenu, true)
319
320 if (needToShowCallStack
321 && callStackView.responsibleAccountId === ClientWrapper.utilsAdaptor.getCurrAccId()){
322 if (!ClientWrapper.accountAdaptor.hasVideoCall()) {
323 pushCommunicationMessageWebView()
324 needToShowCallStack = false
325 } else if (needToShowCallStack) {
326 pushCallStackView()
327 }
328 }
329 }
330
ababia284cae2020-08-10 12:33:34 +0200331 onNeedToBackToWelcomePage: {
332 if (!inSettingsView)
ababi69f5dfc2020-08-25 15:07:57 +0200333 mainViewWindowSidePanel.accountComboBoxNeedToShowWelcomePage()
ababia284cae2020-08-10 12:33:34 +0200334 }
335
336 onNewAccountButtonClicked: {
337 mainViewWindowSidePanel.needToAddNewAccount()
338 }
339
340 Component.onCompleted: {
341 ClientWrapper.accountAdaptor.setQmlObject(this)
342 }
343 }
344
345 StackView {
346 id: sidePanelViewStack
347
348 initialItem: mainViewWindowSidePanel
349
350 anchors.top: accountComboBox.visible ? accountComboBox.bottom : mainViewSidePanelRect.top
351 width: mainViewSidePanelRect.width
352 height: accountComboBox.visible ? mainViewSidePanelRect.height - accountComboBox.height :
353 mainViewSidePanelRect.height
354
355 clip: true
356 }
Sébastien Blin1f915762020-08-03 13:27:42 -0400357 }
358
359 StackView {
ababia284cae2020-08-10 12:33:34 +0200360 id: mainViewStack
Sébastien Blin1f915762020-08-03 13:27:42 -0400361
362 initialItem: welcomePage
363
ababia284cae2020-08-10 12:33:34 +0200364 SplitView.maximumWidth: sidePanelHidden ? splitView.width : splitView.width - sidePanelViewStackPreferredWidth
365 SplitView.minimumWidth: sidePanelViewStackPreferredWidth
Sébastien Blin1f915762020-08-03 13:27:42 -0400366 SplitView.fillHeight: true
367
368 clip: true
369 }
370 }
Sébastien Blin1f915762020-08-03 13:27:42 -0400371 }
372
373 AccountListModel {
374 id: accountListModel
375 }
376
ababia284cae2020-08-10 12:33:34 +0200377
378 LeftPanelView {
379 id: leftPanelSettingsView
380 visible: false
381 contentViewportWidth: mainViewSidePanelRect.width
382 contentViewPortHeight: mainViewSidePanelRect.height
383
384 Connections {
385 target: leftPanelSettingsView.btnAccountSettings
386 function onCheckedToggledForRightPanel(checked) {
387 settingsView.setSelected(SettingsView.Account)
388 if (sidePanelHidden) {
389 recursionStackViewItemMove(mainViewStack, sidePanelViewStack, 1)
390 }
391 }
392 }
393 Connections {
394 target: leftPanelSettingsView.btnGeneralSettings
395 function onCheckedToggledForRightPanel(checked) {
396 settingsView.setSelected(SettingsView.General)
397 if (sidePanelHidden) {
398 recursionStackViewItemMove(mainViewStack, sidePanelViewStack, 1)
399 }
400 }
401 }
402 Connections {
403 target: leftPanelSettingsView.btnMediaSettings
404 function onCheckedToggledForRightPanel(checked) {
405 settingsView.setSelected(SettingsView.Media)
406 if (sidePanelHidden) {
407 recursionStackViewItemMove(mainViewStack, sidePanelViewStack, 1)
408 }
409 }
410 }
411 Connections {
412 target: leftPanelSettingsView.btnPluginSettings
413 function onCheckedToggledForRightPanel(checked) {
414 settingsView.setSelected(SettingsView.Plugin)
415 if (sidePanelHidden) {
416 recursionStackViewItemMove(mainViewStack, sidePanelViewStack, 1)
417 }
418 }
419 }
420 }
421
422
Sébastien Blin1f915762020-08-03 13:27:42 -0400423 SidePanel {
424 id: mainViewWindowSidePanel
425
Sébastien Blin1f915762020-08-03 13:27:42 -0400426 onConversationSmartListNeedToAccessMessageWebView: {
427
428 communicationPageMessageWebView.headerUserAliasLabelText = currentUserAlias
429 communicationPageMessageWebView.headerUserUserNameLabelText = currentUserDisplayName
430
431 callStackView.needToCloseInCallConversationAndPotentialWindow()
432 callStackView.responsibleAccountId = ClientWrapper.utilsAdaptor.getCurrAccId()
433 callStackView.responsibleConvUid = currentUID
434 callStackView.updateCorrspondingUI()
435
436 if (callStackViewShouldShow) {
ababi76b94aa2020-08-24 17:46:30 +0200437 if (callState === Call.Status.IN_PROGRESS || callState === Call.Status.PAUSED) {
Sébastien Blin1f915762020-08-03 13:27:42 -0400438 ClientWrapper.utilsAdaptor.setCurrentCall(
439 ClientWrapper.utilsAdaptor.getCurrAccId(),
440 currentUID)
441 if (isAudioOnly)
442 callStackView.showAudioCallPage()
443 else
444 callStackView.showVideoCallPage(
445 ClientWrapper.utilsAdaptor.getCallId(
446 callStackView.responsibleAccountId,
447 callStackView.responsibleConvUid))
448 } else {
449 callStackView.showOutgoingCallPage(callStateStr)
450 }
451 }
452
453
454 /*
455 * Set up chatview.
456 */
457 MessagesAdapter.setupChatView(currentUID)
Sébastien Blin8940f3c2020-07-23 17:03:11 -0400458 callStackView.setLinkedWebview(
Sébastien Blin1f915762020-08-03 13:27:42 -0400459 communicationPageMessageWebView)
460
ababia284cae2020-08-10 12:33:34 +0200461 if (mainViewStack.find(function (item, index) {
Sébastien Blin1f915762020-08-03 13:27:42 -0400462 return item.objectName === "communicationPageMessageWebView"
463 }) || sidePanelViewStack.find(function (item, index) {
464 return item.objectName === "communicationPageMessageWebView"
465 })) {
466 if (!callStackViewShouldShow)
467 return
468 }
469
470
471 /*
472 * Push messageWebView or callStackView onto the correct stackview
473 */
ababia284cae2020-08-10 12:33:34 +0200474 mainViewStack.pop(null, StackView.Immediate)
Sébastien Blin1f915762020-08-03 13:27:42 -0400475 sidePanelViewStack.pop(null, StackView.Immediate)
476
ababia284cae2020-08-10 12:33:34 +0200477 if (sidePanelViewStack.visible && mainViewStack.visible) {
Sébastien Blin1f915762020-08-03 13:27:42 -0400478 if (callStackViewShouldShow) {
ababia284cae2020-08-10 12:33:34 +0200479 mainViewStack.push(callStackView)
Sébastien Blin1f915762020-08-03 13:27:42 -0400480 } else {
ababia284cae2020-08-10 12:33:34 +0200481 mainViewStack.push(communicationPageMessageWebView)
Sébastien Blin1f915762020-08-03 13:27:42 -0400482 }
483 } else if (sidePanelViewStack.visible
ababia284cae2020-08-10 12:33:34 +0200484 && !mainViewStack.visible) {
Sébastien Blin1f915762020-08-03 13:27:42 -0400485 if (callStackViewShouldShow) {
486 sidePanelViewStack.push(callStackView)
487 } else {
488 sidePanelViewStack.push(communicationPageMessageWebView)
489 }
490 } else if (!sidePanelViewStack.visible
ababia284cae2020-08-10 12:33:34 +0200491 && !mainViewStack.visible) {
Sébastien Blin1f915762020-08-03 13:27:42 -0400492 if (callStackViewShouldShow) {
493 sidePanelViewStack.push(callStackView)
494 } else {
495 sidePanelViewStack.push(communicationPageMessageWebView)
496 }
497 }
498 }
499
500 onAccountComboBoxNeedToShowWelcomePage: {
501
Sébastien Blin1f915762020-08-03 13:27:42 -0400502 /*
503 * If the item argument is specified, all items down to (but not including) item will be popped.
504 */
ababia284cae2020-08-10 12:33:34 +0200505 if (!inSettingsView) {
506 mainViewStack.pop(welcomePage)
ababi69f5dfc2020-08-25 15:07:57 +0200507 welcomePage.updateWelcomePage()
508 qrDialog.updateQrDialog()
ababia284cae2020-08-10 12:33:34 +0200509 }
Sébastien Blin1f915762020-08-03 13:27:42 -0400510 }
511
512 onConversationSmartListViewNeedToShowWelcomePage: {
ababia284cae2020-08-10 12:33:34 +0200513 mainViewStack.pop(welcomePage)
ababi69f5dfc2020-08-25 15:07:57 +0200514 welcomePage.updateWelcomePage()
515 qrDialog.updateQrDialog()
Sébastien Blin1f915762020-08-03 13:27:42 -0400516 }
517
Sébastien Blin1f915762020-08-03 13:27:42 -0400518 onNeedToUpdateConversationForAddedContact: {
519 MessagesAdapter.updateConversationForAddedContact()
520 mainViewWindowSidePanel.clearContactSearchBar()
521 mainViewWindowSidePanel.forceReselectConversationSmartListCurrentIndex()
522 }
523
524 onNeedToAddNewAccount: {
Sébastien Blinc75335f2020-08-04 20:54:02 -0400525 mainViewStackLayout.currentIndex = 2
Sébastien Blin1f915762020-08-03 13:27:42 -0400526 }
527 }
528
529 CallStackView {
530 id: callStackView
531
532 visible: false
533
534 objectName: "callStackViewObject"
ababia284cae2020-08-10 12:33:34 +0200535
Sébastien Blin1f915762020-08-03 13:27:42 -0400536 }
537
538 WelcomePage {
539 id: welcomePage
540 visible: false
541 }
542
ababia284cae2020-08-10 12:33:34 +0200543 SettingsView {
544 id: settingsView
545
546 visible: false
547
548 width: Math.max(mainViewStackPreferredWidth, mainViewStack.width - 100)
549 height: mainViewWindow.minimumHeight
550
551 onSettingsViewWindowNeedToShowMainViewWindow: {
552 mainViewWindowSidePanel.refreshAccountComboBox(
553 accountDeleted ? 0 : -1)
554 toggleSettingsView()
555 }
556
557 onSettingsViewWindowNeedToShowNewWizardWindow: {
558 mainViewWindow.noAccountIsAvailable()
559 }
560
561 onSettingsBackArrowClicked: {
562 mainViewStack.pop(StackView.Immediate)
563 recursionStackViewItemMove(sidePanelViewStack, mainViewStack, 2)
564 }
565 }
566
Sébastien Blin1f915762020-08-03 13:27:42 -0400567 MessageWebView {
568 id: communicationPageMessageWebView
569
570 objectName: "communicationPageMessageWebView"
571
572 signal toSendMessageContentSaved(string arg)
573 signal toMessagesCleared
574 signal toMessagesLoaded
575
576 visible: false
577
578 Connections {
579 target: MessagesAdapter
580
581 function onNeedToUpdateSmartList() {
582 mainViewWindowSidePanel.forceUpdateConversationSmartListView()
583 }
584 }
585
586 onNeedToGoBackToWelcomeView: {
587 mainViewWindowSidePanel.deselectConversationSmartList()
588 if (communicationPageMessageWebView.visible
ababia284cae2020-08-10 12:33:34 +0200589 && !mainViewStack.visible) {
Sébastien Blin1f915762020-08-03 13:27:42 -0400590 sidePanelViewStack.pop()
591 } else if (communicationPageMessageWebView.visible
ababia284cae2020-08-10 12:33:34 +0200592 && mainViewStack.visible) {
593 mainViewStack.pop()
Sébastien Blin1f915762020-08-03 13:27:42 -0400594 }
Sébastien Blin59c8ead2020-08-25 21:32:41 -0400595 recordBox.visible = false
Sébastien Blin1f915762020-08-03 13:27:42 -0400596 }
597
598 Component.onCompleted: {
Sébastien Blin1f915762020-08-03 13:27:42 -0400599
Sébastien Blinc75335f2020-08-04 20:54:02 -0400600 sidePanelViewStack.SplitView.maximumWidth = Qt.binding(function() {
Sébastien Blin59c8ead2020-08-25 21:32:41 -0400601 return (hiddenView ? splitView.width :
602 splitView.width - sidePanelViewStackPreferedWidth)
Sébastien Blinc75335f2020-08-04 20:54:02 -0400603 })
604
605 recordBox.x = Qt.binding(function() {
Sébastien Blin59c8ead2020-08-25 21:32:41 -0400606 var i = ((mainViewStack.visible && mainViewStack.width > 1000) ?
607 Math.round((mainViewStack.width-1000)*0.5) :
608 0)
609 return mainViewStack.visible ?
610 sidePanelViewStack.width + recordBox.x_offset + i :
611 recordBox.x_offset + i
612
Sébastien Blinc75335f2020-08-04 20:54:02 -0400613 })
614
615 recordBox.y = Qt.binding(function() {
Sébastien Blin59c8ead2020-08-25 21:32:41 -0400616 return mainViewStack.visible ? mainViewStack.height + recordBox.y_offset :
617 sidePanelViewStack.height + recordBox.y_offset
Sébastien Blinc75335f2020-08-04 20:54:02 -0400618 })
619
620
Sébastien Blin1f915762020-08-03 13:27:42 -0400621 /*
622 * Set qml MessageWebView object pointer to c++.
623 */
624 MessagesAdapter.setQmlObject(this)
625 }
626 }
627
628 onWidthChanged: {
629
630
631 /*
632 * Hide unnecessary stackview when width is changed.
633 */
ababia284cae2020-08-10 12:33:34 +0200634 if (mainViewWindow.width < sidePanelViewStackPreferredWidth
635 + mainViewStackPreferredWidth - 5
636 && mainViewStack.visible) {
637 mainViewStack.visible = false
638 sidePanelHidden = true
Sébastien Blin1f915762020-08-03 13:27:42 -0400639
640 /*
641 * The find callback function is called for each item in the stack.
642 */
ababia284cae2020-08-10 12:33:34 +0200643 var inWelcomeViewStack = mainViewStack.find(
Sébastien Blin1f915762020-08-03 13:27:42 -0400644 function (item, index) {
645 return index > 0
646 })
ababidf651a22020-07-30 13:38:57 +0200647
Sébastien Blin1f915762020-08-03 13:27:42 -0400648 if (inWelcomeViewStack) {
ababia284cae2020-08-10 12:33:34 +0200649 recursionStackViewItemMove(mainViewStack, sidePanelViewStack)
Sébastien Blin1f915762020-08-03 13:27:42 -0400650 }
651
Sébastien Blin1f915762020-08-03 13:27:42 -0400652 mainViewWindow.update()
ababia284cae2020-08-10 12:33:34 +0200653 } else if (mainViewWindow.width >= sidePanelViewStackPreferredWidth
654 + mainViewStackPreferredWidth + 5
655 && !mainViewStack.visible) {
656 mainViewStack.visible = true
657 sidePanelHidden = false
Sébastien Blin1f915762020-08-03 13:27:42 -0400658
659 var inSidePanelViewStack = sidePanelViewStack.find(
660 function (item, index) {
661 return index > 0
662 })
663 if (inSidePanelViewStack) {
ababia284cae2020-08-10 12:33:34 +0200664 recursionStackViewItemMove(sidePanelViewStack, mainViewStack, (inSettingsView ? 2 : 1))
Sébastien Blin1f915762020-08-03 13:27:42 -0400665 }
666
Sébastien Blin1f915762020-08-03 13:27:42 -0400667 mainViewWindow.update()
668 }
669 }
670
671 AboutPopUp {
672 id: aboutPopUpDialog
673
674 x: Math.round((mainViewWindow.width - width) / 2)
675 y: Math.round((mainViewWindow.height - height) / 2)
Sébastien Blina84e5fd2020-08-16 17:39:15 -0400676 width: aboutPopUpPreferredWidth
Sébastien Blin1f915762020-08-03 13:27:42 -0400677 height: aboutPopUpDialog.contentHeight
678 }
679
680 WelcomePageQrDialog {
681 id: qrDialog
682
683 x: Math.round((mainViewWindow.width - width) / 2)
684 y: Math.round((mainViewWindow.height - height) / 2)
685 width: qrDialog.contentHeight
686 height: qrDialog.contentHeight
687 }
688
689 RecordBox{
690 id: recordBox
691 visible: false
692 }
693
694 UserProfile {
695 id: userProfile
696
697 x: Math.round((mainViewWindow.width - width) / 2)
698 y: Math.round((mainViewWindow.height - height) / 2)
ababia284cae2020-08-10 12:33:34 +0200699 width: Math.max(mainViewWindow.width / 2, aboutPopUpPreferredWidth)
Sébastien Blin1f915762020-08-03 13:27:42 -0400700 height: userProfile.contentHeight
701 }
702
703 Component.onCompleted: {
704 CallAdapter.initQmlObject()
705 }
706
707 onClosing: {
708 close.accepted = false
709 mainViewWindow.hide()
710 mainViewWindow.closeApp()
711 }
712}