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" |
Sébastien Blin | c75335f | 2020-08-04 20:54:02 -0400 | [diff] [blame] | 32 | import "../wizardview" |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 33 | import "../settingsview" |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 34 | import "../settingsview/components" |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 35 | |
| 36 | Window { |
| 37 | id: mainViewWindow |
| 38 | |
Sébastien Blin | 8cb4e44 | 2020-08-24 14:28:11 -0400 | [diff] [blame] | 39 | property int minWidth: 400 |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 40 | property int minHeight: aboutPopUpDialog.contentHeight |
| 41 | |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 42 | property int mainViewWindowPreferredWidth: 650 |
| 43 | property int mainViewWindowPreferredHeight: 600 |
Sébastien Blin | 8cb4e44 | 2020-08-24 14:28:11 -0400 | [diff] [blame] | 44 | property int sidePanelViewStackPreferredWidth: 250 |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 45 | property int mainViewStackPreferredWidth: 250 |
Sébastien Blin | a84e5fd | 2020-08-16 17:39:15 -0400 | [diff] [blame] | 46 | property int aboutPopUpPreferredWidth: 400 |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 47 | |
ababi | df651a2 | 2020-07-30 13:38:57 +0200 | [diff] [blame] | 48 | property int savedSidePanelViewMinWidth: 0 |
| 49 | property int savedSidePanelViewMaxWidth: 0 |
| 50 | property int savedWelcomeViewMinWidth: 0 |
| 51 | property int savedWelcomeViewMaxWidth: 0 |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 52 | property bool sidePanelHidden: false |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 53 | |
| 54 | /* |
| 55 | * To calculate tab bar bottom border hidden rect left margin. |
| 56 | */ |
| 57 | property int tabBarLeftMargin: 8 |
| 58 | property int tabButtonShrinkSize: 8 |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 59 | property bool inSettingsView: false |
| 60 | property bool needToShowCallStack: false |
| 61 | property bool needToCloseCallStack: false |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 62 | |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 63 | signal closeApp |
Sébastien Blin | c75335f | 2020-08-04 20:54:02 -0400 | [diff] [blame] | 64 | signal noAccountIsAvailable |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 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 | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 173 | /* |
| 174 | * Check if call stack view is on any of the stackview. |
| 175 | */ |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 176 | if (callStackView.responsibleAccountId === accountId |
| 177 | && callStackView.responsibleConvUid === convUid) { |
| 178 | if (mainViewStack.find(function (item, index) { |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 179 | return item.objectName === "callStackViewObject" |
| 180 | }) || sidePanelViewStack.find(function (item, index) { |
| 181 | return item.objectName === "callStackViewObject" |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 182 | }) || (inSettingsView && needToShowCallStack)) { |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 183 | callStackView.needToCloseInCallConversationAndPotentialWindow() |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 184 | |
| 185 | if (!inSettingsView) { |
| 186 | pushCommunicationMessageWebView() |
| 187 | needToShowCallStack = false |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 188 | } else { |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 189 | needToCloseCallStack = true |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 190 | } |
| 191 | } |
| 192 | } |
| 193 | } |
| 194 | |
| 195 | function onIncomingCallNeedToSetupMainView(accountId, convUid) { |
| 196 | |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 197 | /* |
| 198 | * Set up the call stack view that is needed by call overlay. |
| 199 | */ |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 200 | if (!inSettingsView) { |
| 201 | mainViewStack.pop(null, StackView.Immediate) |
| 202 | sidePanelViewStack.pop(null, StackView.Immediate) |
| 203 | } else { |
| 204 | toggleSettingsView() |
| 205 | } |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 206 | |
| 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 Blin | 8940f3c | 2020-07-23 17:03:11 -0400 | [diff] [blame] | 215 | callStackView.setLinkedWebview( |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 216 | 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 Blin | c75335f | 2020-08-04 20:54:02 -0400 | [diff] [blame] | 229 | WizardView { |
Ming Rui Zhang | a70e130 | 2020-08-28 13:31:26 -0400 | [diff] [blame] | 230 | id: wizardView |
Sébastien Blin | c75335f | 2020-08-04 20:54:02 -0400 | [diff] [blame] | 231 | |
Ming Rui Zhang | a70e130 | 2020-08-28 13:31:26 -0400 | [diff] [blame] | 232 | anchors.fill: parent |
Sébastien Blin | c75335f | 2020-08-04 20:54:02 -0400 | [diff] [blame] | 233 | |
Ming Rui Zhang | a70e130 | 2020-08-28 13:31:26 -0400 | [diff] [blame] | 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() |
Sébastien Blin | c75335f | 2020-08-04 20:54:02 -0400 | [diff] [blame] | 242 | } |
Ming Rui Zhang | a70e130 | 2020-08-28 13:31:26 -0400 | [diff] [blame] | 243 | mainViewStackLayout.currentIndex = 0 |
Sébastien Blin | c75335f | 2020-08-04 20:54:02 -0400 | [diff] [blame] | 244 | } |
| 245 | |
Ming Rui Zhang | a70e130 | 2020-08-28 13:31:26 -0400 | [diff] [blame] | 246 | onWizardViewIsClosed: { |
| 247 | mainViewStackLayout.currentIndex = 0 |
| 248 | } |
| 249 | } |
| 250 | |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 251 | 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 { |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 268 | implicitWidth: JamiTheme.splitViewHandlePreferredWidth |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 269 | implicitHeight: splitView.height |
ababi | 6fa0861 | 2020-08-10 19:13:28 +0200 | [diff] [blame] | 270 | color:"white" |
ababi | df651a2 | 2020-07-30 13:38:57 +0200 | [diff] [blame] | 271 | Rectangle { |
| 272 | implicitWidth: 1 |
| 273 | implicitHeight: splitView.height |
| 274 | color: SplitHandle.pressed ? JamiTheme.pressColor : (SplitHandle.hovered ? JamiTheme.hoverColor : JamiTheme.tabbarBorderColor) |
| 275 | } |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 276 | } |
| 277 | |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 278 | Rectangle { |
| 279 | id: mainViewSidePanelRect |
| 280 | SplitView.minimumWidth: sidePanelViewStackPreferredWidth |
| 281 | SplitView.maximumWidth: (sidePanelHidden ? splitView.width : |
| 282 | splitView.width - sidePanelViewStackPreferredWidth) |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 283 | SplitView.fillHeight: true |
| 284 | |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 285 | /* |
| 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 | |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 302 | function onUpdateConversationForAddedContact() { |
| 303 | mainViewWindowSidePanel.needToUpdateConversationForAddedContact() |
| 304 | } |
| 305 | |
| 306 | function onAccountStatusChanged() { |
| 307 | accountComboBox.updateAccountListModel() |
| 308 | } |
| 309 | } |
| 310 | |
| 311 | onSettingBtnClicked: { |
| 312 | toggleSettingsView() |
| 313 | } |
| 314 | |
| 315 | onAccountChanged: { |
ababi | 69f5dfc | 2020-08-25 15:07:57 +0200 | [diff] [blame] | 316 | mainViewWindowSidePanel.refreshAccountComboBox(index) |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 317 | settingsView.slotAccountListChanged() |
| 318 | settingsView.setSelected(settingsView.selectedMenu, true) |
| 319 | |
| 320 | if (needToShowCallStack |
| 321 | && callStackView.responsibleAccountId === ClientWrapper.utilsAdaptor.getCurrAccId()){ |
| 322 | if (!ClientWrapper.accountAdaptor.hasVideoCall()) { |
| 323 | pushCommunicationMessageWebView() |
| 324 | needToShowCallStack = false |
| 325 | } else if (needToShowCallStack) { |
| 326 | pushCallStackView() |
| 327 | } |
| 328 | } |
| 329 | } |
| 330 | |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 331 | onNeedToBackToWelcomePage: { |
| 332 | if (!inSettingsView) |
ababi | 69f5dfc | 2020-08-25 15:07:57 +0200 | [diff] [blame] | 333 | mainViewWindowSidePanel.accountComboBoxNeedToShowWelcomePage() |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 334 | } |
| 335 | |
| 336 | onNewAccountButtonClicked: { |
| 337 | mainViewWindowSidePanel.needToAddNewAccount() |
| 338 | } |
| 339 | |
| 340 | Component.onCompleted: { |
| 341 | ClientWrapper.accountAdaptor.setQmlObject(this) |
| 342 | } |
| 343 | } |
| 344 | |
| 345 | StackView { |
| 346 | id: sidePanelViewStack |
| 347 | |
| 348 | initialItem: mainViewWindowSidePanel |
| 349 | |
| 350 | anchors.top: accountComboBox.visible ? accountComboBox.bottom : mainViewSidePanelRect.top |
| 351 | width: mainViewSidePanelRect.width |
| 352 | height: accountComboBox.visible ? mainViewSidePanelRect.height - accountComboBox.height : |
| 353 | mainViewSidePanelRect.height |
| 354 | |
| 355 | clip: true |
| 356 | } |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 357 | } |
| 358 | |
| 359 | StackView { |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 360 | id: mainViewStack |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 361 | |
| 362 | initialItem: welcomePage |
| 363 | |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 364 | SplitView.maximumWidth: sidePanelHidden ? splitView.width : splitView.width - sidePanelViewStackPreferredWidth |
| 365 | SplitView.minimumWidth: sidePanelViewStackPreferredWidth |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 366 | SplitView.fillHeight: true |
| 367 | |
| 368 | clip: true |
| 369 | } |
| 370 | } |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 371 | } |
| 372 | |
| 373 | AccountListModel { |
| 374 | id: accountListModel |
| 375 | } |
| 376 | |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 377 | |
| 378 | LeftPanelView { |
| 379 | id: leftPanelSettingsView |
| 380 | visible: false |
| 381 | contentViewportWidth: mainViewSidePanelRect.width |
| 382 | contentViewPortHeight: mainViewSidePanelRect.height |
| 383 | |
| 384 | Connections { |
| 385 | target: leftPanelSettingsView.btnAccountSettings |
| 386 | function onCheckedToggledForRightPanel(checked) { |
| 387 | settingsView.setSelected(SettingsView.Account) |
| 388 | if (sidePanelHidden) { |
| 389 | recursionStackViewItemMove(mainViewStack, sidePanelViewStack, 1) |
| 390 | } |
| 391 | } |
| 392 | } |
| 393 | Connections { |
| 394 | target: leftPanelSettingsView.btnGeneralSettings |
| 395 | function onCheckedToggledForRightPanel(checked) { |
| 396 | settingsView.setSelected(SettingsView.General) |
| 397 | if (sidePanelHidden) { |
| 398 | recursionStackViewItemMove(mainViewStack, sidePanelViewStack, 1) |
| 399 | } |
| 400 | } |
| 401 | } |
| 402 | Connections { |
| 403 | target: leftPanelSettingsView.btnMediaSettings |
| 404 | function onCheckedToggledForRightPanel(checked) { |
| 405 | settingsView.setSelected(SettingsView.Media) |
| 406 | if (sidePanelHidden) { |
| 407 | recursionStackViewItemMove(mainViewStack, sidePanelViewStack, 1) |
| 408 | } |
| 409 | } |
| 410 | } |
| 411 | Connections { |
| 412 | target: leftPanelSettingsView.btnPluginSettings |
| 413 | function onCheckedToggledForRightPanel(checked) { |
| 414 | settingsView.setSelected(SettingsView.Plugin) |
| 415 | if (sidePanelHidden) { |
| 416 | recursionStackViewItemMove(mainViewStack, sidePanelViewStack, 1) |
| 417 | } |
| 418 | } |
| 419 | } |
| 420 | } |
| 421 | |
| 422 | |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 423 | SidePanel { |
| 424 | id: mainViewWindowSidePanel |
| 425 | |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 426 | onConversationSmartListNeedToAccessMessageWebView: { |
| 427 | |
| 428 | communicationPageMessageWebView.headerUserAliasLabelText = currentUserAlias |
| 429 | communicationPageMessageWebView.headerUserUserNameLabelText = currentUserDisplayName |
| 430 | |
| 431 | callStackView.needToCloseInCallConversationAndPotentialWindow() |
| 432 | callStackView.responsibleAccountId = ClientWrapper.utilsAdaptor.getCurrAccId() |
| 433 | callStackView.responsibleConvUid = currentUID |
| 434 | callStackView.updateCorrspondingUI() |
| 435 | |
| 436 | if (callStackViewShouldShow) { |
ababi | 76b94aa | 2020-08-24 17:46:30 +0200 | [diff] [blame] | 437 | if (callState === Call.Status.IN_PROGRESS || callState === Call.Status.PAUSED) { |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 438 | ClientWrapper.utilsAdaptor.setCurrentCall( |
| 439 | ClientWrapper.utilsAdaptor.getCurrAccId(), |
| 440 | currentUID) |
| 441 | if (isAudioOnly) |
| 442 | callStackView.showAudioCallPage() |
| 443 | else |
| 444 | callStackView.showVideoCallPage( |
| 445 | ClientWrapper.utilsAdaptor.getCallId( |
| 446 | callStackView.responsibleAccountId, |
| 447 | callStackView.responsibleConvUid)) |
| 448 | } else { |
| 449 | callStackView.showOutgoingCallPage(callStateStr) |
| 450 | } |
| 451 | } |
| 452 | |
| 453 | |
| 454 | /* |
| 455 | * Set up chatview. |
| 456 | */ |
| 457 | MessagesAdapter.setupChatView(currentUID) |
Sébastien Blin | 8940f3c | 2020-07-23 17:03:11 -0400 | [diff] [blame] | 458 | callStackView.setLinkedWebview( |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 459 | communicationPageMessageWebView) |
| 460 | |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 461 | if (mainViewStack.find(function (item, index) { |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 462 | return item.objectName === "communicationPageMessageWebView" |
| 463 | }) || sidePanelViewStack.find(function (item, index) { |
| 464 | return item.objectName === "communicationPageMessageWebView" |
| 465 | })) { |
| 466 | if (!callStackViewShouldShow) |
| 467 | return |
| 468 | } |
| 469 | |
| 470 | |
| 471 | /* |
| 472 | * Push messageWebView or callStackView onto the correct stackview |
| 473 | */ |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 474 | mainViewStack.pop(null, StackView.Immediate) |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 475 | sidePanelViewStack.pop(null, StackView.Immediate) |
| 476 | |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 477 | if (sidePanelViewStack.visible && mainViewStack.visible) { |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 478 | if (callStackViewShouldShow) { |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 479 | mainViewStack.push(callStackView) |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 480 | } else { |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 481 | mainViewStack.push(communicationPageMessageWebView) |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 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 | } else if (!sidePanelViewStack.visible |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 491 | && !mainViewStack.visible) { |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 492 | if (callStackViewShouldShow) { |
| 493 | sidePanelViewStack.push(callStackView) |
| 494 | } else { |
| 495 | sidePanelViewStack.push(communicationPageMessageWebView) |
| 496 | } |
| 497 | } |
| 498 | } |
| 499 | |
| 500 | onAccountComboBoxNeedToShowWelcomePage: { |
| 501 | |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 502 | /* |
| 503 | * If the item argument is specified, all items down to (but not including) item will be popped. |
| 504 | */ |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 505 | if (!inSettingsView) { |
| 506 | mainViewStack.pop(welcomePage) |
ababi | 69f5dfc | 2020-08-25 15:07:57 +0200 | [diff] [blame] | 507 | welcomePage.updateWelcomePage() |
| 508 | qrDialog.updateQrDialog() |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 509 | } |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 510 | } |
| 511 | |
| 512 | onConversationSmartListViewNeedToShowWelcomePage: { |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 513 | mainViewStack.pop(welcomePage) |
ababi | 69f5dfc | 2020-08-25 15:07:57 +0200 | [diff] [blame] | 514 | welcomePage.updateWelcomePage() |
| 515 | qrDialog.updateQrDialog() |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 516 | } |
| 517 | |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 518 | onNeedToUpdateConversationForAddedContact: { |
| 519 | MessagesAdapter.updateConversationForAddedContact() |
| 520 | mainViewWindowSidePanel.clearContactSearchBar() |
| 521 | mainViewWindowSidePanel.forceReselectConversationSmartListCurrentIndex() |
| 522 | } |
| 523 | |
| 524 | onNeedToAddNewAccount: { |
Sébastien Blin | c75335f | 2020-08-04 20:54:02 -0400 | [diff] [blame] | 525 | mainViewStackLayout.currentIndex = 2 |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 526 | } |
| 527 | } |
| 528 | |
| 529 | CallStackView { |
| 530 | id: callStackView |
| 531 | |
| 532 | visible: false |
| 533 | |
| 534 | objectName: "callStackViewObject" |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 535 | |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 536 | } |
| 537 | |
| 538 | WelcomePage { |
| 539 | id: welcomePage |
| 540 | visible: false |
| 541 | } |
| 542 | |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 543 | SettingsView { |
| 544 | id: settingsView |
| 545 | |
| 546 | visible: false |
| 547 | |
| 548 | width: Math.max(mainViewStackPreferredWidth, mainViewStack.width - 100) |
| 549 | height: mainViewWindow.minimumHeight |
| 550 | |
| 551 | onSettingsViewWindowNeedToShowMainViewWindow: { |
| 552 | mainViewWindowSidePanel.refreshAccountComboBox( |
| 553 | accountDeleted ? 0 : -1) |
| 554 | toggleSettingsView() |
| 555 | } |
| 556 | |
| 557 | onSettingsViewWindowNeedToShowNewWizardWindow: { |
| 558 | mainViewWindow.noAccountIsAvailable() |
| 559 | } |
| 560 | |
| 561 | onSettingsBackArrowClicked: { |
| 562 | mainViewStack.pop(StackView.Immediate) |
| 563 | recursionStackViewItemMove(sidePanelViewStack, mainViewStack, 2) |
| 564 | } |
| 565 | } |
| 566 | |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 567 | MessageWebView { |
| 568 | id: communicationPageMessageWebView |
| 569 | |
| 570 | objectName: "communicationPageMessageWebView" |
| 571 | |
| 572 | signal toSendMessageContentSaved(string arg) |
| 573 | signal toMessagesCleared |
| 574 | signal toMessagesLoaded |
| 575 | |
| 576 | visible: false |
| 577 | |
| 578 | Connections { |
| 579 | target: MessagesAdapter |
| 580 | |
| 581 | function onNeedToUpdateSmartList() { |
| 582 | mainViewWindowSidePanel.forceUpdateConversationSmartListView() |
| 583 | } |
| 584 | } |
| 585 | |
| 586 | onNeedToGoBackToWelcomeView: { |
| 587 | mainViewWindowSidePanel.deselectConversationSmartList() |
| 588 | if (communicationPageMessageWebView.visible |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 589 | && !mainViewStack.visible) { |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 590 | sidePanelViewStack.pop() |
| 591 | } else if (communicationPageMessageWebView.visible |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 592 | && mainViewStack.visible) { |
| 593 | mainViewStack.pop() |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 594 | } |
Sébastien Blin | 59c8ead | 2020-08-25 21:32:41 -0400 | [diff] [blame^] | 595 | recordBox.visible = false |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 596 | } |
| 597 | |
| 598 | Component.onCompleted: { |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 599 | |
Sébastien Blin | c75335f | 2020-08-04 20:54:02 -0400 | [diff] [blame] | 600 | sidePanelViewStack.SplitView.maximumWidth = Qt.binding(function() { |
Sébastien Blin | 59c8ead | 2020-08-25 21:32:41 -0400 | [diff] [blame^] | 601 | return (hiddenView ? splitView.width : |
| 602 | splitView.width - sidePanelViewStackPreferedWidth) |
Sébastien Blin | c75335f | 2020-08-04 20:54:02 -0400 | [diff] [blame] | 603 | }) |
| 604 | |
| 605 | recordBox.x = Qt.binding(function() { |
Sébastien Blin | 59c8ead | 2020-08-25 21:32:41 -0400 | [diff] [blame^] | 606 | var i = ((mainViewStack.visible && mainViewStack.width > 1000) ? |
| 607 | Math.round((mainViewStack.width-1000)*0.5) : |
| 608 | 0) |
| 609 | return mainViewStack.visible ? |
| 610 | sidePanelViewStack.width + recordBox.x_offset + i : |
| 611 | recordBox.x_offset + i |
| 612 | |
Sébastien Blin | c75335f | 2020-08-04 20:54:02 -0400 | [diff] [blame] | 613 | }) |
| 614 | |
| 615 | recordBox.y = Qt.binding(function() { |
Sébastien Blin | 59c8ead | 2020-08-25 21:32:41 -0400 | [diff] [blame^] | 616 | return mainViewStack.visible ? mainViewStack.height + recordBox.y_offset : |
| 617 | sidePanelViewStack.height + recordBox.y_offset |
Sébastien Blin | c75335f | 2020-08-04 20:54:02 -0400 | [diff] [blame] | 618 | }) |
| 619 | |
| 620 | |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 621 | /* |
| 622 | * Set qml MessageWebView object pointer to c++. |
| 623 | */ |
| 624 | MessagesAdapter.setQmlObject(this) |
| 625 | } |
| 626 | } |
| 627 | |
| 628 | onWidthChanged: { |
| 629 | |
| 630 | |
| 631 | /* |
| 632 | * Hide unnecessary stackview when width is changed. |
| 633 | */ |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 634 | if (mainViewWindow.width < sidePanelViewStackPreferredWidth |
| 635 | + mainViewStackPreferredWidth - 5 |
| 636 | && mainViewStack.visible) { |
| 637 | mainViewStack.visible = false |
| 638 | sidePanelHidden = true |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 639 | |
| 640 | /* |
| 641 | * The find callback function is called for each item in the stack. |
| 642 | */ |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 643 | var inWelcomeViewStack = mainViewStack.find( |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 644 | function (item, index) { |
| 645 | return index > 0 |
| 646 | }) |
ababi | df651a2 | 2020-07-30 13:38:57 +0200 | [diff] [blame] | 647 | |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 648 | if (inWelcomeViewStack) { |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 649 | recursionStackViewItemMove(mainViewStack, sidePanelViewStack) |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 650 | } |
| 651 | |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 652 | mainViewWindow.update() |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 653 | } else if (mainViewWindow.width >= sidePanelViewStackPreferredWidth |
| 654 | + mainViewStackPreferredWidth + 5 |
| 655 | && !mainViewStack.visible) { |
| 656 | mainViewStack.visible = true |
| 657 | sidePanelHidden = false |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 658 | |
| 659 | var inSidePanelViewStack = sidePanelViewStack.find( |
| 660 | function (item, index) { |
| 661 | return index > 0 |
| 662 | }) |
| 663 | if (inSidePanelViewStack) { |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 664 | recursionStackViewItemMove(sidePanelViewStack, mainViewStack, (inSettingsView ? 2 : 1)) |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 665 | } |
| 666 | |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 667 | mainViewWindow.update() |
| 668 | } |
| 669 | } |
| 670 | |
| 671 | AboutPopUp { |
| 672 | id: aboutPopUpDialog |
| 673 | |
| 674 | x: Math.round((mainViewWindow.width - width) / 2) |
| 675 | y: Math.round((mainViewWindow.height - height) / 2) |
Sébastien Blin | a84e5fd | 2020-08-16 17:39:15 -0400 | [diff] [blame] | 676 | width: aboutPopUpPreferredWidth |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 677 | height: aboutPopUpDialog.contentHeight |
| 678 | } |
| 679 | |
| 680 | WelcomePageQrDialog { |
| 681 | id: qrDialog |
| 682 | |
| 683 | x: Math.round((mainViewWindow.width - width) / 2) |
| 684 | y: Math.round((mainViewWindow.height - height) / 2) |
| 685 | width: qrDialog.contentHeight |
| 686 | height: qrDialog.contentHeight |
| 687 | } |
| 688 | |
| 689 | RecordBox{ |
| 690 | id: recordBox |
| 691 | visible: false |
| 692 | } |
| 693 | |
| 694 | UserProfile { |
| 695 | id: userProfile |
| 696 | |
| 697 | x: Math.round((mainViewWindow.width - width) / 2) |
| 698 | y: Math.round((mainViewWindow.height - height) / 2) |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 699 | width: Math.max(mainViewWindow.width / 2, aboutPopUpPreferredWidth) |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 700 | height: userProfile.contentHeight |
| 701 | } |
| 702 | |
| 703 | Component.onCompleted: { |
| 704 | CallAdapter.initQmlObject() |
| 705 | } |
| 706 | |
| 707 | onClosing: { |
| 708 | close.accepted = false |
| 709 | mainViewWindow.hide() |
| 710 | mainViewWindow.closeApp() |
| 711 | } |
| 712 | } |