blob: d7a0a89ee1ed9ab83f0ab900f45a6574957f28a2 [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
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 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 {
230 id: wizardView
231
232 anchors.fill: parent
233
234 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()
242 }
243 mainViewStackLayout.currentIndex = 0
244 }
245
246 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
302 function onAccountSignalsReconnect(accountId) {
303 CallAdapter.connectCallModel(accountId)
ababia284cae2020-08-10 12:33:34 +0200304 mainViewWindowSidePanel.accountSignalsReconnect(accountId)
ababi69f5dfc2020-08-25 15:07:57 +0200305 ConversationsAdapter.accountChangedSetUp(accountId)
ababia284cae2020-08-10 12:33:34 +0200306 }
307
308 function onUpdateConversationForAddedContact() {
309 mainViewWindowSidePanel.needToUpdateConversationForAddedContact()
310 }
311
312 function onAccountStatusChanged() {
313 accountComboBox.updateAccountListModel()
314 }
315 }
316
317 onSettingBtnClicked: {
318 toggleSettingsView()
319 }
320
321 onAccountChanged: {
ababi69f5dfc2020-08-25 15:07:57 +0200322 mainViewWindowSidePanel.refreshAccountComboBox(index)
ababia284cae2020-08-10 12:33:34 +0200323 settingsView.slotAccountListChanged()
324 settingsView.setSelected(settingsView.selectedMenu, true)
325
326 if (needToShowCallStack
327 && callStackView.responsibleAccountId === ClientWrapper.utilsAdaptor.getCurrAccId()){
328 if (!ClientWrapper.accountAdaptor.hasVideoCall()) {
329 pushCommunicationMessageWebView()
330 needToShowCallStack = false
331 } else if (needToShowCallStack) {
332 pushCallStackView()
333 }
334 }
335 }
336
337 onNeedToUpdateSmartList: {
338 mainViewWindowSidePanel.updateSmartList(accountId)
339 }
340
341 onNeedToBackToWelcomePage: {
342 if (!inSettingsView)
ababi69f5dfc2020-08-25 15:07:57 +0200343 mainViewWindowSidePanel.accountComboBoxNeedToShowWelcomePage()
ababia284cae2020-08-10 12:33:34 +0200344 }
345
346 onNewAccountButtonClicked: {
347 mainViewWindowSidePanel.needToAddNewAccount()
348 }
349
350 Component.onCompleted: {
351 ClientWrapper.accountAdaptor.setQmlObject(this)
352 }
353 }
354
355 StackView {
356 id: sidePanelViewStack
357
358 initialItem: mainViewWindowSidePanel
359
360 anchors.top: accountComboBox.visible ? accountComboBox.bottom : mainViewSidePanelRect.top
361 width: mainViewSidePanelRect.width
362 height: accountComboBox.visible ? mainViewSidePanelRect.height - accountComboBox.height :
363 mainViewSidePanelRect.height
364
365 clip: true
366 }
Sébastien Blin1f915762020-08-03 13:27:42 -0400367 }
368
369 StackView {
ababia284cae2020-08-10 12:33:34 +0200370 id: mainViewStack
Sébastien Blin1f915762020-08-03 13:27:42 -0400371
372 initialItem: welcomePage
373
ababia284cae2020-08-10 12:33:34 +0200374 SplitView.maximumWidth: sidePanelHidden ? splitView.width : splitView.width - sidePanelViewStackPreferredWidth
375 SplitView.minimumWidth: sidePanelViewStackPreferredWidth
Sébastien Blin1f915762020-08-03 13:27:42 -0400376 SplitView.fillHeight: true
377
378 clip: true
379 }
380 }
Sébastien Blin1f915762020-08-03 13:27:42 -0400381 }
382
383 AccountListModel {
384 id: accountListModel
385 }
386
ababia284cae2020-08-10 12:33:34 +0200387
388 LeftPanelView {
389 id: leftPanelSettingsView
390 visible: false
391 contentViewportWidth: mainViewSidePanelRect.width
392 contentViewPortHeight: mainViewSidePanelRect.height
393
394 Connections {
395 target: leftPanelSettingsView.btnAccountSettings
396 function onCheckedToggledForRightPanel(checked) {
397 settingsView.setSelected(SettingsView.Account)
398 if (sidePanelHidden) {
399 recursionStackViewItemMove(mainViewStack, sidePanelViewStack, 1)
400 }
401 }
402 }
403 Connections {
404 target: leftPanelSettingsView.btnGeneralSettings
405 function onCheckedToggledForRightPanel(checked) {
406 settingsView.setSelected(SettingsView.General)
407 if (sidePanelHidden) {
408 recursionStackViewItemMove(mainViewStack, sidePanelViewStack, 1)
409 }
410 }
411 }
412 Connections {
413 target: leftPanelSettingsView.btnMediaSettings
414 function onCheckedToggledForRightPanel(checked) {
415 settingsView.setSelected(SettingsView.Media)
416 if (sidePanelHidden) {
417 recursionStackViewItemMove(mainViewStack, sidePanelViewStack, 1)
418 }
419 }
420 }
421 Connections {
422 target: leftPanelSettingsView.btnPluginSettings
423 function onCheckedToggledForRightPanel(checked) {
424 settingsView.setSelected(SettingsView.Plugin)
425 if (sidePanelHidden) {
426 recursionStackViewItemMove(mainViewStack, sidePanelViewStack, 1)
427 }
428 }
429 }
430 }
431
432
Sébastien Blin1f915762020-08-03 13:27:42 -0400433 SidePanel {
434 id: mainViewWindowSidePanel
435
Sébastien Blin1f915762020-08-03 13:27:42 -0400436 onConversationSmartListNeedToAccessMessageWebView: {
437
438 communicationPageMessageWebView.headerUserAliasLabelText = currentUserAlias
439 communicationPageMessageWebView.headerUserUserNameLabelText = currentUserDisplayName
440
441 callStackView.needToCloseInCallConversationAndPotentialWindow()
442 callStackView.responsibleAccountId = ClientWrapper.utilsAdaptor.getCurrAccId()
443 callStackView.responsibleConvUid = currentUID
444 callStackView.updateCorrspondingUI()
445
446 if (callStackViewShouldShow) {
447 if (callStateStr == "Talking" || callStateStr == "Hold") {
448 ClientWrapper.utilsAdaptor.setCurrentCall(
449 ClientWrapper.utilsAdaptor.getCurrAccId(),
450 currentUID)
451 if (isAudioOnly)
452 callStackView.showAudioCallPage()
453 else
454 callStackView.showVideoCallPage(
455 ClientWrapper.utilsAdaptor.getCallId(
456 callStackView.responsibleAccountId,
457 callStackView.responsibleConvUid))
458 } else {
459 callStackView.showOutgoingCallPage(callStateStr)
460 }
461 }
462
463
464 /*
465 * Set up chatview.
466 */
467 MessagesAdapter.setupChatView(currentUID)
Sébastien Blin8940f3c2020-07-23 17:03:11 -0400468 callStackView.setLinkedWebview(
Sébastien Blin1f915762020-08-03 13:27:42 -0400469 communicationPageMessageWebView)
470
ababia284cae2020-08-10 12:33:34 +0200471 if (mainViewStack.find(function (item, index) {
Sébastien Blin1f915762020-08-03 13:27:42 -0400472 return item.objectName === "communicationPageMessageWebView"
473 }) || sidePanelViewStack.find(function (item, index) {
474 return item.objectName === "communicationPageMessageWebView"
475 })) {
476 if (!callStackViewShouldShow)
477 return
478 }
479
480
481 /*
482 * Push messageWebView or callStackView onto the correct stackview
483 */
ababia284cae2020-08-10 12:33:34 +0200484 mainViewStack.pop(null, StackView.Immediate)
Sébastien Blin1f915762020-08-03 13:27:42 -0400485 sidePanelViewStack.pop(null, StackView.Immediate)
486
ababia284cae2020-08-10 12:33:34 +0200487 if (sidePanelViewStack.visible && mainViewStack.visible) {
Sébastien Blin1f915762020-08-03 13:27:42 -0400488 if (callStackViewShouldShow) {
ababia284cae2020-08-10 12:33:34 +0200489 mainViewStack.push(callStackView)
Sébastien Blin1f915762020-08-03 13:27:42 -0400490 } else {
ababia284cae2020-08-10 12:33:34 +0200491 mainViewStack.push(communicationPageMessageWebView)
Sébastien Blin1f915762020-08-03 13:27:42 -0400492 }
493 } else if (sidePanelViewStack.visible
ababia284cae2020-08-10 12:33:34 +0200494 && !mainViewStack.visible) {
Sébastien Blin1f915762020-08-03 13:27:42 -0400495 if (callStackViewShouldShow) {
496 sidePanelViewStack.push(callStackView)
497 } else {
498 sidePanelViewStack.push(communicationPageMessageWebView)
499 }
500 } else if (!sidePanelViewStack.visible
ababia284cae2020-08-10 12:33:34 +0200501 && !mainViewStack.visible) {
Sébastien Blin1f915762020-08-03 13:27:42 -0400502 if (callStackViewShouldShow) {
503 sidePanelViewStack.push(callStackView)
504 } else {
505 sidePanelViewStack.push(communicationPageMessageWebView)
506 }
507 }
508 }
509
510 onAccountComboBoxNeedToShowWelcomePage: {
511
Sébastien Blin1f915762020-08-03 13:27:42 -0400512 /*
513 * If the item argument is specified, all items down to (but not including) item will be popped.
514 */
ababia284cae2020-08-10 12:33:34 +0200515 if (!inSettingsView) {
516 mainViewStack.pop(welcomePage)
ababi69f5dfc2020-08-25 15:07:57 +0200517 welcomePage.updateWelcomePage()
518 qrDialog.updateQrDialog()
ababia284cae2020-08-10 12:33:34 +0200519 }
Sébastien Blin1f915762020-08-03 13:27:42 -0400520 }
521
522 onConversationSmartListViewNeedToShowWelcomePage: {
ababia284cae2020-08-10 12:33:34 +0200523 mainViewStack.pop(welcomePage)
ababi69f5dfc2020-08-25 15:07:57 +0200524 welcomePage.updateWelcomePage()
525 qrDialog.updateQrDialog()
Sébastien Blin1f915762020-08-03 13:27:42 -0400526 }
527
528 onAccountSignalsReconnect: {
529 MessagesAdapter.accountChangedSetUp(accountId)
530 }
531
532 onNeedToUpdateConversationForAddedContact: {
533 MessagesAdapter.updateConversationForAddedContact()
534 mainViewWindowSidePanel.clearContactSearchBar()
535 mainViewWindowSidePanel.forceReselectConversationSmartListCurrentIndex()
536 }
537
538 onNeedToAddNewAccount: {
Sébastien Blinc75335f2020-08-04 20:54:02 -0400539 mainViewStackLayout.currentIndex = 2
Sébastien Blin1f915762020-08-03 13:27:42 -0400540 }
541 }
542
543 CallStackView {
544 id: callStackView
545
546 visible: false
547
548 objectName: "callStackViewObject"
ababia284cae2020-08-10 12:33:34 +0200549
Sébastien Blin1f915762020-08-03 13:27:42 -0400550 }
551
552 WelcomePage {
553 id: welcomePage
554 visible: false
555 }
556
ababia284cae2020-08-10 12:33:34 +0200557 SettingsView {
558 id: settingsView
559
560 visible: false
561
562 width: Math.max(mainViewStackPreferredWidth, mainViewStack.width - 100)
563 height: mainViewWindow.minimumHeight
564
565 onSettingsViewWindowNeedToShowMainViewWindow: {
566 mainViewWindowSidePanel.refreshAccountComboBox(
567 accountDeleted ? 0 : -1)
568 toggleSettingsView()
569 }
570
571 onSettingsViewWindowNeedToShowNewWizardWindow: {
572 mainViewWindow.noAccountIsAvailable()
573 }
574
575 onSettingsBackArrowClicked: {
576 mainViewStack.pop(StackView.Immediate)
577 recursionStackViewItemMove(sidePanelViewStack, mainViewStack, 2)
578 }
579 }
580
Sébastien Blin1f915762020-08-03 13:27:42 -0400581 MessageWebView {
582 id: communicationPageMessageWebView
583
584 objectName: "communicationPageMessageWebView"
585
586 signal toSendMessageContentSaved(string arg)
587 signal toMessagesCleared
588 signal toMessagesLoaded
589
590 visible: false
591
592 Connections {
593 target: MessagesAdapter
594
595 function onNeedToUpdateSmartList() {
596 mainViewWindowSidePanel.forceUpdateConversationSmartListView()
597 }
598 }
599
600 onNeedToGoBackToWelcomeView: {
601 mainViewWindowSidePanel.deselectConversationSmartList()
602 if (communicationPageMessageWebView.visible
ababia284cae2020-08-10 12:33:34 +0200603 && !mainViewStack.visible) {
Sébastien Blin1f915762020-08-03 13:27:42 -0400604 sidePanelViewStack.pop()
605 } else if (communicationPageMessageWebView.visible
ababia284cae2020-08-10 12:33:34 +0200606 && mainViewStack.visible) {
607 mainViewStack.pop()
Sébastien Blin1f915762020-08-03 13:27:42 -0400608 }
609 }
610
611 Component.onCompleted: {
Sébastien Blin1f915762020-08-03 13:27:42 -0400612
Sébastien Blinc75335f2020-08-04 20:54:02 -0400613 sidePanelViewStack.SplitView.maximumWidth = Qt.binding(function() {
614 return (hiddenView ? splitView.width : splitView.width - sidePanelViewStackPreferedWidth)
615 })
616
617 recordBox.x = Qt.binding(function() {
618 var i = (welcomeViewStack.width > 1000 ? Math.round((welcomeViewStack.width-1000)*0.5) : 0)
619 return sidePanelViewStack.width + recordBox.x_offset + i
620 })
621
622 recordBox.y = Qt.binding(function() {
623 return sidePanelViewStack.height + recordBox.y_offset
624 })
625
626
Sébastien Blin1f915762020-08-03 13:27:42 -0400627 /*
628 * Set qml MessageWebView object pointer to c++.
629 */
630 MessagesAdapter.setQmlObject(this)
631 }
632 }
633
634 onWidthChanged: {
635
636
637 /*
638 * Hide unnecessary stackview when width is changed.
639 */
ababia284cae2020-08-10 12:33:34 +0200640 if (mainViewWindow.width < sidePanelViewStackPreferredWidth
641 + mainViewStackPreferredWidth - 5
642 && mainViewStack.visible) {
643 mainViewStack.visible = false
644 sidePanelHidden = true
Sébastien Blin1f915762020-08-03 13:27:42 -0400645
646 /*
647 * The find callback function is called for each item in the stack.
648 */
ababia284cae2020-08-10 12:33:34 +0200649 var inWelcomeViewStack = mainViewStack.find(
Sébastien Blin1f915762020-08-03 13:27:42 -0400650 function (item, index) {
651 return index > 0
652 })
ababidf651a22020-07-30 13:38:57 +0200653
Sébastien Blin1f915762020-08-03 13:27:42 -0400654 if (inWelcomeViewStack) {
ababia284cae2020-08-10 12:33:34 +0200655 recursionStackViewItemMove(mainViewStack, sidePanelViewStack)
Sébastien Blin1f915762020-08-03 13:27:42 -0400656 }
657
Sébastien Blin1f915762020-08-03 13:27:42 -0400658 mainViewWindow.update()
ababia284cae2020-08-10 12:33:34 +0200659 } else if (mainViewWindow.width >= sidePanelViewStackPreferredWidth
660 + mainViewStackPreferredWidth + 5
661 && !mainViewStack.visible) {
662 mainViewStack.visible = true
663 sidePanelHidden = false
Sébastien Blin1f915762020-08-03 13:27:42 -0400664
665 var inSidePanelViewStack = sidePanelViewStack.find(
666 function (item, index) {
667 return index > 0
668 })
669 if (inSidePanelViewStack) {
ababia284cae2020-08-10 12:33:34 +0200670 recursionStackViewItemMove(sidePanelViewStack, mainViewStack, (inSettingsView ? 2 : 1))
Sébastien Blin1f915762020-08-03 13:27:42 -0400671 }
672
Sébastien Blin1f915762020-08-03 13:27:42 -0400673 mainViewWindow.update()
674 }
675 }
676
677 AboutPopUp {
678 id: aboutPopUpDialog
679
680 x: Math.round((mainViewWindow.width - width) / 2)
681 y: Math.round((mainViewWindow.height - height) / 2)
ababia284cae2020-08-10 12:33:34 +0200682 width: Math.max(mainViewWindow.width / 2, aboutPopUpPreferredWidth)
Sébastien Blin1f915762020-08-03 13:27:42 -0400683 height: aboutPopUpDialog.contentHeight
684 }
685
686 WelcomePageQrDialog {
687 id: qrDialog
688
689 x: Math.round((mainViewWindow.width - width) / 2)
690 y: Math.round((mainViewWindow.height - height) / 2)
691 width: qrDialog.contentHeight
692 height: qrDialog.contentHeight
693 }
694
695 RecordBox{
696 id: recordBox
697 visible: false
ababia284cae2020-08-10 12:33:34 +0200698
699 Component.onCompleted: {
700 recordBox.x = Qt.binding(function() {
701 var i = (mainViewStack.width > 1000 ? Math.round((mainViewStack.width-1000)*0.5) : 0)
702 return sidePanelViewStack.width + recordBox.x_offset + i
703 })
704
705 recordBox.y = Qt.binding(function() {
706 return mainViewStack.height + recordBox.y_offset
707 })
708 }
Sébastien Blin1f915762020-08-03 13:27:42 -0400709 }
710
711 UserProfile {
712 id: userProfile
713
714 x: Math.round((mainViewWindow.width - width) / 2)
715 y: Math.round((mainViewWindow.height - height) / 2)
ababia284cae2020-08-10 12:33:34 +0200716 width: Math.max(mainViewWindow.width / 2, aboutPopUpPreferredWidth)
Sébastien Blin1f915762020-08-03 13:27:42 -0400717 height: userProfile.contentHeight
718 }
719
720 Component.onCompleted: {
721 CallAdapter.initQmlObject()
722 }
723
724 onClosing: {
725 close.accepted = false
726 mainViewWindow.hide()
727 mainViewWindow.closeApp()
728 }
729}