Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 1 | |
| 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 | */ |
| 19 | import QtQuick 2.14 |
| 20 | import QtQuick.Window 2.14 |
| 21 | import QtQuick.Controls 2.14 |
| 22 | import QtQuick.Layouts 1.14 |
| 23 | import QtQuick.Controls.Universal 2.12 |
| 24 | import QtGraphicalEffects 1.14 |
| 25 | import net.jami.Models 1.0 |
| 26 | |
| 27 | |
| 28 | /* |
| 29 | * Import qml component files. |
| 30 | */ |
| 31 | import "components" |
| 32 | import "../settingsview" |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 33 | import "../settingsview/components" |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 34 | |
| 35 | Window { |
| 36 | id: mainViewWindow |
| 37 | |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 38 | property int minWidth: sidePanelViewStackPreferredWidth |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 39 | property int minHeight: aboutPopUpDialog.contentHeight |
| 40 | |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 41 | 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 Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 46 | |
ababi | df651a2 | 2020-07-30 13:38:57 +0200 | [diff] [blame] | 47 | property int savedSidePanelViewMinWidth: 0 |
| 48 | property int savedSidePanelViewMaxWidth: 0 |
| 49 | property int savedWelcomeViewMinWidth: 0 |
| 50 | property int savedWelcomeViewMaxWidth: 0 |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 51 | property bool sidePanelHidden: false |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 52 | |
| 53 | /* |
| 54 | * To calculate tab bar bottom border hidden rect left margin. |
| 55 | */ |
| 56 | property int tabBarLeftMargin: 8 |
| 57 | property int tabButtonShrinkSize: 8 |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 58 | property bool inSettingsView: false |
| 59 | property bool needToShowCallStack: false |
| 60 | property bool needToCloseCallStack: false |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 61 | |
| 62 | signal noAccountIsAvailable |
| 63 | signal needToAddNewAccount |
| 64 | signal closeApp |
| 65 | |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 66 | 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 Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 89 | function newAccountAdded(index) { |
| 90 | mainViewWindowSidePanel.refreshAccountComboBox(index) |
| 91 | } |
| 92 | |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 93 | function recursionStackViewItemMove(stackOne, stackTwo, depth=1) { |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 94 | |
| 95 | /* |
| 96 | * Move all items (expect the bottom item) to stacktwo by the same order in stackone. |
| 97 | */ |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 98 | if (stackOne.depth === depth) { |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 99 | return |
| 100 | } |
| 101 | |
| 102 | var tempItem = stackOne.pop(StackView.Immediate) |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 103 | recursionStackViewItemMove(stackOne, stackTwo, depth) |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 104 | stackTwo.push(tempItem, StackView.Immediate) |
| 105 | } |
| 106 | |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 107 | 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 Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 142 | title: "Jami" |
| 143 | visible: true |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 144 | width: mainViewWindowPreferredWidth |
| 145 | height: mainViewWindowPreferredHeight |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 146 | minimumWidth: minWidth |
| 147 | minimumHeight: minHeight |
| 148 | |
| 149 | Connections { |
| 150 | target: CallAdapter |
| 151 | |
| 152 | function onShowCallStack(accountId, convUid, forceReset) { |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 153 | |
| 154 | needToShowCallStack = true |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 155 | 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) { |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 167 | pushCallStackView() |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 168 | } |
| 169 | } |
| 170 | |
| 171 | function onCloseCallStack(accountId, convUid) { |
| 172 | |
Sébastien Blin | 8940f3c | 2020-07-23 17:03:11 -0400 | [diff] [blame] | 173 | var responsibleCallId = ClientWrapper.utilsAdaptor.getCallId( |
| 174 | callStackView.responsibleAccountId, callStackView.responsibleConvUid) |
| 175 | var callId = ClientWrapper.utilsAdaptor.getCallId( |
| 176 | callStackView.responsibleAccountId, convUid) |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 177 | /* |
| 178 | * Check if call stack view is on any of the stackview. |
| 179 | */ |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 180 | if (callStackView.responsibleAccountId === accountId |
| 181 | && callStackView.responsibleConvUid === convUid) { |
| 182 | if (mainViewStack.find(function (item, index) { |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 183 | return item.objectName === "callStackViewObject" |
| 184 | }) || sidePanelViewStack.find(function (item, index) { |
| 185 | return item.objectName === "callStackViewObject" |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 186 | }) || (inSettingsView && needToShowCallStack)) { |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 187 | callStackView.needToCloseInCallConversationAndPotentialWindow() |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 188 | |
| 189 | if (!inSettingsView) { |
| 190 | pushCommunicationMessageWebView() |
| 191 | needToShowCallStack = false |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 192 | } else { |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 193 | needToCloseCallStack = true |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 194 | } |
| 195 | } |
| 196 | } |
| 197 | } |
| 198 | |
| 199 | function onIncomingCallNeedToSetupMainView(accountId, convUid) { |
| 200 | |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 201 | /* |
| 202 | * Set up the call stack view that is needed by call overlay. |
| 203 | */ |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 204 | if (!inSettingsView) { |
| 205 | mainViewStack.pop(null, StackView.Immediate) |
| 206 | sidePanelViewStack.pop(null, StackView.Immediate) |
| 207 | } else { |
| 208 | toggleSettingsView() |
| 209 | } |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 210 | |
| 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 Blin | 8940f3c | 2020-07-23 17:03:11 -0400 | [diff] [blame] | 219 | callStackView.setLinkedWebview( |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 220 | 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 { |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 250 | implicitWidth: JamiTheme.splitViewHandlePreferredWidth |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 251 | implicitHeight: splitView.height |
ababi | 6fa0861 | 2020-08-10 19:13:28 +0200 | [diff] [blame] | 252 | color:"white" |
ababi | df651a2 | 2020-07-30 13:38:57 +0200 | [diff] [blame] | 253 | Rectangle { |
| 254 | implicitWidth: 1 |
| 255 | implicitHeight: splitView.height |
| 256 | color: SplitHandle.pressed ? JamiTheme.pressColor : (SplitHandle.hovered ? JamiTheme.hoverColor : JamiTheme.tabbarBorderColor) |
| 257 | } |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 258 | } |
| 259 | |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 260 | Rectangle { |
| 261 | id: mainViewSidePanelRect |
| 262 | SplitView.minimumWidth: sidePanelViewStackPreferredWidth |
| 263 | SplitView.maximumWidth: (sidePanelHidden ? splitView.width : |
| 264 | splitView.width - sidePanelViewStackPreferredWidth) |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 265 | SplitView.fillHeight: true |
| 266 | |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 267 | /* |
| 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 Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 350 | } |
| 351 | |
| 352 | StackView { |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 353 | id: mainViewStack |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 354 | |
| 355 | initialItem: welcomePage |
| 356 | |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 357 | SplitView.maximumWidth: sidePanelHidden ? splitView.width : splitView.width - sidePanelViewStackPreferredWidth |
| 358 | SplitView.minimumWidth: sidePanelViewStackPreferredWidth |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 359 | SplitView.fillHeight: true |
| 360 | |
| 361 | clip: true |
| 362 | } |
| 363 | } |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 364 | } |
| 365 | |
| 366 | AccountListModel { |
| 367 | id: accountListModel |
| 368 | } |
| 369 | |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 370 | |
| 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 Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 416 | SidePanel { |
| 417 | id: mainViewWindowSidePanel |
| 418 | |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 419 | 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 Blin | 8940f3c | 2020-07-23 17:03:11 -0400 | [diff] [blame] | 451 | callStackView.setLinkedWebview( |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 452 | communicationPageMessageWebView) |
| 453 | |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 454 | if (mainViewStack.find(function (item, index) { |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 455 | 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 | */ |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 467 | mainViewStack.pop(null, StackView.Immediate) |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 468 | sidePanelViewStack.pop(null, StackView.Immediate) |
| 469 | |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 470 | if (sidePanelViewStack.visible && mainViewStack.visible) { |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 471 | if (callStackViewShouldShow) { |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 472 | mainViewStack.push(callStackView) |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 473 | } else { |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 474 | mainViewStack.push(communicationPageMessageWebView) |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 475 | } |
| 476 | } else if (sidePanelViewStack.visible |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 477 | && !mainViewStack.visible) { |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 478 | if (callStackViewShouldShow) { |
| 479 | sidePanelViewStack.push(callStackView) |
| 480 | } else { |
| 481 | sidePanelViewStack.push(communicationPageMessageWebView) |
| 482 | } |
| 483 | } else if (!sidePanelViewStack.visible |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 484 | && !mainViewStack.visible) { |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 485 | if (callStackViewShouldShow) { |
| 486 | sidePanelViewStack.push(callStackView) |
| 487 | } else { |
| 488 | sidePanelViewStack.push(communicationPageMessageWebView) |
| 489 | } |
| 490 | } |
| 491 | } |
| 492 | |
| 493 | onAccountComboBoxNeedToShowWelcomePage: { |
| 494 | |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 495 | /* |
| 496 | * If the item argument is specified, all items down to (but not including) item will be popped. |
| 497 | */ |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 498 | if (!inSettingsView) { |
| 499 | mainViewStack.pop(welcomePage) |
| 500 | welcomePage.currentAccountIndex = index |
| 501 | qrDialog.currentAccountIndex = index |
| 502 | } |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 503 | } |
| 504 | |
| 505 | onConversationSmartListViewNeedToShowWelcomePage: { |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 506 | mainViewStack.pop(welcomePage) |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 507 | 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" |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 532 | |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 533 | } |
| 534 | |
| 535 | WelcomePage { |
| 536 | id: welcomePage |
| 537 | visible: false |
| 538 | } |
| 539 | |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 540 | 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 Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 564 | 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 |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 586 | && !mainViewStack.visible) { |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 587 | sidePanelViewStack.pop() |
| 588 | } else if (communicationPageMessageWebView.visible |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 589 | && mainViewStack.visible) { |
| 590 | mainViewStack.pop() |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 591 | } |
| 592 | } |
| 593 | |
| 594 | Component.onCompleted: { |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 595 | |
| 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 | */ |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 609 | if (mainViewWindow.width < sidePanelViewStackPreferredWidth |
| 610 | + mainViewStackPreferredWidth - 5 |
| 611 | && mainViewStack.visible) { |
| 612 | mainViewStack.visible = false |
| 613 | sidePanelHidden = true |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 614 | |
| 615 | /* |
| 616 | * The find callback function is called for each item in the stack. |
| 617 | */ |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 618 | var inWelcomeViewStack = mainViewStack.find( |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 619 | function (item, index) { |
| 620 | return index > 0 |
| 621 | }) |
ababi | df651a2 | 2020-07-30 13:38:57 +0200 | [diff] [blame] | 622 | |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 623 | if (inWelcomeViewStack) { |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 624 | recursionStackViewItemMove(mainViewStack, sidePanelViewStack) |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 625 | } |
| 626 | |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 627 | mainViewWindow.update() |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 628 | } else if (mainViewWindow.width >= sidePanelViewStackPreferredWidth |
| 629 | + mainViewStackPreferredWidth + 5 |
| 630 | && !mainViewStack.visible) { |
| 631 | mainViewStack.visible = true |
| 632 | sidePanelHidden = false |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 633 | |
| 634 | var inSidePanelViewStack = sidePanelViewStack.find( |
| 635 | function (item, index) { |
| 636 | return index > 0 |
| 637 | }) |
| 638 | if (inSidePanelViewStack) { |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 639 | recursionStackViewItemMove(sidePanelViewStack, mainViewStack, (inSettingsView ? 2 : 1)) |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 640 | } |
| 641 | |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 642 | 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) |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 651 | width: Math.max(mainViewWindow.width / 2, aboutPopUpPreferredWidth) |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 652 | 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 |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 667 | |
| 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 Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 678 | } |
| 679 | |
| 680 | UserProfile { |
| 681 | id: userProfile |
| 682 | |
| 683 | x: Math.round((mainViewWindow.width - width) / 2) |
| 684 | y: Math.round((mainViewWindow.height - height) / 2) |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 685 | width: Math.max(mainViewWindow.width / 2, aboutPopUpPreferredWidth) |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 686 | 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 | } |