diff --git a/src/accountadapter.cpp b/src/accountadapter.cpp index 11007e0dae171abbfd6c1b8341f18b6869f309f6..442dbd88f9647035826ddfb6448f640152996119 100644 --- a/src/accountadapter.cpp +++ b/src/accountadapter.cpp @@ -40,7 +40,7 @@ AccountAdapter::safeInit() this, &AccountAdapter::onCurrentAccountChanged); - backToWelcomePage(); + deselectConversation(); auto accountId = LRCInstance::getCurrAccId(); setProperties(accountId); @@ -68,10 +68,10 @@ AccountAdapter::getDeviceModel() void AccountAdapter::accountChanged(int index) { + deselectConversation(); // Hack UI auto accountList = LRCInstance::accountModel().getAccountList(); if (accountList.size() > index) { LRCInstance::setSelectedAccountId(accountList.at(index)); - backToWelcomePage(); } } @@ -335,13 +335,6 @@ AccountAdapter::passwordSetStatusMessageBox(bool success, QString title, QString } } -void -AccountAdapter::backToWelcomePage() -{ - deselectConversation(); - emit navigateToWelcomePageRequested(); -} - void AccountAdapter::deselectConversation() { diff --git a/src/accountadapter.h b/src/accountadapter.h index 33840a7048a55ab8f11e03f4a708eea3f942d68c..78abf7217124ecb48218bdc0fc6e18a321371c12 100644 --- a/src/accountadapter.h +++ b/src/accountadapter.h @@ -115,7 +115,6 @@ signals: * send report failure to QML to make it show the right UI state . */ void reportFailure(); - void navigateToWelcomePageRequested(); void accountAdded(bool showBackUp, int index); private slots: @@ -126,7 +125,6 @@ private: lrc::api::profile::Type currentAccountType_ {}; int accountListSize_ {}; - void backToWelcomePage(); void deselectConversation(); /* diff --git a/src/calladapter.cpp b/src/calladapter.cpp index 96dcb73695e904491220b97a134d6c23c46ae8bb..8a4bc29c89c79c6337e3791bcce6612a59d0fef3 100644 --- a/src/calladapter.cpp +++ b/src/calladapter.cpp @@ -108,20 +108,19 @@ CallAdapter::slotShowIncomingCallView(const QString& accountId, const conversati { auto selectedAccountId = LRCInstance::getCurrAccId(); auto* callModel = LRCInstance::getCurrentCallModel(); + auto* convModel = LRCInstance::getCurrentConversationModel(); + if (!callModel->hasCall(convInfo.callId)) { if (QApplication::focusObject() == nullptr || accountId != selectedAccountId) { showNotification(accountId, convInfo.uid); return; } - auto* convModel = LRCInstance::getCurrentConversationModel(); const auto currentConvUid = LRCInstance::getCurrentConvUid(); const auto currentConvInfo = convModel->getConversationForUID(currentConvUid); - // Call in current conversation + // Current call auto currentConvHasCall = callModel->hasCall(currentConvInfo.callId); - - // Check INCOMING / OUTGOING call in current conversation if (currentConvHasCall) { auto currentCall = callModel->getCall(currentConvInfo.callId); if (currentCall.status == lrc::api::call::Status::CONNECTED @@ -130,9 +129,7 @@ CallAdapter::slotShowIncomingCallView(const QString& accountId, const conversati return; } } - emit incomingCallNeedToSetupMainView(accountId, convInfo.uid); - emit showIncomingCallPage(accountId, convInfo.uid); - emit showCallStack(accountId, convInfo.uid, true); + emit callSetupMainViewRequired(accountId, convInfo.uid); emit LRCInstance::instance().updateSmartList(); return; } @@ -142,11 +139,9 @@ CallAdapter::slotShowIncomingCallView(const QString& accountId, const conversati if (call.isOutgoing) { if (isCallSelected) { - emit showOutgoingCallPage(accountId, convInfo.uid); - emit showCallStack(accountId, convInfo.uid, true); + emit callSetupMainViewRequired(accountId, convInfo.uid); } } else { - auto showIncomingCall = false; auto accountProperties = LRCInstance::accountModel().getAccountConfig(selectedAccountId); if (!accountProperties.autoAnswer && !accountProperties.isRendezVous) { // App not focused or in different account @@ -155,7 +150,6 @@ CallAdapter::slotShowIncomingCallView(const QString& accountId, const conversati return; } - auto* convModel = LRCInstance::getCurrentConversationModel(); const auto currentConvUid = LRCInstance::getCurrentConvUid(); const auto currentConvInfo = convModel->getConversationForUID(currentConvUid); @@ -168,11 +162,12 @@ CallAdapter::slotShowIncomingCallView(const QString& accountId, const conversati auto currentCall = callModel->getCall(currentConvInfo.callId); if (currentCall.status == lrc::api::call::Status::OUTGOING_RINGING) { showNotification(accountId, convInfo.uid); + return; } else { - showIncomingCall = true; + emit callSetupMainViewRequired(accountId, convInfo.uid); } } else { - showIncomingCall = true; + emit callSetupMainViewRequired(accountId, convInfo.uid); } } else { // Not current conversation if (currentConvHasCall) { @@ -183,15 +178,9 @@ CallAdapter::slotShowIncomingCallView(const QString& accountId, const conversati return; } } - showIncomingCall = true; + emit callSetupMainViewRequired(accountId, convInfo.uid); } } - - if (showIncomingCall) { - emit incomingCallNeedToSetupMainView(accountId, convInfo.uid); - emit showIncomingCallPage(accountId, convInfo.uid); - emit showCallStack(accountId, convInfo.uid, true); - } } emit callStatusChanged(static_cast<int>(call.status), accountId, convInfo.uid); emit LRCInstance::instance().updateSmartList(); @@ -220,20 +209,9 @@ CallAdapter::updateCall(const QString& convUid, const QString& accountId, bool f return; } - if (call->isAudioOnly) { - emit showAudioCallPage(accountId_, convUid_); - } else { - emit showVideoCallPage(accountId_, convUid_, call->id); - } - + emit callSetupMainViewRequired(accountId_, convUid_); updateCallOverlay(convInfo); - - /* - * Preview. - */ emit previewVisibilityNeedToChange(shouldShowPreview(forceCallOnly)); - - emit showCallStack(accountId_, convUid_); } bool @@ -310,26 +288,15 @@ CallAdapter::showNotification(const QString& accountId, const QString& convUid) } } - auto onClicked = [this, accountId, convInfo]() { + auto onClicked = [this, convInfo]() { #ifdef Q_OS_WINDOWS emit LRCInstance::instance().notificationClicked(); #else emit LRCInstance::instance().notificationClicked(true); #endif - // TODO: only a selectConversation(accountId, convUid) should occur - // here, the UI should resolve its state by observation as much as possible, - // or in response to a conversationSelected signal. - // - https://git.jami.net/savoirfairelinux/jami-client-qt/issues/87 - // - https://git.jami.net/savoirfairelinux/jami-client-qt/issues/86 - emit incomingCallNeedToSetupMainView(accountId, convInfo.uid); - auto call = LRCInstance::getCallInfoForConversation(convInfo); - if (call && call->status == lrc::api::call::Status::INCOMING_RINGING) { - emit showIncomingCallPage(accountId, convInfo.uid); - emit showCallStack(accountId, convInfo.uid, true); - } - emit LRCInstance::instance().updateSmartList(); + callSetupMainViewRequired(convInfo.accountId, convInfo.uid); }; - + emit LRCInstance::instance().updateSmartList(); Utils::showNotification(tr("is calling you"), from, accountId, convUid, onClicked); } @@ -437,12 +404,9 @@ CallAdapter::connectCallModel(const QString& accountId) * Reset the call view corresponding accountId, uid. */ LRCInstance::setSelectedConvId(otherConv.uid); - showCallStack(otherConv.accountId, otherConv.uid, true); updateCall(otherConv.uid, otherConv.accountId, forceCallOnly); } } - } else { - emit closeCallStack(accountId, convInfo.uid); } break; diff --git a/src/calladapter.h b/src/calladapter.h index 7ebf6433470cf68e393e0b4c657c4b6c22310627..a6b2978bdc38f6399f31f4d7b9fbd64cbcaa2f70 100644 --- a/src/calladapter.h +++ b/src/calladapter.h @@ -67,21 +67,12 @@ public: Q_INVOKABLE QVariantList getConferencesInfos(); signals: - void showOutgoingCallPage(const QString& accountId, const QString& convUid); - void showIncomingCallPage(const QString& accountId, const QString& convUid); - void showAudioCallPage(const QString& accountId, const QString& convUid); - void showVideoCallPage(const QString& accountId, const QString& convUid, const QString& callId); - void showCallStack(const QString& accountId, const QString& convUid, bool forceReset = false); - void closeCallStack(const QString& accountId, const QString& convUid); void callStatusChanged(int index, const QString& accountId, const QString& convUid); void updateConversationSmartList(); void updateParticipantsInfos(const QVariantList& infos, const QString& accountId, const QString& callId); - - void incomingCallNeedToSetupMainView(const QString& accountId, - const QString& convUid, - bool fromNotification = false); + void callSetupMainViewRequired(const QString& accountId, const QString& convUid); void previewVisibilityNeedToChange(bool visible); /* diff --git a/src/conversationsadapter.cpp b/src/conversationsadapter.cpp index 78fac053165ec820272dfc29a2be8b69cd00eb63..8d93b5e2283068de2a5f9ebe2cff9577292fd980 100644 --- a/src/conversationsadapter.cpp +++ b/src/conversationsadapter.cpp @@ -42,7 +42,7 @@ ConversationsAdapter::safeInit() connect(&LRCInstance::behaviorController(), &BehaviorController::showChatView, [this](const QString& accountId, lrc::api::conversation::Info convInfo) { - emit showChatView(accountId, convInfo.uid); + emit showConversation(accountId, convInfo.uid); }); connect(&LRCInstance::behaviorController(), @@ -66,64 +66,35 @@ ConversationsAdapter::backToWelcomePage() } void -ConversationsAdapter::selectConversation(const QString& accountId, - const QString& convUid, - bool preventSendingSignal) +ConversationsAdapter::selectConversation(const QString& accountId, const QString& convUid) { - auto& accInfo = LRCInstance::getAccountInfo(accountId); - const auto convInfo = accInfo.conversationModel->getConversationForUID(convUid); + auto* convModel = LRCInstance::getAccountInfo(accountId).conversationModel.get(); + const auto& convInfo = convModel->getConversationForUID(convUid); - selectConversation(convInfo, preventSendingSignal); -} - -void -ConversationsAdapter::selectConversation(const QString& convUid) -{ - auto* convModel = LRCInstance::getCurrentConversationModel(); - if (convModel == nullptr) { - return; - } - - const auto& conversation = convModel->getConversationForUID(convUid); - - if (selectConversation(conversation, false)) { - // If it is calling, show callview (can use showChatView signal, since it will be determined on qml). - if (!conversation.uid.isEmpty() - && LRCInstance::getCurrentCallModel()->hasCall(conversation.callId)) { - emit showChatView(LRCInstance::getCurrAccId(), conversation.uid); - } - } -} - -bool -ConversationsAdapter::selectConversation(const lrc::api::conversation::Info& convInfo, - bool preventSendingSignal) -{ - // accInfo.conversationModel->selectConversation(item.uid) only emit ui - // behavior control signals, but sometimes we do not want that, - // preventSendingSignal boolean can help us to determine. - if (LRCInstance::getCurrentConvUid() == convInfo.uid - && LRCInstance::getCurrAccId() == convInfo.accountId) { - return false; - } else if (convInfo.participants.size() > 0) { + if (LRCInstance::getCurrentConvUid() != convInfo.uid + && convInfo.participants.size() > 0) { // If the account is not currently selected, do that first, then // proceed to select the conversation. - auto selectConversation = [convInfo, preventSendingSignal] { + auto selectConversation = [convInfo] { auto& accInfo = LRCInstance::getAccountInfo(convInfo.accountId); LRCInstance::setSelectedConvId(convInfo.uid); - if (!preventSendingSignal) - accInfo.conversationModel->selectConversation(convInfo.uid); accInfo.conversationModel->clearUnreadInteractions(convInfo.uid); }; if (convInfo.accountId != LRCInstance::getCurrAccId()) { Utils::oneShotConnect(&LRCInstance::instance(), &LRCInstance::currentAccountChanged, - [selectConversation] { selectConversation(); }); + [selectConversation] { + selectConversation(); + }); + LRCInstance::setSelectedConvId(); // Hack UI LRCInstance::setSelectedAccountId(convInfo.accountId); } else { selectConversation(); } - return true; + } + + if (!convInfo.uid.isEmpty()) { + emit showConversation(LRCInstance::getCurrAccId(), convInfo.uid); } } @@ -178,7 +149,7 @@ ConversationsAdapter::onNewUnreadInteraction(const QString& accountId, #endif auto convInfo = LRCInstance::getConversationFromConvUid(convUid, accountId); if (!convInfo.uid.isEmpty()) { - selectConversation(convInfo, false); + selectConversation(accountId, convInfo.uid); emit LRCInstance::instance().updateSmartList(); emit modelSorted(uri); } diff --git a/src/conversationsadapter.h b/src/conversationsadapter.h index 8b6ebdc61ea44a72e70d5934e1b73659ede8768c..a127a3814b8e663b8133b7bfffe6ef81ad441aec 100644 --- a/src/conversationsadapter.h +++ b/src/conversationsadapter.h @@ -38,17 +38,14 @@ protected: public: Q_INVOKABLE bool connectConversationModel(bool updateFilter = true); Q_INVOKABLE void disconnectConversationModel(); - Q_INVOKABLE void selectConversation(const QString& accountId, - const QString& convUid, - bool preventSendingSignal = true); - Q_INVOKABLE void selectConversation(const QString& uid); + Q_INVOKABLE void selectConversation(const QString& accountId, const QString& uid); Q_INVOKABLE void deselectConversation(); Q_INVOKABLE void refill(); Q_INVOKABLE void updateConversationsFilterWidget(); Q_INVOKABLE void setConversationFilter(const QString& type); signals: - void showChatView(const QString& accountId, const QString& convUid); + void showConversation(const QString& accountId, const QString& convUid); void showConversationTabs(bool visible); void showSearchStatus(const QString& status); @@ -67,8 +64,6 @@ private slots: private: void setConversationFilter(lrc::api::profile::Type filter); void backToWelcomePage(); - bool selectConversation(const lrc::api::conversation::Info& item, - bool preventSendingSignal = true); void updateConversationForNewContact(const QString& convUid); SmartListModel* conversationSmartListModel_; diff --git a/src/mainview/MainView.qml b/src/mainview/MainView.qml index 44997f64532bed408ccfd6f1212897de67ffa9e6..daedafc2fe88167826a37d4beac3c0dc17549755 100644 --- a/src/mainview/MainView.qml +++ b/src/mainview/MainView.qml @@ -55,6 +55,9 @@ Window { property int tabButtonShrinkSize: 8 property bool inSettingsView: false + // For updating msgWebView + property string currentConvUID: "" + signal closeApp signal noAccountIsAvailable @@ -65,8 +68,8 @@ Window { if (inSettingsView) { settingsView.accountListChanged() settingsView.setSelected(settingsView.selectedMenu, true) - } else if (currentAccountIsCalling()) { - setCallStackView() + } else { + backToMainView(true) } } @@ -79,6 +82,8 @@ Window { } function showWelcomeView() { + currentConvUID = "" + callStackView.needToCloseInCallConversationAndPotentialWindow() mainViewWindowSidePanel.deselectConversationSmartList() if (isPageInStack("callStackViewObject", sidePanelViewStack) || isPageInStack("communicationPageMessageWebView", sidePanelViewStack) || @@ -90,39 +95,9 @@ Window { recordBox.visible = false } - function setCallStackView() { - - mainViewWindowSidePanel.deselectConversationSmartList() - - var currentAccount = AccountAdapter.currentAccountId - var currentCallConv = UtilsAdapter.getCallConvForAccount(currentAccount) - - ConversationsAdapter.selectConversation(currentCallConv) - var callId = UtilsAdapter.getCallId(currentAccount, currentCallConv) - var callStatus = UtilsAdapter.getCallStatus(callId) - - switch (callStatus) { - case Call.Status.INCOMING_RINGING: - callStackView.showIncomingCallPage(currentAccount, currentCallConv) - break - case Call.Status.OUTGOING_RINGING: - callStackView.showOutgoingCallPage() - break - default: - if (UtilsAdapter.hasVideoCall()) { - callStackView.showVideoCallPage(callId) - } else { - callStackView.showAudioCallPage() - } - } - - callStackView.responsibleAccountId = currentAccount - callStackView.responsibleConvUid = currentCallConv - callStackView.updateCorrespondingUI() - } - function pushCallStackView() { if (sidePanelOnly) { + sidePanelViewStack.pop(StackView.Immediate) sidePanelViewStack.push(callStackView, StackView.Immediate) } else { sidePanelViewStack.pop(StackView.Immediate) @@ -160,6 +135,21 @@ Window { stackTwo.push(tempItem, StackView.Immediate) } + // Back to WelcomeView required, but can also check, i. e., on account switch or + // settings exit, if there is need to switch to a current call + function backToMainView(checkCurrentCall = false) { + if (inSettingsView) + return + if (checkCurrentCall && currentAccountIsCalling()) { + var callConv = UtilsAdapter.getCallConvForAccount( + AccountAdapter.currentAccountId) + ConversationsAdapter.selectConversation( + AccountAdapter.currentAccountId, callConv) + } else { + showWelcomeView() + } + } + function toggleSettingsView() { inSettingsView = !inSettingsView @@ -179,13 +169,54 @@ Window { } else { sidePanelViewStack.pop(StackView.Immediate) mainViewStack.pop(StackView.Immediate) - - if (currentAccountIsCalling()) - setCallStackView() - else - mainViewWindowSidePanel.deselectConversationSmartList() + backToMainView(true) } + } + // ConversationSmartListViewItemDelegate provides UI information + function setMainView(currentUserDisplayName, currentUserAlias, currentUID, + callStackViewShouldShow, isAudioOnly, callState) { + if (callStackViewShouldShow) { + if (inSettingsView) { + toggleSettingsView() + } + MessagesAdapter.setupChatView(currentUID) + communicationPageMessageWebView.headerUserAliasLabelText = currentUserAlias + communicationPageMessageWebView.headerUserUserNameLabelText = currentUserDisplayName + callStackView.setLinkedWebview(communicationPageMessageWebView) + callStackView.responsibleAccountId = AccountAdapter.currentAccountId + callStackView.responsibleConvUid = currentUID + callStackView.updateCorrespondingUI() + + if (callState === Call.Status.IN_PROGRESS || callState === Call.Status.PAUSED) { + UtilsAdapter.setCurrentCall(AccountAdapter.currentAccountId, currentUID) + if (isAudioOnly) + callStackView.showAudioCallPage() + else + callStackView.showVideoCallPage() + } else if (callState === Call.Status.INCOMING_RINGING) { + callStackView.showIncomingCallPage(AccountAdapter.currentAccountId, + currentUID) + } else { + callStackView.showOutgoingCallPage(callState) + } + pushCallStackView() + } else if (!inSettingsView) { + if (currentConvUID !== currentUID) { + callStackView.needToCloseInCallConversationAndPotentialWindow() + MessagesAdapter.setupChatView(currentUID) + communicationPageMessageWebView.headerUserAliasLabelText = currentUserAlias + communicationPageMessageWebView.headerUserUserNameLabelText = currentUserDisplayName + pushCommunicationMessageWebView() + communicationPageMessageWebView.focusMessageWebView() + currentConvUID = currentUID + } else if (isPageInStack("callStackViewObject", sidePanelViewStack) + || isPageInStack("callStackViewObject", mainViewStack)) { + callStackView.needToCloseInCallConversationAndPotentialWindow() + pushCommunicationMessageWebView() + communicationPageMessageWebView.focusMessageWebView() + } + } } title: JamiStrings.appTitle @@ -198,61 +229,9 @@ Window { Connections { target: CallAdapter - function onShowCallStack(accountId, convUid, forceReset) { - - if (forceReset) { - callStackView.responsibleAccountId = accountId - callStackView.responsibleConvUid = convUid - } - - // Check if it is coming from the current responsible call, - // and push views onto the correct stackview - if (callStackView.responsibleAccountId === accountId - && callStackView.responsibleConvUid === convUid) { - pushCallStackView() - } - } - - function onCloseCallStack(accountId, convUid) { - // Check if call stack view is on any of the stackview. - if (callStackView.responsibleAccountId === accountId - && callStackView.responsibleConvUid === convUid) { - if (isPageInStack("callStackViewObject", sidePanelViewStack) || - isPageInStack("callStackViewObject", mainViewStack)) { - if (!inSettingsView) { - callStackView.needToCloseInCallConversationAndPotentialWindow() - pushCommunicationMessageWebView() - } - } - } - } - - function onIncomingCallNeedToSetupMainView(accountId, convUid, fromNotification) { - // Set up the call stack view that is needed by call overlay. - if (!inSettingsView) { - mainViewStack.pop(welcomePage, StackView.Immediate) - sidePanelViewStack.pop(mainViewWindowSidePanel, StackView.Immediate) - } else { - toggleSettingsView() - } - - var index = UtilsAdapter.getCurrAccList().indexOf(accountId) - var name = UtilsAdapter.getBestName(accountId, convUid) - var id = UtilsAdapter.getBestId(accountId, convUid) - - communicationPageMessageWebView.headerUserAliasLabelText = name - communicationPageMessageWebView.headerUserUserNameLabelText = (name !== id) ? id : "" - - callStackView.needToCloseInCallConversationAndPotentialWindow() - callStackView.setLinkedWebview(communicationPageMessageWebView) - - callStackView.responsibleAccountId = accountId - callStackView.responsibleConvUid = convUid - callStackView.updateCorrespondingUI() - - AccountAdapter.accountChanged(index) - ConversationsAdapter.selectConversation(accountId, convUid, !fromNotification) - MessagesAdapter.setupChatView(convUid) + // selectConversation causes UI update + function onCallSetupMainViewRequired(accountId, convUid) { + ConversationsAdapter.selectConversation(accountId, convUid) } } @@ -317,11 +296,6 @@ Window { function onAccountStatusChanged() { accountComboBox.resetAccountListModel() } - - function onNavigateToWelcomePageRequested() { - if (!inSettingsView && !currentAccountIsCalling()) - showWelcomeView() - } } onSettingBtnClicked: { @@ -371,26 +345,12 @@ Window { onNeedToShowMainViewWindow: { mainViewStackLayout.currentIndex = 0 - // TODO: to be simplified in the refactor - if (!inSettingsView) { - if (currentAccountIsCalling()) { - setCallStackView() - } else { - showWelcomeView() - } - } + backToMainView() } onWizardViewIsClosed: { mainViewStackLayout.currentIndex = 0 - // TODO: to be simplified in the refactor - if (!inSettingsView) { - if (currentAccountIsCalling()) { - setCallStackView() - } else { - showWelcomeView() - } - } + backToMainView() } } } @@ -445,87 +405,11 @@ Window { SidePanel { id: mainViewWindowSidePanel - onFocusMessageWebViewRequested: { - communicationPageMessageWebView.focusMessageWebView() - } - - // TODO: remove the evil in this slot - onConversationSmartListNeedToAccessMessageWebView: { - communicationPageMessageWebView.headerUserAliasLabelText = currentUserAlias - communicationPageMessageWebView.headerUserUserNameLabelText = currentUserDisplayName - - callStackView.needToCloseInCallConversationAndPotentialWindow() - callStackView.responsibleAccountId = AccountAdapter.currentAccountId - callStackView.responsibleConvUid = currentUID - callStackView.updateCorrespondingUI() - - if (callStackViewShouldShow) { - if (callState === Call.Status.IN_PROGRESS || callState === Call.Status.PAUSED) { - UtilsAdapter.setCurrentCall(AccountAdapter.currentAccountId, currentUID) - if (isAudioOnly) - callStackView.showAudioCallPage() - else - callStackView.showVideoCallPage( - UtilsAdapter.getCallId( - callStackView.responsibleAccountId, - callStackView.responsibleConvUid)) - } else if (callState === Call.Status.INCOMING_RINGING) { - callStackView.showIncomingCallPage(AccountAdapter.currentAccountId, - currentUID) - } else { - callStackView.showOutgoingCallPage(callState) - } - } - - // Set up chatview. - MessagesAdapter.setupChatView(currentUID) - callStackView.setLinkedWebview(communicationPageMessageWebView) - - if (isPageInStack("communicationPageMessageWebView", sidePanelViewStack) || - isPageInStack("communicationPageMessageWebView", mainViewStack)) { - if (!callStackViewShouldShow) - return - } - - // Push messageWebView or callStackView onto the correct stackview - mainViewStack.pop(welcomePage, StackView.Immediate) - sidePanelViewStack.pop(mainViewWindowSidePanel, StackView.Immediate) - - if (sidePanelViewStack.visible && mainViewStack.visible) { - if (callStackViewShouldShow) { - mainViewStack.push(callStackView) - } else { - mainViewStack.push(communicationPageMessageWebView) - } - } else if (sidePanelViewStack.visible - && !mainViewStack.visible) { - // Note: the change of visibility for mainViewWindowSidePanel - // is to prevent accountComboBox to be shown when pushing - // pages to sidePanelViewStack (to be refactored) - mainViewWindowSidePanel.visible = false - if (callStackViewShouldShow) { - sidePanelViewStack.push(callStackView, StackView.Immediate) - } else { - sidePanelViewStack.push(communicationPageMessageWebView, StackView.Immediate) - } - } else if (!sidePanelViewStack.visible - && !mainViewStack.visible) { - if (callStackViewShouldShow) { - sidePanelViewStack.push(callStackView) - } else { - sidePanelViewStack.push(communicationPageMessageWebView) - } - } - - if (!callStackViewShouldShow) - communicationPageMessageWebView.focusMessageWebView() - } - Connections { target: ConversationsAdapter function onNavigateToWelcomePageRequested() { - showWelcomeView() + backToMainView() } } } @@ -578,7 +462,7 @@ Window { } function onContactBanned() { - showWelcomeView() + backToMainView() } } diff --git a/src/mainview/components/AccountComboBoxPopup.qml b/src/mainview/components/AccountComboBoxPopup.qml index 441436d85a64124c0ef48d3b446901ef083ae79d..c20edfbe90687f52d8764aed01f37dddbe8fa0f9 100644 --- a/src/mainview/components/AccountComboBoxPopup.qml +++ b/src/mainview/components/AccountComboBoxPopup.qml @@ -91,7 +91,7 @@ Popup { anchors.left: userImage.right anchors.leftMargin: 10 - anchors.top: itemCoboBackground.top + anchors.top: itemComboBackground.top anchors.topMargin: 15 text: textMetricsUserAliasPopup.elidedText @@ -125,7 +125,7 @@ Popup { } background: Rectangle { - id: itemCoboBackground + id: itemComboBackground color: JamiTheme.backgroundColor implicitWidth: accountComboBox.width implicitHeight: accountComboBox.height @@ -135,19 +135,19 @@ Popup { anchors.fill: parent hoverEnabled: true onPressed: { - itemCoboBackground.color = JamiTheme.pressColor + itemComboBackground.color = JamiTheme.pressColor } onReleased: { - itemCoboBackground.color = JamiTheme.releaseColor + itemComboBackground.color = JamiTheme.releaseColor currentIndex = index root.close() AccountAdapter.accountChanged(index) } onEntered: { - itemCoboBackground.color = JamiTheme.hoverColor + itemComboBackground.color = JamiTheme.hoverColor } onExited: { - itemCoboBackground.color = JamiTheme.backgroundColor + itemComboBackground.color = JamiTheme.backgroundColor } } } diff --git a/src/mainview/components/CallStackView.qml b/src/mainview/components/CallStackView.qml index 0dba8313ae783df188d9de559c9cfee96c7e039a..46ee0144d857d75a35c41468a8f48d6c3b5bc9d4 100644 --- a/src/mainview/components/CallStackView.qml +++ b/src/mainview/components/CallStackView.qml @@ -107,7 +107,7 @@ Rectangle { incomingCallPage.updateUI(accountId, convUid) } - function showVideoCallPage(callId) { + function showVideoCallPage() { var itemToFind = callStackMainView.find(function (item) { return item.stackNumber === 2 }) @@ -118,6 +118,8 @@ Rectangle { callStackMainView.pop(itemToFind, StackView.Immediate) } videoCallPage.updateUI(responsibleAccountId, responsibleConvUid) + var callId = UtilsAdapter.getCallId(responsibleAccountId, + responsibleConvUid) videoCallPage.setDistantRendererId(callId) } @@ -138,33 +140,6 @@ Rectangle { Connections { target: CallAdapter - function onShowOutgoingCallPage(accountId, convUid) { - - // Need to check whether it is the current selected conversation. - if (responsibleConvUid === convUid - && responsibleAccountId === accountId) { - showOutgoingCallPage() - } - } - - function onShowIncomingCallPage(accountId, convUid) { - showIncomingCallPage(accountId, convUid) - } - - function onShowAudioCallPage(accountId, convUid) { - if (responsibleConvUid === convUid - && responsibleAccountId === accountId) { - showAudioCallPage() - } - } - - function onShowVideoCallPage(accountId, convUid, callId) { - if (responsibleConvUid === convUid - && responsibleAccountId === accountId) { - showVideoCallPage(callId) - } - } - function onCallStatusChanged(status, accountId, convUid) { if (responsibleConvUid === convUid && responsibleAccountId === accountId) { outgoingCallPage.callStatus = status diff --git a/src/mainview/components/ConversationSmartListView.qml b/src/mainview/components/ConversationSmartListView.qml index 7f8c16f995b2123cd7fbd53d47103ee2690813a5..a6f7ada58c0c2e6958fc3dc35480ac70ad63f0a3 100644 --- a/src/mainview/components/ConversationSmartListView.qml +++ b/src/mainview/components/ConversationSmartListView.qml @@ -26,11 +26,7 @@ import net.jami.Adapters 1.0 ListView { id: root - signal needToAccessMessageWebView(string currentUserDisplayName, string currentUserAlias, string currentUID, bool callStackViewShouldShow, bool isAudioOnly, int callState) - signal needToSelectItems(string conversationUid) signal needToDeselectItems - - signal needToShowChatView(string accountId, string convUid) signal forceUpdatePotentialInvalidItem // Refresh all items within the model. diff --git a/src/mainview/components/ConversationSmartListViewItemDelegate.qml b/src/mainview/components/ConversationSmartListViewItemDelegate.qml index f7a415ade1b03f4914ddfcaf057fa3178da0d773..df96d7762307856c234a448e285994c0ff8d7bfb 100644 --- a/src/mainview/components/ConversationSmartListViewItemDelegate.qml +++ b/src/mainview/components/ConversationSmartListViewItemDelegate.qml @@ -54,16 +54,19 @@ ItemDelegate { return InCall ? Qt.lighter(JamiTheme.selectionBlue, 1.8) : JamiTheme.releaseColor }) - conversationSmartListView.needToSelectItems(UID) + ConversationsAdapter.selectConversation( + AccountAdapter.currentAccountId, UID) } } + } + + Connections { + target: ConversationsAdapter - function onNeedToShowChatView(accountId, convUid) { + function onShowConversation(accountId, convUid) { if (convUid === UID) { - conversationSmartListView.needToAccessMessageWebView( - DisplayID == DisplayName ? "" : DisplayID, - DisplayName, UID, CallStackViewShouldShow, - IsAudioOnly, CallState) + mainViewWindow.setMainView(DisplayID == DisplayName ? "" : DisplayID, + DisplayName, UID, CallStackViewShouldShow, IsAudioOnly, CallState) } } } diff --git a/src/mainview/components/SidePanel.qml b/src/mainview/components/SidePanel.qml index 8c107a44dbdd39d0ccf9e68779f0b4a368c6fb03..3ca544c0444c30a8414f80afa9f20dcea0b5dc6f 100644 --- a/src/mainview/components/SidePanel.qml +++ b/src/mainview/components/SidePanel.qml @@ -33,9 +33,6 @@ Rectangle { property int pendingRequestCount: 0 property int totalUnreadMessagesCount: 0 - signal conversationSmartListNeedToAccessMessageWebView(string currentUserDisplayName, string currentUserAlias, string currentUID, bool callStackViewShouldShow, bool isAudioOnly, int callState) - signal focusMessageWebViewRequested - // Hack -> force redraw. function forceReselectConversationSmartListCurrentIndex() { var index = conversationSmartListView.currentIndex @@ -176,15 +173,9 @@ Rectangle { height: tabBarVisible ? sidePanelRect.height - sidePanelTabBar.height - contactSearchBar.height - 20 : sidePanelRect.height - contactSearchBar.height - 20 - onCurrentIndexChanged: focusMessageWebViewRequested() - Connections { target: ConversationsAdapter - function onShowChatView(accountId, convUid) { - conversationSmartListView.needToShowChatView(accountId, convUid) - } - function onShowConversationTabs(visible) { tabBarVisible = visible updatePendingRequestCount() @@ -196,17 +187,6 @@ Rectangle { } } - onNeedToSelectItems: { - ConversationsAdapter.selectConversation(conversationUid) - } - - onNeedToAccessMessageWebView: { - sidePanelRect.conversationSmartListNeedToAccessMessageWebView( - currentUserDisplayName, currentUserAlias, - currentUID, callStackViewShouldShow, - isAudioOnly, callState) - } - Component.onCompleted: { ConversationsAdapter.setQmlObject(this) conversationSmartListView.currentIndex = -1 diff --git a/src/messagesadapter.cpp b/src/messagesadapter.cpp index 810305dcf6aace582e785e610980e660265ebd01..b36eb92266d5ee0da8cff6730a0e9b2e6031ba4a 100644 --- a/src/messagesadapter.cpp +++ b/src/messagesadapter.cpp @@ -56,6 +56,10 @@ MessagesAdapter::setupChatView(const QString& uid) if (convModel == nullptr) { return; } + + if (currentConvUid_ == uid) + return; + const auto& convInfo = convModel->getConversationForUID(uid); if (convInfo.uid.isEmpty() || convInfo.participants.isEmpty()) { return; @@ -105,6 +109,8 @@ MessagesAdapter::setupChatView(const QString& uid) SLOT(slotSendMessageContentSaved(const QString&))); requestSendMessageContent(); + + currentConvUid_ = uid; } void diff --git a/src/messagesadapter.h b/src/messagesadapter.h index 9a73c4b6eca1e733cf9b45a7442ddbeb0f483dfa..41c89a5f6359a037638221c476127af2d32ced7d 100644 --- a/src/messagesadapter.h +++ b/src/messagesadapter.h @@ -103,6 +103,7 @@ private: const interaction::Info& interaction); QString LastConvUid_; + QString currentConvUid_; /* * Interaction connections. diff --git a/src/smartlistmodel.cpp b/src/smartlistmodel.cpp index f777d488e5700fdc66e6e7a0208925436efe29dc..3fd0b47f22edaa03845ad62f1f15b55b8c98775c 100644 --- a/src/smartlistmodel.cpp +++ b/src/smartlistmodel.cpp @@ -336,7 +336,8 @@ SmartListModel::getConversationItemData(const conversation::Info& item, && (call.status == lrc::api::call::Status::IN_PROGRESS || call.status == lrc::api::call::Status::PAUSED || call.status == lrc::api::call::Status::INCOMING_RINGING)) - || call.isOutgoing)); + || (call.isOutgoing + && call.status != lrc::api::call::Status::ENDED))); } return QVariant(false); }