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