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 |
| 46 | property int aboutPopUpPreferredWidth: 250 |
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 { |
| 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 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 | |
| 302 | function onAccountSignalsReconnect(accountId) { |
| 303 | CallAdapter.connectCallModel(accountId) |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 304 | mainViewWindowSidePanel.accountSignalsReconnect(accountId) |
ababi | 69f5dfc | 2020-08-25 15:07:57 +0200 | [diff] [blame^] | 305 | ConversationsAdapter.accountChangedSetUp(accountId) |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 306 | } |
| 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: { |
ababi | 69f5dfc | 2020-08-25 15:07:57 +0200 | [diff] [blame^] | 322 | mainViewWindowSidePanel.refreshAccountComboBox(index) |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 323 | 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) |
ababi | 69f5dfc | 2020-08-25 15:07:57 +0200 | [diff] [blame^] | 343 | mainViewWindowSidePanel.accountComboBoxNeedToShowWelcomePage() |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 344 | } |
| 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 Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 367 | } |
| 368 | |
| 369 | StackView { |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 370 | id: mainViewStack |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 371 | |
| 372 | initialItem: welcomePage |
| 373 | |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 374 | SplitView.maximumWidth: sidePanelHidden ? splitView.width : splitView.width - sidePanelViewStackPreferredWidth |
| 375 | SplitView.minimumWidth: sidePanelViewStackPreferredWidth |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 376 | SplitView.fillHeight: true |
| 377 | |
| 378 | clip: true |
| 379 | } |
| 380 | } |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 381 | } |
| 382 | |
| 383 | AccountListModel { |
| 384 | id: accountListModel |
| 385 | } |
| 386 | |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 387 | |
| 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 Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 433 | SidePanel { |
| 434 | id: mainViewWindowSidePanel |
| 435 | |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 436 | 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 Blin | 8940f3c | 2020-07-23 17:03:11 -0400 | [diff] [blame] | 468 | callStackView.setLinkedWebview( |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 469 | communicationPageMessageWebView) |
| 470 | |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 471 | if (mainViewStack.find(function (item, index) { |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 472 | 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 | */ |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 484 | mainViewStack.pop(null, StackView.Immediate) |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 485 | sidePanelViewStack.pop(null, StackView.Immediate) |
| 486 | |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 487 | if (sidePanelViewStack.visible && mainViewStack.visible) { |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 488 | if (callStackViewShouldShow) { |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 489 | mainViewStack.push(callStackView) |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 490 | } else { |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 491 | mainViewStack.push(communicationPageMessageWebView) |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 492 | } |
| 493 | } else if (sidePanelViewStack.visible |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 494 | && !mainViewStack.visible) { |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 495 | if (callStackViewShouldShow) { |
| 496 | sidePanelViewStack.push(callStackView) |
| 497 | } else { |
| 498 | sidePanelViewStack.push(communicationPageMessageWebView) |
| 499 | } |
| 500 | } else if (!sidePanelViewStack.visible |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 501 | && !mainViewStack.visible) { |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 502 | if (callStackViewShouldShow) { |
| 503 | sidePanelViewStack.push(callStackView) |
| 504 | } else { |
| 505 | sidePanelViewStack.push(communicationPageMessageWebView) |
| 506 | } |
| 507 | } |
| 508 | } |
| 509 | |
| 510 | onAccountComboBoxNeedToShowWelcomePage: { |
| 511 | |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 512 | /* |
| 513 | * If the item argument is specified, all items down to (but not including) item will be popped. |
| 514 | */ |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 515 | if (!inSettingsView) { |
| 516 | mainViewStack.pop(welcomePage) |
ababi | 69f5dfc | 2020-08-25 15:07:57 +0200 | [diff] [blame^] | 517 | welcomePage.updateWelcomePage() |
| 518 | qrDialog.updateQrDialog() |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 519 | } |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 520 | } |
| 521 | |
| 522 | onConversationSmartListViewNeedToShowWelcomePage: { |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 523 | mainViewStack.pop(welcomePage) |
ababi | 69f5dfc | 2020-08-25 15:07:57 +0200 | [diff] [blame^] | 524 | welcomePage.updateWelcomePage() |
| 525 | qrDialog.updateQrDialog() |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 526 | } |
| 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 Blin | c75335f | 2020-08-04 20:54:02 -0400 | [diff] [blame] | 539 | mainViewStackLayout.currentIndex = 2 |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 540 | } |
| 541 | } |
| 542 | |
| 543 | CallStackView { |
| 544 | id: callStackView |
| 545 | |
| 546 | visible: false |
| 547 | |
| 548 | objectName: "callStackViewObject" |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 549 | |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 550 | } |
| 551 | |
| 552 | WelcomePage { |
| 553 | id: welcomePage |
| 554 | visible: false |
| 555 | } |
| 556 | |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 557 | 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 Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 581 | 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 |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 603 | && !mainViewStack.visible) { |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 604 | sidePanelViewStack.pop() |
| 605 | } else if (communicationPageMessageWebView.visible |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 606 | && mainViewStack.visible) { |
| 607 | mainViewStack.pop() |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 608 | } |
| 609 | } |
| 610 | |
| 611 | Component.onCompleted: { |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 612 | |
Sébastien Blin | c75335f | 2020-08-04 20:54:02 -0400 | [diff] [blame] | 613 | 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 Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 627 | /* |
| 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 | */ |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 640 | if (mainViewWindow.width < sidePanelViewStackPreferredWidth |
| 641 | + mainViewStackPreferredWidth - 5 |
| 642 | && mainViewStack.visible) { |
| 643 | mainViewStack.visible = false |
| 644 | sidePanelHidden = true |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 645 | |
| 646 | /* |
| 647 | * The find callback function is called for each item in the stack. |
| 648 | */ |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 649 | var inWelcomeViewStack = mainViewStack.find( |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 650 | function (item, index) { |
| 651 | return index > 0 |
| 652 | }) |
ababi | df651a2 | 2020-07-30 13:38:57 +0200 | [diff] [blame] | 653 | |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 654 | if (inWelcomeViewStack) { |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 655 | recursionStackViewItemMove(mainViewStack, sidePanelViewStack) |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 656 | } |
| 657 | |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 658 | mainViewWindow.update() |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 659 | } else if (mainViewWindow.width >= sidePanelViewStackPreferredWidth |
| 660 | + mainViewStackPreferredWidth + 5 |
| 661 | && !mainViewStack.visible) { |
| 662 | mainViewStack.visible = true |
| 663 | sidePanelHidden = false |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 664 | |
| 665 | var inSidePanelViewStack = sidePanelViewStack.find( |
| 666 | function (item, index) { |
| 667 | return index > 0 |
| 668 | }) |
| 669 | if (inSidePanelViewStack) { |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 670 | recursionStackViewItemMove(sidePanelViewStack, mainViewStack, (inSettingsView ? 2 : 1)) |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 671 | } |
| 672 | |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 673 | 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) |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 682 | width: Math.max(mainViewWindow.width / 2, aboutPopUpPreferredWidth) |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 683 | 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 |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 698 | |
| 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 Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 709 | } |
| 710 | |
| 711 | UserProfile { |
| 712 | id: userProfile |
| 713 | |
| 714 | x: Math.round((mainViewWindow.width - width) / 2) |
| 715 | y: Math.round((mainViewWindow.height - height) / 2) |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 716 | width: Math.max(mainViewWindow.width / 2, aboutPopUpPreferredWidth) |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 717 | 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 | } |