blob: aa9dcec2e15eb48005e60a16c2dc91e83f681023 [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"
32import "../settingsview"
ababia284cae2020-08-10 12:33:34 +020033import "../settingsview/components"
Sébastien Blin1f915762020-08-03 13:27:42 -040034
35Window {
36 id: mainViewWindow
37
ababia284cae2020-08-10 12:33:34 +020038 property int minWidth: sidePanelViewStackPreferredWidth
Sébastien Blin1f915762020-08-03 13:27:42 -040039 property int minHeight: aboutPopUpDialog.contentHeight
40
ababia284cae2020-08-10 12:33:34 +020041 property int mainViewWindowPreferredWidth: 650
42 property int mainViewWindowPreferredHeight: 600
43 property int sidePanelViewStackPreferredWidth: 250
44 property int mainViewStackPreferredWidth: 250
45 property int aboutPopUpPreferredWidth: 250
Sébastien Blin1f915762020-08-03 13:27:42 -040046
ababidf651a22020-07-30 13:38:57 +020047 property int savedSidePanelViewMinWidth: 0
48 property int savedSidePanelViewMaxWidth: 0
49 property int savedWelcomeViewMinWidth: 0
50 property int savedWelcomeViewMaxWidth: 0
ababia284cae2020-08-10 12:33:34 +020051 property bool sidePanelHidden: false
Sébastien Blin1f915762020-08-03 13:27:42 -040052
53 /*
54 * To calculate tab bar bottom border hidden rect left margin.
55 */
56 property int tabBarLeftMargin: 8
57 property int tabButtonShrinkSize: 8
ababia284cae2020-08-10 12:33:34 +020058 property bool inSettingsView: false
59 property bool needToShowCallStack: false
60 property bool needToCloseCallStack: false
Sébastien Blin1f915762020-08-03 13:27:42 -040061
62 signal noAccountIsAvailable
63 signal needToAddNewAccount
64 signal closeApp
65
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 Blin8940f3c2020-07-23 17:03:11 -0400173 var responsibleCallId = ClientWrapper.utilsAdaptor.getCallId(
174 callStackView.responsibleAccountId, callStackView.responsibleConvUid)
175 var callId = ClientWrapper.utilsAdaptor.getCallId(
176 callStackView.responsibleAccountId, convUid)
Sébastien Blin1f915762020-08-03 13:27:42 -0400177 /*
178 * Check if call stack view is on any of the stackview.
179 */
ababia284cae2020-08-10 12:33:34 +0200180 if (callStackView.responsibleAccountId === accountId
181 && callStackView.responsibleConvUid === convUid) {
182 if (mainViewStack.find(function (item, index) {
Sébastien Blin1f915762020-08-03 13:27:42 -0400183 return item.objectName === "callStackViewObject"
184 }) || sidePanelViewStack.find(function (item, index) {
185 return item.objectName === "callStackViewObject"
ababia284cae2020-08-10 12:33:34 +0200186 }) || (inSettingsView && needToShowCallStack)) {
Sébastien Blin1f915762020-08-03 13:27:42 -0400187 callStackView.needToCloseInCallConversationAndPotentialWindow()
ababia284cae2020-08-10 12:33:34 +0200188
189 if (!inSettingsView) {
190 pushCommunicationMessageWebView()
191 needToShowCallStack = false
Sébastien Blin1f915762020-08-03 13:27:42 -0400192 } else {
ababia284cae2020-08-10 12:33:34 +0200193 needToCloseCallStack = true
Sébastien Blin1f915762020-08-03 13:27:42 -0400194 }
195 }
196 }
197 }
198
199 function onIncomingCallNeedToSetupMainView(accountId, convUid) {
200
Sébastien Blin1f915762020-08-03 13:27:42 -0400201 /*
202 * Set up the call stack view that is needed by call overlay.
203 */
ababia284cae2020-08-10 12:33:34 +0200204 if (!inSettingsView) {
205 mainViewStack.pop(null, StackView.Immediate)
206 sidePanelViewStack.pop(null, StackView.Immediate)
207 } else {
208 toggleSettingsView()
209 }
Sébastien Blin1f915762020-08-03 13:27:42 -0400210
211 var index = ClientWrapper.utilsAdaptor.getCurrAccList().indexOf(accountId)
212 var name = ClientWrapper.utilsAdaptor.getBestName(accountId, convUid)
213 var id = ClientWrapper.utilsAdaptor.getBestId(accountId, convUid)
214
215 communicationPageMessageWebView.headerUserAliasLabelText = name
216 communicationPageMessageWebView.headerUserUserNameLabelText = (name !== id) ? id : ""
217
218 callStackView.needToCloseInCallConversationAndPotentialWindow()
Sébastien Blin8940f3c2020-07-23 17:03:11 -0400219 callStackView.setLinkedWebview(
Sébastien Blin1f915762020-08-03 13:27:42 -0400220 communicationPageMessageWebView)
221
222 callStackView.responsibleAccountId = accountId
223 callStackView.responsibleConvUid = convUid
224 callStackView.updateCorrspondingUI()
225
226 mainViewWindowSidePanel.needToChangeToAccount(accountId, index)
227 ConversationsAdapter.selectConversation(accountId, convUid)
228
229 MessagesAdapter.setupChatView(convUid)
230 }
231 }
232
233 StackLayout {
234 id: mainViewStackLayout
235
236 anchors.fill: parent
237
238 currentIndex: 0
239
240 SplitView {
241 id: splitView
242
243 Layout.fillWidth: true
244 Layout.fillHeight: true
245
246 width: mainViewWindow.width
247 height: mainViewWindow.height
248
249 handle: Rectangle {
ababia284cae2020-08-10 12:33:34 +0200250 implicitWidth: JamiTheme.splitViewHandlePreferredWidth
Sébastien Blin1f915762020-08-03 13:27:42 -0400251 implicitHeight: splitView.height
ababidf651a22020-07-30 13:38:57 +0200252 color:"transparent"
253 Rectangle {
254 implicitWidth: 1
255 implicitHeight: splitView.height
256 color: SplitHandle.pressed ? JamiTheme.pressColor : (SplitHandle.hovered ? JamiTheme.hoverColor : JamiTheme.tabbarBorderColor)
257 }
Sébastien Blin1f915762020-08-03 13:27:42 -0400258 }
259
ababia284cae2020-08-10 12:33:34 +0200260 Rectangle {
261 id: mainViewSidePanelRect
262 SplitView.minimumWidth: sidePanelViewStackPreferredWidth
263 SplitView.maximumWidth: (sidePanelHidden ? splitView.width :
264 splitView.width - sidePanelViewStackPreferredWidth)
Sébastien Blin1f915762020-08-03 13:27:42 -0400265 SplitView.fillHeight: true
266
ababia284cae2020-08-10 12:33:34 +0200267 /*
268 * AccountComboBox is always visible
269 */
270 AccountComboBox {
271 id: accountComboBox
272
273 anchors.top: mainViewSidePanelRect.top
274 width: mainViewSidePanelRect.width
275 height: 64
276
277 visible: (mainViewWindowSidePanel.visible || leftPanelSettingsView.visible)
278
279 currentIndex: 0
280
281 Connections {
282 target: ClientWrapper.accountAdaptor
283
284 function onAccountSignalsReconnect(accountId) {
285 CallAdapter.connectCallModel(accountId)
286 ConversationsAdapter.accountChangedSetUp(accountId)
287 mainViewWindowSidePanel.accountSignalsReconnect(accountId)
288 }
289
290 function onUpdateConversationForAddedContact() {
291 mainViewWindowSidePanel.needToUpdateConversationForAddedContact()
292 }
293
294 function onAccountStatusChanged() {
295 accountComboBox.updateAccountListModel()
296 }
297 }
298
299 onSettingBtnClicked: {
300 toggleSettingsView()
301 }
302
303 onAccountChanged: {
304 ClientWrapper.accountAdaptor.accountChanged(index)
305 mainViewWindowSidePanel.refreshAccountComboBox(0)
306 settingsView.slotAccountListChanged()
307 settingsView.setSelected(settingsView.selectedMenu, true)
308
309 if (needToShowCallStack
310 && callStackView.responsibleAccountId === ClientWrapper.utilsAdaptor.getCurrAccId()){
311 if (!ClientWrapper.accountAdaptor.hasVideoCall()) {
312 pushCommunicationMessageWebView()
313 needToShowCallStack = false
314 } else if (needToShowCallStack) {
315 pushCallStackView()
316 }
317 }
318 }
319
320 onNeedToUpdateSmartList: {
321 mainViewWindowSidePanel.updateSmartList(accountId)
322 }
323
324 onNeedToBackToWelcomePage: {
325 if (!inSettingsView)
326 mainViewWindowSidePanel.accountComboBoxNeedToShowWelcomePage(index)
327 }
328
329 onNewAccountButtonClicked: {
330 mainViewWindowSidePanel.needToAddNewAccount()
331 }
332
333 Component.onCompleted: {
334 ClientWrapper.accountAdaptor.setQmlObject(this)
335 }
336 }
337
338 StackView {
339 id: sidePanelViewStack
340
341 initialItem: mainViewWindowSidePanel
342
343 anchors.top: accountComboBox.visible ? accountComboBox.bottom : mainViewSidePanelRect.top
344 width: mainViewSidePanelRect.width
345 height: accountComboBox.visible ? mainViewSidePanelRect.height - accountComboBox.height :
346 mainViewSidePanelRect.height
347
348 clip: true
349 }
Sébastien Blin1f915762020-08-03 13:27:42 -0400350 }
351
352 StackView {
ababia284cae2020-08-10 12:33:34 +0200353 id: mainViewStack
Sébastien Blin1f915762020-08-03 13:27:42 -0400354
355 initialItem: welcomePage
356
ababia284cae2020-08-10 12:33:34 +0200357 SplitView.maximumWidth: sidePanelHidden ? splitView.width : splitView.width - sidePanelViewStackPreferredWidth
358 SplitView.minimumWidth: sidePanelViewStackPreferredWidth
Sébastien Blin1f915762020-08-03 13:27:42 -0400359 SplitView.fillHeight: true
360
361 clip: true
362 }
363 }
Sébastien Blin1f915762020-08-03 13:27:42 -0400364 }
365
366 AccountListModel {
367 id: accountListModel
368 }
369
ababia284cae2020-08-10 12:33:34 +0200370
371 LeftPanelView {
372 id: leftPanelSettingsView
373 visible: false
374 contentViewportWidth: mainViewSidePanelRect.width
375 contentViewPortHeight: mainViewSidePanelRect.height
376
377 Connections {
378 target: leftPanelSettingsView.btnAccountSettings
379 function onCheckedToggledForRightPanel(checked) {
380 settingsView.setSelected(SettingsView.Account)
381 if (sidePanelHidden) {
382 recursionStackViewItemMove(mainViewStack, sidePanelViewStack, 1)
383 }
384 }
385 }
386 Connections {
387 target: leftPanelSettingsView.btnGeneralSettings
388 function onCheckedToggledForRightPanel(checked) {
389 settingsView.setSelected(SettingsView.General)
390 if (sidePanelHidden) {
391 recursionStackViewItemMove(mainViewStack, sidePanelViewStack, 1)
392 }
393 }
394 }
395 Connections {
396 target: leftPanelSettingsView.btnMediaSettings
397 function onCheckedToggledForRightPanel(checked) {
398 settingsView.setSelected(SettingsView.Media)
399 if (sidePanelHidden) {
400 recursionStackViewItemMove(mainViewStack, sidePanelViewStack, 1)
401 }
402 }
403 }
404 Connections {
405 target: leftPanelSettingsView.btnPluginSettings
406 function onCheckedToggledForRightPanel(checked) {
407 settingsView.setSelected(SettingsView.Plugin)
408 if (sidePanelHidden) {
409 recursionStackViewItemMove(mainViewStack, sidePanelViewStack, 1)
410 }
411 }
412 }
413 }
414
415
Sébastien Blin1f915762020-08-03 13:27:42 -0400416 SidePanel {
417 id: mainViewWindowSidePanel
418
Sébastien Blin1f915762020-08-03 13:27:42 -0400419 onConversationSmartListNeedToAccessMessageWebView: {
420
421 communicationPageMessageWebView.headerUserAliasLabelText = currentUserAlias
422 communicationPageMessageWebView.headerUserUserNameLabelText = currentUserDisplayName
423
424 callStackView.needToCloseInCallConversationAndPotentialWindow()
425 callStackView.responsibleAccountId = ClientWrapper.utilsAdaptor.getCurrAccId()
426 callStackView.responsibleConvUid = currentUID
427 callStackView.updateCorrspondingUI()
428
429 if (callStackViewShouldShow) {
430 if (callStateStr == "Talking" || callStateStr == "Hold") {
431 ClientWrapper.utilsAdaptor.setCurrentCall(
432 ClientWrapper.utilsAdaptor.getCurrAccId(),
433 currentUID)
434 if (isAudioOnly)
435 callStackView.showAudioCallPage()
436 else
437 callStackView.showVideoCallPage(
438 ClientWrapper.utilsAdaptor.getCallId(
439 callStackView.responsibleAccountId,
440 callStackView.responsibleConvUid))
441 } else {
442 callStackView.showOutgoingCallPage(callStateStr)
443 }
444 }
445
446
447 /*
448 * Set up chatview.
449 */
450 MessagesAdapter.setupChatView(currentUID)
Sébastien Blin8940f3c2020-07-23 17:03:11 -0400451 callStackView.setLinkedWebview(
Sébastien Blin1f915762020-08-03 13:27:42 -0400452 communicationPageMessageWebView)
453
ababia284cae2020-08-10 12:33:34 +0200454 if (mainViewStack.find(function (item, index) {
Sébastien Blin1f915762020-08-03 13:27:42 -0400455 return item.objectName === "communicationPageMessageWebView"
456 }) || sidePanelViewStack.find(function (item, index) {
457 return item.objectName === "communicationPageMessageWebView"
458 })) {
459 if (!callStackViewShouldShow)
460 return
461 }
462
463
464 /*
465 * Push messageWebView or callStackView onto the correct stackview
466 */
ababia284cae2020-08-10 12:33:34 +0200467 mainViewStack.pop(null, StackView.Immediate)
Sébastien Blin1f915762020-08-03 13:27:42 -0400468 sidePanelViewStack.pop(null, StackView.Immediate)
469
ababia284cae2020-08-10 12:33:34 +0200470 if (sidePanelViewStack.visible && mainViewStack.visible) {
Sébastien Blin1f915762020-08-03 13:27:42 -0400471 if (callStackViewShouldShow) {
ababia284cae2020-08-10 12:33:34 +0200472 mainViewStack.push(callStackView)
Sébastien Blin1f915762020-08-03 13:27:42 -0400473 } else {
ababia284cae2020-08-10 12:33:34 +0200474 mainViewStack.push(communicationPageMessageWebView)
Sébastien Blin1f915762020-08-03 13:27:42 -0400475 }
476 } else if (sidePanelViewStack.visible
ababia284cae2020-08-10 12:33:34 +0200477 && !mainViewStack.visible) {
Sébastien Blin1f915762020-08-03 13:27:42 -0400478 if (callStackViewShouldShow) {
479 sidePanelViewStack.push(callStackView)
480 } else {
481 sidePanelViewStack.push(communicationPageMessageWebView)
482 }
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 }
491 }
492
493 onAccountComboBoxNeedToShowWelcomePage: {
494
Sébastien Blin1f915762020-08-03 13:27:42 -0400495 /*
496 * If the item argument is specified, all items down to (but not including) item will be popped.
497 */
ababia284cae2020-08-10 12:33:34 +0200498 if (!inSettingsView) {
499 mainViewStack.pop(welcomePage)
500 welcomePage.currentAccountIndex = index
501 qrDialog.currentAccountIndex = index
502 }
Sébastien Blin1f915762020-08-03 13:27:42 -0400503 }
504
505 onConversationSmartListViewNeedToShowWelcomePage: {
ababia284cae2020-08-10 12:33:34 +0200506 mainViewStack.pop(welcomePage)
Sébastien Blin1f915762020-08-03 13:27:42 -0400507 welcomePage.currentAccountIndex = 0
508 qrDialog.currentAccountIndex = 0
509 }
510
511 onAccountSignalsReconnect: {
512 MessagesAdapter.accountChangedSetUp(accountId)
513 }
514
515 onNeedToUpdateConversationForAddedContact: {
516 MessagesAdapter.updateConversationForAddedContact()
517 mainViewWindowSidePanel.clearContactSearchBar()
518 mainViewWindowSidePanel.forceReselectConversationSmartListCurrentIndex()
519 }
520
521 onNeedToAddNewAccount: {
522 mainViewWindow.needToAddNewAccount()
523 }
524 }
525
526 CallStackView {
527 id: callStackView
528
529 visible: false
530
531 objectName: "callStackViewObject"
ababia284cae2020-08-10 12:33:34 +0200532
Sébastien Blin1f915762020-08-03 13:27:42 -0400533 }
534
535 WelcomePage {
536 id: welcomePage
537 visible: false
538 }
539
ababia284cae2020-08-10 12:33:34 +0200540 SettingsView {
541 id: settingsView
542
543 visible: false
544
545 width: Math.max(mainViewStackPreferredWidth, mainViewStack.width - 100)
546 height: mainViewWindow.minimumHeight
547
548 onSettingsViewWindowNeedToShowMainViewWindow: {
549 mainViewWindowSidePanel.refreshAccountComboBox(
550 accountDeleted ? 0 : -1)
551 toggleSettingsView()
552 }
553
554 onSettingsViewWindowNeedToShowNewWizardWindow: {
555 mainViewWindow.noAccountIsAvailable()
556 }
557
558 onSettingsBackArrowClicked: {
559 mainViewStack.pop(StackView.Immediate)
560 recursionStackViewItemMove(sidePanelViewStack, mainViewStack, 2)
561 }
562 }
563
Sébastien Blin1f915762020-08-03 13:27:42 -0400564 MessageWebView {
565 id: communicationPageMessageWebView
566
567 objectName: "communicationPageMessageWebView"
568
569 signal toSendMessageContentSaved(string arg)
570 signal toMessagesCleared
571 signal toMessagesLoaded
572
573 visible: false
574
575 Connections {
576 target: MessagesAdapter
577
578 function onNeedToUpdateSmartList() {
579 mainViewWindowSidePanel.forceUpdateConversationSmartListView()
580 }
581 }
582
583 onNeedToGoBackToWelcomeView: {
584 mainViewWindowSidePanel.deselectConversationSmartList()
585 if (communicationPageMessageWebView.visible
ababia284cae2020-08-10 12:33:34 +0200586 && !mainViewStack.visible) {
Sébastien Blin1f915762020-08-03 13:27:42 -0400587 sidePanelViewStack.pop()
588 } else if (communicationPageMessageWebView.visible
ababia284cae2020-08-10 12:33:34 +0200589 && mainViewStack.visible) {
590 mainViewStack.pop()
Sébastien Blin1f915762020-08-03 13:27:42 -0400591 }
592 }
593
594 Component.onCompleted: {
Sébastien Blin1f915762020-08-03 13:27:42 -0400595
596 /*
597 * Set qml MessageWebView object pointer to c++.
598 */
599 MessagesAdapter.setQmlObject(this)
600 }
601 }
602
603 onWidthChanged: {
604
605
606 /*
607 * Hide unnecessary stackview when width is changed.
608 */
ababia284cae2020-08-10 12:33:34 +0200609 if (mainViewWindow.width < sidePanelViewStackPreferredWidth
610 + mainViewStackPreferredWidth - 5
611 && mainViewStack.visible) {
612 mainViewStack.visible = false
613 sidePanelHidden = true
Sébastien Blin1f915762020-08-03 13:27:42 -0400614
615 /*
616 * The find callback function is called for each item in the stack.
617 */
ababia284cae2020-08-10 12:33:34 +0200618 var inWelcomeViewStack = mainViewStack.find(
Sébastien Blin1f915762020-08-03 13:27:42 -0400619 function (item, index) {
620 return index > 0
621 })
ababidf651a22020-07-30 13:38:57 +0200622
Sébastien Blin1f915762020-08-03 13:27:42 -0400623 if (inWelcomeViewStack) {
ababia284cae2020-08-10 12:33:34 +0200624 recursionStackViewItemMove(mainViewStack, sidePanelViewStack)
Sébastien Blin1f915762020-08-03 13:27:42 -0400625 }
626
Sébastien Blin1f915762020-08-03 13:27:42 -0400627 mainViewWindow.update()
ababia284cae2020-08-10 12:33:34 +0200628 } else if (mainViewWindow.width >= sidePanelViewStackPreferredWidth
629 + mainViewStackPreferredWidth + 5
630 && !mainViewStack.visible) {
631 mainViewStack.visible = true
632 sidePanelHidden = false
Sébastien Blin1f915762020-08-03 13:27:42 -0400633
634 var inSidePanelViewStack = sidePanelViewStack.find(
635 function (item, index) {
636 return index > 0
637 })
638 if (inSidePanelViewStack) {
ababia284cae2020-08-10 12:33:34 +0200639 recursionStackViewItemMove(sidePanelViewStack, mainViewStack, (inSettingsView ? 2 : 1))
Sébastien Blin1f915762020-08-03 13:27:42 -0400640 }
641
Sébastien Blin1f915762020-08-03 13:27:42 -0400642 mainViewWindow.update()
643 }
644 }
645
646 AboutPopUp {
647 id: aboutPopUpDialog
648
649 x: Math.round((mainViewWindow.width - width) / 2)
650 y: Math.round((mainViewWindow.height - height) / 2)
ababia284cae2020-08-10 12:33:34 +0200651 width: Math.max(mainViewWindow.width / 2, aboutPopUpPreferredWidth)
Sébastien Blin1f915762020-08-03 13:27:42 -0400652 height: aboutPopUpDialog.contentHeight
653 }
654
655 WelcomePageQrDialog {
656 id: qrDialog
657
658 x: Math.round((mainViewWindow.width - width) / 2)
659 y: Math.round((mainViewWindow.height - height) / 2)
660 width: qrDialog.contentHeight
661 height: qrDialog.contentHeight
662 }
663
664 RecordBox{
665 id: recordBox
666 visible: false
ababia284cae2020-08-10 12:33:34 +0200667
668 Component.onCompleted: {
669 recordBox.x = Qt.binding(function() {
670 var i = (mainViewStack.width > 1000 ? Math.round((mainViewStack.width-1000)*0.5) : 0)
671 return sidePanelViewStack.width + recordBox.x_offset + i
672 })
673
674 recordBox.y = Qt.binding(function() {
675 return mainViewStack.height + recordBox.y_offset
676 })
677 }
Sébastien Blin1f915762020-08-03 13:27:42 -0400678 }
679
680 UserProfile {
681 id: userProfile
682
683 x: Math.round((mainViewWindow.width - width) / 2)
684 y: Math.round((mainViewWindow.height - height) / 2)
ababia284cae2020-08-10 12:33:34 +0200685 width: Math.max(mainViewWindow.width / 2, aboutPopUpPreferredWidth)
Sébastien Blin1f915762020-08-03 13:27:42 -0400686 height: userProfile.contentHeight
687 }
688
689 Component.onCompleted: {
690 CallAdapter.initQmlObject()
691 }
692
693 onClosing: {
694 close.accepted = false
695 mainViewWindow.hide()
696 mainViewWindow.closeApp()
697 }
698}