blob: 9279f2dfacfd22862051ba1913c8185b2fbc56cc [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
ababia284cae2020-08-10 12:33:34 +020039 property int minWidth: sidePanelViewStackPreferredWidth
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 Blinc75335f2020-08-04 20:54:02 -040044 property int sidePanelViewStackPreferredWidth: 400
ababia284cae2020-08-10 12:33:34 +020045 property int mainViewStackPreferredWidth: 250
46 property int aboutPopUpPreferredWidth: 250
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 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
Sébastien Blinc75335f2020-08-04 20:54:02 -0400233 WizardView {
234 id: wizardView
235
236 anchors.fill: parent
237
238 onNeedToShowMainViewWindow: {
239 mainViewLoader.newAddedAccountIndex = accountIndex
240 if (mainViewLoader.source.toString() !== "qrc:/src/mainview/MainView.qml") {
241 mainViewLoader.loaded.disconnect(slotNewAccountAdded)
242 mainViewLoader.loaded.connect(slotNewAccountAdded)
243 mainViewLoader.setSource("qrc:/src/mainview/MainView.qml")
244 } else {
245 slotNewAccountAdded()
246 }
247 mainViewStackLayout.currentIndex = 0
248 }
249
250 onWizardViewIsClosed: {
251 mainViewStackLayout.currentIndex = 0
252 }
253 }
254
Sébastien Blin1f915762020-08-03 13:27:42 -0400255 StackLayout {
256 id: mainViewStackLayout
257
258 anchors.fill: parent
259
260 currentIndex: 0
261
262 SplitView {
263 id: splitView
264
265 Layout.fillWidth: true
266 Layout.fillHeight: true
267
268 width: mainViewWindow.width
269 height: mainViewWindow.height
270
271 handle: Rectangle {
ababia284cae2020-08-10 12:33:34 +0200272 implicitWidth: JamiTheme.splitViewHandlePreferredWidth
Sébastien Blin1f915762020-08-03 13:27:42 -0400273 implicitHeight: splitView.height
ababi6fa08612020-08-10 19:13:28 +0200274 color:"white"
ababidf651a22020-07-30 13:38:57 +0200275 Rectangle {
276 implicitWidth: 1
277 implicitHeight: splitView.height
278 color: SplitHandle.pressed ? JamiTheme.pressColor : (SplitHandle.hovered ? JamiTheme.hoverColor : JamiTheme.tabbarBorderColor)
279 }
Sébastien Blin1f915762020-08-03 13:27:42 -0400280 }
281
ababia284cae2020-08-10 12:33:34 +0200282 Rectangle {
283 id: mainViewSidePanelRect
284 SplitView.minimumWidth: sidePanelViewStackPreferredWidth
285 SplitView.maximumWidth: (sidePanelHidden ? splitView.width :
286 splitView.width - sidePanelViewStackPreferredWidth)
Sébastien Blin1f915762020-08-03 13:27:42 -0400287 SplitView.fillHeight: true
288
ababia284cae2020-08-10 12:33:34 +0200289 /*
290 * AccountComboBox is always visible
291 */
292 AccountComboBox {
293 id: accountComboBox
294
295 anchors.top: mainViewSidePanelRect.top
296 width: mainViewSidePanelRect.width
297 height: 64
298
299 visible: (mainViewWindowSidePanel.visible || leftPanelSettingsView.visible)
300
301 currentIndex: 0
302
303 Connections {
304 target: ClientWrapper.accountAdaptor
305
306 function onAccountSignalsReconnect(accountId) {
307 CallAdapter.connectCallModel(accountId)
308 ConversationsAdapter.accountChangedSetUp(accountId)
309 mainViewWindowSidePanel.accountSignalsReconnect(accountId)
310 }
311
312 function onUpdateConversationForAddedContact() {
313 mainViewWindowSidePanel.needToUpdateConversationForAddedContact()
314 }
315
316 function onAccountStatusChanged() {
317 accountComboBox.updateAccountListModel()
318 }
319 }
320
321 onSettingBtnClicked: {
322 toggleSettingsView()
323 }
324
325 onAccountChanged: {
326 ClientWrapper.accountAdaptor.accountChanged(index)
327 mainViewWindowSidePanel.refreshAccountComboBox(0)
328 settingsView.slotAccountListChanged()
329 settingsView.setSelected(settingsView.selectedMenu, true)
330
331 if (needToShowCallStack
332 && callStackView.responsibleAccountId === ClientWrapper.utilsAdaptor.getCurrAccId()){
333 if (!ClientWrapper.accountAdaptor.hasVideoCall()) {
334 pushCommunicationMessageWebView()
335 needToShowCallStack = false
336 } else if (needToShowCallStack) {
337 pushCallStackView()
338 }
339 }
340 }
341
342 onNeedToUpdateSmartList: {
343 mainViewWindowSidePanel.updateSmartList(accountId)
344 }
345
346 onNeedToBackToWelcomePage: {
347 if (!inSettingsView)
348 mainViewWindowSidePanel.accountComboBoxNeedToShowWelcomePage(index)
349 }
350
351 onNewAccountButtonClicked: {
352 mainViewWindowSidePanel.needToAddNewAccount()
353 }
354
355 Component.onCompleted: {
356 ClientWrapper.accountAdaptor.setQmlObject(this)
357 }
358 }
359
360 StackView {
361 id: sidePanelViewStack
362
363 initialItem: mainViewWindowSidePanel
364
365 anchors.top: accountComboBox.visible ? accountComboBox.bottom : mainViewSidePanelRect.top
366 width: mainViewSidePanelRect.width
367 height: accountComboBox.visible ? mainViewSidePanelRect.height - accountComboBox.height :
368 mainViewSidePanelRect.height
369
370 clip: true
371 }
Sébastien Blin1f915762020-08-03 13:27:42 -0400372 }
373
374 StackView {
ababia284cae2020-08-10 12:33:34 +0200375 id: mainViewStack
Sébastien Blin1f915762020-08-03 13:27:42 -0400376
377 initialItem: welcomePage
378
ababia284cae2020-08-10 12:33:34 +0200379 SplitView.maximumWidth: sidePanelHidden ? splitView.width : splitView.width - sidePanelViewStackPreferredWidth
380 SplitView.minimumWidth: sidePanelViewStackPreferredWidth
Sébastien Blin1f915762020-08-03 13:27:42 -0400381 SplitView.fillHeight: true
382
383 clip: true
384 }
385 }
Sébastien Blin1f915762020-08-03 13:27:42 -0400386 }
387
388 AccountListModel {
389 id: accountListModel
390 }
391
ababia284cae2020-08-10 12:33:34 +0200392
393 LeftPanelView {
394 id: leftPanelSettingsView
395 visible: false
396 contentViewportWidth: mainViewSidePanelRect.width
397 contentViewPortHeight: mainViewSidePanelRect.height
398
399 Connections {
400 target: leftPanelSettingsView.btnAccountSettings
401 function onCheckedToggledForRightPanel(checked) {
402 settingsView.setSelected(SettingsView.Account)
403 if (sidePanelHidden) {
404 recursionStackViewItemMove(mainViewStack, sidePanelViewStack, 1)
405 }
406 }
407 }
408 Connections {
409 target: leftPanelSettingsView.btnGeneralSettings
410 function onCheckedToggledForRightPanel(checked) {
411 settingsView.setSelected(SettingsView.General)
412 if (sidePanelHidden) {
413 recursionStackViewItemMove(mainViewStack, sidePanelViewStack, 1)
414 }
415 }
416 }
417 Connections {
418 target: leftPanelSettingsView.btnMediaSettings
419 function onCheckedToggledForRightPanel(checked) {
420 settingsView.setSelected(SettingsView.Media)
421 if (sidePanelHidden) {
422 recursionStackViewItemMove(mainViewStack, sidePanelViewStack, 1)
423 }
424 }
425 }
426 Connections {
427 target: leftPanelSettingsView.btnPluginSettings
428 function onCheckedToggledForRightPanel(checked) {
429 settingsView.setSelected(SettingsView.Plugin)
430 if (sidePanelHidden) {
431 recursionStackViewItemMove(mainViewStack, sidePanelViewStack, 1)
432 }
433 }
434 }
435 }
436
437
Sébastien Blin1f915762020-08-03 13:27:42 -0400438 SidePanel {
439 id: mainViewWindowSidePanel
440
Sébastien Blin1f915762020-08-03 13:27:42 -0400441 onConversationSmartListNeedToAccessMessageWebView: {
442
443 communicationPageMessageWebView.headerUserAliasLabelText = currentUserAlias
444 communicationPageMessageWebView.headerUserUserNameLabelText = currentUserDisplayName
445
446 callStackView.needToCloseInCallConversationAndPotentialWindow()
447 callStackView.responsibleAccountId = ClientWrapper.utilsAdaptor.getCurrAccId()
448 callStackView.responsibleConvUid = currentUID
449 callStackView.updateCorrspondingUI()
450
451 if (callStackViewShouldShow) {
452 if (callStateStr == "Talking" || callStateStr == "Hold") {
453 ClientWrapper.utilsAdaptor.setCurrentCall(
454 ClientWrapper.utilsAdaptor.getCurrAccId(),
455 currentUID)
456 if (isAudioOnly)
457 callStackView.showAudioCallPage()
458 else
459 callStackView.showVideoCallPage(
460 ClientWrapper.utilsAdaptor.getCallId(
461 callStackView.responsibleAccountId,
462 callStackView.responsibleConvUid))
463 } else {
464 callStackView.showOutgoingCallPage(callStateStr)
465 }
466 }
467
468
469 /*
470 * Set up chatview.
471 */
472 MessagesAdapter.setupChatView(currentUID)
Sébastien Blin8940f3c2020-07-23 17:03:11 -0400473 callStackView.setLinkedWebview(
Sébastien Blin1f915762020-08-03 13:27:42 -0400474 communicationPageMessageWebView)
475
ababia284cae2020-08-10 12:33:34 +0200476 if (mainViewStack.find(function (item, index) {
Sébastien Blin1f915762020-08-03 13:27:42 -0400477 return item.objectName === "communicationPageMessageWebView"
478 }) || sidePanelViewStack.find(function (item, index) {
479 return item.objectName === "communicationPageMessageWebView"
480 })) {
481 if (!callStackViewShouldShow)
482 return
483 }
484
485
486 /*
487 * Push messageWebView or callStackView onto the correct stackview
488 */
ababia284cae2020-08-10 12:33:34 +0200489 mainViewStack.pop(null, StackView.Immediate)
Sébastien Blin1f915762020-08-03 13:27:42 -0400490 sidePanelViewStack.pop(null, StackView.Immediate)
491
ababia284cae2020-08-10 12:33:34 +0200492 if (sidePanelViewStack.visible && mainViewStack.visible) {
Sébastien Blin1f915762020-08-03 13:27:42 -0400493 if (callStackViewShouldShow) {
ababia284cae2020-08-10 12:33:34 +0200494 mainViewStack.push(callStackView)
Sébastien Blin1f915762020-08-03 13:27:42 -0400495 } else {
ababia284cae2020-08-10 12:33:34 +0200496 mainViewStack.push(communicationPageMessageWebView)
Sébastien Blin1f915762020-08-03 13:27:42 -0400497 }
498 } else if (sidePanelViewStack.visible
ababia284cae2020-08-10 12:33:34 +0200499 && !mainViewStack.visible) {
Sébastien Blin1f915762020-08-03 13:27:42 -0400500 if (callStackViewShouldShow) {
501 sidePanelViewStack.push(callStackView)
502 } else {
503 sidePanelViewStack.push(communicationPageMessageWebView)
504 }
505 } else if (!sidePanelViewStack.visible
ababia284cae2020-08-10 12:33:34 +0200506 && !mainViewStack.visible) {
Sébastien Blin1f915762020-08-03 13:27:42 -0400507 if (callStackViewShouldShow) {
508 sidePanelViewStack.push(callStackView)
509 } else {
510 sidePanelViewStack.push(communicationPageMessageWebView)
511 }
512 }
513 }
514
515 onAccountComboBoxNeedToShowWelcomePage: {
516
Sébastien Blin1f915762020-08-03 13:27:42 -0400517 /*
518 * If the item argument is specified, all items down to (but not including) item will be popped.
519 */
ababia284cae2020-08-10 12:33:34 +0200520 if (!inSettingsView) {
521 mainViewStack.pop(welcomePage)
522 welcomePage.currentAccountIndex = index
523 qrDialog.currentAccountIndex = index
524 }
Sébastien Blin1f915762020-08-03 13:27:42 -0400525 }
526
527 onConversationSmartListViewNeedToShowWelcomePage: {
ababia284cae2020-08-10 12:33:34 +0200528 mainViewStack.pop(welcomePage)
Sébastien Blin1f915762020-08-03 13:27:42 -0400529 welcomePage.currentAccountIndex = 0
530 qrDialog.currentAccountIndex = 0
531 }
532
533 onAccountSignalsReconnect: {
534 MessagesAdapter.accountChangedSetUp(accountId)
535 }
536
537 onNeedToUpdateConversationForAddedContact: {
538 MessagesAdapter.updateConversationForAddedContact()
539 mainViewWindowSidePanel.clearContactSearchBar()
540 mainViewWindowSidePanel.forceReselectConversationSmartListCurrentIndex()
541 }
542
543 onNeedToAddNewAccount: {
Sébastien Blinc75335f2020-08-04 20:54:02 -0400544 mainViewStackLayout.currentIndex = 2
Sébastien Blin1f915762020-08-03 13:27:42 -0400545 }
546 }
547
548 CallStackView {
549 id: callStackView
550
551 visible: false
552
553 objectName: "callStackViewObject"
ababia284cae2020-08-10 12:33:34 +0200554
Sébastien Blin1f915762020-08-03 13:27:42 -0400555 }
556
557 WelcomePage {
558 id: welcomePage
559 visible: false
560 }
561
ababia284cae2020-08-10 12:33:34 +0200562 SettingsView {
563 id: settingsView
564
565 visible: false
566
567 width: Math.max(mainViewStackPreferredWidth, mainViewStack.width - 100)
568 height: mainViewWindow.minimumHeight
569
570 onSettingsViewWindowNeedToShowMainViewWindow: {
571 mainViewWindowSidePanel.refreshAccountComboBox(
572 accountDeleted ? 0 : -1)
573 toggleSettingsView()
574 }
575
576 onSettingsViewWindowNeedToShowNewWizardWindow: {
577 mainViewWindow.noAccountIsAvailable()
578 }
579
580 onSettingsBackArrowClicked: {
581 mainViewStack.pop(StackView.Immediate)
582 recursionStackViewItemMove(sidePanelViewStack, mainViewStack, 2)
583 }
584 }
585
Sébastien Blin1f915762020-08-03 13:27:42 -0400586 MessageWebView {
587 id: communicationPageMessageWebView
588
589 objectName: "communicationPageMessageWebView"
590
591 signal toSendMessageContentSaved(string arg)
592 signal toMessagesCleared
593 signal toMessagesLoaded
594
595 visible: false
596
597 Connections {
598 target: MessagesAdapter
599
600 function onNeedToUpdateSmartList() {
601 mainViewWindowSidePanel.forceUpdateConversationSmartListView()
602 }
603 }
604
605 onNeedToGoBackToWelcomeView: {
606 mainViewWindowSidePanel.deselectConversationSmartList()
607 if (communicationPageMessageWebView.visible
ababia284cae2020-08-10 12:33:34 +0200608 && !mainViewStack.visible) {
Sébastien Blin1f915762020-08-03 13:27:42 -0400609 sidePanelViewStack.pop()
610 } else if (communicationPageMessageWebView.visible
ababia284cae2020-08-10 12:33:34 +0200611 && mainViewStack.visible) {
612 mainViewStack.pop()
Sébastien Blin1f915762020-08-03 13:27:42 -0400613 }
614 }
615
616 Component.onCompleted: {
Sébastien Blin1f915762020-08-03 13:27:42 -0400617
Sébastien Blinc75335f2020-08-04 20:54:02 -0400618 sidePanelViewStack.SplitView.maximumWidth = Qt.binding(function() {
619 return (hiddenView ? splitView.width : splitView.width - sidePanelViewStackPreferedWidth)
620 })
621
622 recordBox.x = Qt.binding(function() {
623 var i = (welcomeViewStack.width > 1000 ? Math.round((welcomeViewStack.width-1000)*0.5) : 0)
624 return sidePanelViewStack.width + recordBox.x_offset + i
625 })
626
627 recordBox.y = Qt.binding(function() {
628 return sidePanelViewStack.height + recordBox.y_offset
629 })
630
631
Sébastien Blin1f915762020-08-03 13:27:42 -0400632 /*
633 * Set qml MessageWebView object pointer to c++.
634 */
635 MessagesAdapter.setQmlObject(this)
636 }
637 }
638
639 onWidthChanged: {
640
641
642 /*
643 * Hide unnecessary stackview when width is changed.
644 */
ababia284cae2020-08-10 12:33:34 +0200645 if (mainViewWindow.width < sidePanelViewStackPreferredWidth
646 + mainViewStackPreferredWidth - 5
647 && mainViewStack.visible) {
648 mainViewStack.visible = false
649 sidePanelHidden = true
Sébastien Blin1f915762020-08-03 13:27:42 -0400650
651 /*
652 * The find callback function is called for each item in the stack.
653 */
ababia284cae2020-08-10 12:33:34 +0200654 var inWelcomeViewStack = mainViewStack.find(
Sébastien Blin1f915762020-08-03 13:27:42 -0400655 function (item, index) {
656 return index > 0
657 })
ababidf651a22020-07-30 13:38:57 +0200658
Sébastien Blin1f915762020-08-03 13:27:42 -0400659 if (inWelcomeViewStack) {
ababia284cae2020-08-10 12:33:34 +0200660 recursionStackViewItemMove(mainViewStack, sidePanelViewStack)
Sébastien Blin1f915762020-08-03 13:27:42 -0400661 }
662
Sébastien Blin1f915762020-08-03 13:27:42 -0400663 mainViewWindow.update()
ababia284cae2020-08-10 12:33:34 +0200664 } else if (mainViewWindow.width >= sidePanelViewStackPreferredWidth
665 + mainViewStackPreferredWidth + 5
666 && !mainViewStack.visible) {
667 mainViewStack.visible = true
668 sidePanelHidden = false
Sébastien Blin1f915762020-08-03 13:27:42 -0400669
670 var inSidePanelViewStack = sidePanelViewStack.find(
671 function (item, index) {
672 return index > 0
673 })
674 if (inSidePanelViewStack) {
ababia284cae2020-08-10 12:33:34 +0200675 recursionStackViewItemMove(sidePanelViewStack, mainViewStack, (inSettingsView ? 2 : 1))
Sébastien Blin1f915762020-08-03 13:27:42 -0400676 }
677
Sébastien Blin1f915762020-08-03 13:27:42 -0400678 mainViewWindow.update()
679 }
680 }
681
682 AboutPopUp {
683 id: aboutPopUpDialog
684
685 x: Math.round((mainViewWindow.width - width) / 2)
686 y: Math.round((mainViewWindow.height - height) / 2)
ababia284cae2020-08-10 12:33:34 +0200687 width: Math.max(mainViewWindow.width / 2, aboutPopUpPreferredWidth)
Sébastien Blin1f915762020-08-03 13:27:42 -0400688 height: aboutPopUpDialog.contentHeight
689 }
690
691 WelcomePageQrDialog {
692 id: qrDialog
693
694 x: Math.round((mainViewWindow.width - width) / 2)
695 y: Math.round((mainViewWindow.height - height) / 2)
696 width: qrDialog.contentHeight
697 height: qrDialog.contentHeight
698 }
699
700 RecordBox{
701 id: recordBox
702 visible: false
ababia284cae2020-08-10 12:33:34 +0200703
704 Component.onCompleted: {
705 recordBox.x = Qt.binding(function() {
706 var i = (mainViewStack.width > 1000 ? Math.round((mainViewStack.width-1000)*0.5) : 0)
707 return sidePanelViewStack.width + recordBox.x_offset + i
708 })
709
710 recordBox.y = Qt.binding(function() {
711 return mainViewStack.height + recordBox.y_offset
712 })
713 }
Sébastien Blin1f915762020-08-03 13:27:42 -0400714 }
715
716 UserProfile {
717 id: userProfile
718
719 x: Math.round((mainViewWindow.width - width) / 2)
720 y: Math.round((mainViewWindow.height - height) / 2)
ababia284cae2020-08-10 12:33:34 +0200721 width: Math.max(mainViewWindow.width / 2, aboutPopUpPreferredWidth)
Sébastien Blin1f915762020-08-03 13:27:42 -0400722 height: userProfile.contentHeight
723 }
724
725 Component.onCompleted: {
726 CallAdapter.initQmlObject()
727 }
728
729 onClosing: {
730 close.accepted = false
731 mainViewWindow.hide()
732 mainViewWindow.closeApp()
733 }
734}