From 76b94aac11a28dfe7b0cb149cd590fcd1b65b809 Mon Sep 17 00:00:00 2001 From: ababi <albert.babi@savoirfairelinux.com> Date: Mon, 24 Aug 2020 17:46:30 +0200 Subject: [PATCH] mainview: get call state from API's enumeration In order to make it work with the translations, call status is no longer passed as a string but as an integer (from enum lrc::api::call::Status). Gitlab: #10 Change-Id: If8d8b7093fbf82e9b7732e6991eec647ad0d50b7 --- src/calladapter.cpp | 6 ++---- src/calladapter.h | 6 +++--- src/mainview/MainView.qml | 2 +- src/mainview/components/CallStackView.qml | 4 ++-- src/mainview/components/ConversationSmartListView.qml | 2 +- .../components/ConversationSmartListViewItemDelegate.qml | 4 ++-- src/mainview/components/OutgoingCallPage.qml | 4 ++-- src/mainview/components/SidePanel.qml | 5 +++-- src/smartlistmodel.cpp | 8 ++++---- src/smartlistmodel.h | 2 +- src/utils.cpp | 8 ++++++++ src/utils.h | 1 + 12 files changed, 30 insertions(+), 22 deletions(-) diff --git a/src/calladapter.cpp b/src/calladapter.cpp index c4badc91d..0ead73b69 100644 --- a/src/calladapter.cpp +++ b/src/calladapter.cpp @@ -176,7 +176,7 @@ CallAdapter::slotShowIncomingCallView(const QString& accountId, const conversati } } - emit callStatusChanged(lrc::api::call::to_string(call.status), accountId, convInfo.uid); + emit callStatusChanged(static_cast<int>(call.status), accountId, convInfo.uid); emit updateConversationSmartList(); } @@ -342,9 +342,7 @@ CallAdapter::connectCallModel(const QString& accountId) */ const auto convInfo = LRCInstance::getConversationFromCallId(callId); if (!convInfo.uid.isEmpty()) { - emit callStatusChanged(lrc::api::call::to_string(call.status), - accountId, - convInfo.uid); + emit callStatusChanged(static_cast<int>(call.status), accountId, convInfo.uid); } switch (call.status) { diff --git a/src/calladapter.h b/src/calladapter.h index fbf5ffc4d..bd7871d79 100644 --- a/src/calladapter.h +++ b/src/calladapter.h @@ -56,7 +56,7 @@ public: Q_INVOKABLE void minimizeParticipant(); Q_INVOKABLE void hangUpThisCall(); Q_INVOKABLE bool isCurrentMaster() const; - Q_INVOKABLE int getCurrentLayoutType() const; + Q_INVOKABLE int getCurrentLayoutType() const; Q_INVOKABLE void holdThisCallToggle(); Q_INVOKABLE void muteThisCallToggle(); Q_INVOKABLE void recordThisCallToggle(); @@ -72,7 +72,7 @@ signals: void showCallStack(const QString& accountId, const QString& convUid, bool forceReset = false); void closeCallStack(const QString& accountId, const QString& convUid); void closePotentialIncomingCallPageWindow(const QString& accountId, const QString& convUid); - void callStatusChanged(const QString& status, 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, @@ -84,7 +84,7 @@ signals: /* * For Call Overlay */ - void updateTimeText(const QString& time); + void updateTimeText(const QString &time); void showOnHoldLabel(bool isPaused); void updateOverlay(bool isPaused, bool isAudioOnly, diff --git a/src/mainview/MainView.qml b/src/mainview/MainView.qml index 5b98007bc..1625b4333 100644 --- a/src/mainview/MainView.qml +++ b/src/mainview/MainView.qml @@ -434,7 +434,7 @@ Window { callStackView.updateCorrspondingUI() if (callStackViewShouldShow) { - if (callStateStr == "Talking" || callStateStr == "Hold") { + if (callState === Call.Status.IN_PROGRESS || callState === Call.Status.PAUSED) { ClientWrapper.utilsAdaptor.setCurrentCall( ClientWrapper.utilsAdaptor.getCurrAccId(), currentUID) diff --git a/src/mainview/components/CallStackView.qml b/src/mainview/components/CallStackView.qml index 1f46174b3..c4901c69f 100644 --- a/src/mainview/components/CallStackView.qml +++ b/src/mainview/components/CallStackView.qml @@ -93,7 +93,7 @@ Rectangle { callStackMainView.pop(itemToFind, StackView.Immediate) } if (currentCallStatus) - outgoingCallPage.callStatusPresentation = currentCallStatus + outgoingCallPage.callStatus = currentCallStatus } function showVideoCallPage(callId) { @@ -158,7 +158,7 @@ Rectangle { function onCallStatusChanged(status, accountId, convUid) { if (responsibleConvUid === convUid && responsibleAccountId === accountId) { - outgoingCallPage.callStatusPresentation = status + outgoingCallPage.callStatus = status } } diff --git a/src/mainview/components/ConversationSmartListView.qml b/src/mainview/components/ConversationSmartListView.qml index eb7cd0d30..65177c190 100644 --- a/src/mainview/components/ConversationSmartListView.qml +++ b/src/mainview/components/ConversationSmartListView.qml @@ -24,7 +24,7 @@ import net.jami.Models 1.0 ListView { id: conversationSmartListView - signal needToAccessMessageWebView(string currentUserDisplayName, string currentUserAlias, string currentUID, bool callStackViewShouldShow, bool isAudioOnly, string callStateStr) + signal needToAccessMessageWebView(string currentUserDisplayName, string currentUserAlias, string currentUID, bool callStackViewShouldShow, bool isAudioOnly, int callState) signal needToSelectItems(string conversationUid) signal needToDeselectItems signal needToBackToWelcomePage diff --git a/src/mainview/components/ConversationSmartListViewItemDelegate.qml b/src/mainview/components/ConversationSmartListViewItemDelegate.qml index 74d07dbc8..3538200a1 100644 --- a/src/mainview/components/ConversationSmartListViewItemDelegate.qml +++ b/src/mainview/components/ConversationSmartListViewItemDelegate.qml @@ -65,7 +65,7 @@ ItemDelegate { conversationSmartListView.needToAccessMessageWebView( DisplayID == DisplayName ? "" : DisplayID, DisplayName, UID, CallStackViewShouldShow, - IsAudioOnly, CallStateStr) + IsAudioOnly, CallState) } } } @@ -137,7 +137,7 @@ ItemDelegate { elide: Text.ElideRight elideWidth: LastInteractionDate ? (smartListItemDelegate.width - lastInteractionPreferredWidth - conversationSmartListUserImage.width-32) : smartListItemDelegate.width - lastInteractionPreferredWidth - text: InCall ? CallStateStr : (Draft ? Draft : LastInteraction) + text: InCall ? ClientWrapper.utilsAdaptor.getCallStatusStr(CallState) : (Draft ? Draft : LastInteraction) } font.hintingPreference: Font.PreferNoHinting diff --git a/src/mainview/components/OutgoingCallPage.qml b/src/mainview/components/OutgoingCallPage.qml index c3a4fd51d..b0b2aa863 100644 --- a/src/mainview/components/OutgoingCallPage.qml +++ b/src/mainview/components/OutgoingCallPage.qml @@ -28,7 +28,7 @@ Rectangle { id: outgoingCallPageRect property int buttonPreferredSize: 50 - property string callStatusPresentation: "outgoing" + property int callStatus: 0 property string contactImgSource: "" property string bestName: "Best Name" property string bestId: "Best Id" @@ -160,7 +160,7 @@ Rectangle { horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter - text: callStatusPresentation + "..." + text: ClientWrapper.utilsAdaptor.getCallStatusStr(callStatus) + "..." color: Qt.lighter("white", 1.5) } } diff --git a/src/mainview/components/SidePanel.qml b/src/mainview/components/SidePanel.qml index c861e980b..350244e4d 100644 --- a/src/mainview/components/SidePanel.qml +++ b/src/mainview/components/SidePanel.qml @@ -31,7 +31,7 @@ Rectangle { property int pendingRequestCount: 0 property int totalUnreadMessagesCount: 0 - signal conversationSmartListNeedToAccessMessageWebView(string currentUserDisplayName, string currentUserAlias, string currentUID, bool callStackViewShouldShow, bool isAudioOnly, string callStateStr) + signal conversationSmartListNeedToAccessMessageWebView(string currentUserDisplayName, string currentUserAlias, string currentUID, bool callStackViewShouldShow, bool isAudioOnly, string callState) signal accountComboBoxNeedToShowWelcomePage() signal conversationSmartListViewNeedToShowWelcomePage signal needToUpdateConversationForAddedContact @@ -87,6 +87,7 @@ Rectangle { function refreshAccountComboBox(index = -1) { + /* * To make sure that the ui is refreshed for accountComboBox. * Note: when index in -1, it means to maintain the @@ -242,7 +243,7 @@ Rectangle { sidePanelRect.conversationSmartListNeedToAccessMessageWebView( currentUserDisplayName, currentUserAlias, currentUID, callStackViewShouldShow, - isAudioOnly, callStateStr) + isAudioOnly, callState) } onNeedToGrabFocus: { diff --git a/src/smartlistmodel.cpp b/src/smartlistmodel.cpp index c3957cbb1..db76a8748 100644 --- a/src/smartlistmodel.cpp +++ b/src/smartlistmodel.cpp @@ -130,6 +130,7 @@ SmartListModel::data(const QModelIndex &index, int role) const if (role == Role::AccountId) { return QVariant(itemAccId); } + auto &itemAccountInfo = LRCInstance::accountModel().getAccountInfo(itemAccId); item = itemAccountInfo.conversationModel->getConversationForUID(itemConvUid); return getConversationItemData(item, itemAccountInfo, role); @@ -160,7 +161,7 @@ SmartListModel::roleNames() const roles[InCall] = "InCall"; roles[IsAudioOnly] = "IsAudioOnly"; roles[CallStackViewShouldShow] = "CallStackViewShouldShow"; - roles[CallStateStr] = "CallStateStr"; + roles[CallState] = "CallState"; roles[SectionName] = "SectionName"; roles[AccountId] = "AccountId"; roles[Draft] = "Draft"; @@ -340,14 +341,13 @@ SmartListModel::getConversationItemData(const conversation::Info &item, } return QVariant(false); } - case Role::CallStateStr: { + case Role::CallState: { auto* convModel = LRCInstance::getCurrentConversationModel(); const auto convInfo = convModel->getConversationForUID(item.uid); if (!convInfo.uid.isEmpty()) { auto* call = LRCInstance::getCallInfoForConversation(convInfo); if (call) { - auto statusString = call::to_string(call->status); - return QVariant(statusString); + return QVariant(static_cast<int>(call->status)); } } return QVariant(); diff --git a/src/smartlistmodel.h b/src/smartlistmodel.h index bdf359241..3128d706d 100644 --- a/src/smartlistmodel.h +++ b/src/smartlistmodel.h @@ -55,7 +55,7 @@ public: InCall, IsAudioOnly, CallStackViewShouldShow, - CallStateStr, + CallState, SectionName, AccountId, Draft diff --git a/src/utils.cpp b/src/utils.cpp index a43cf1bbd..2723ff39d 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -1046,6 +1046,14 @@ UtilsAdapter::getCallId(const QString &accountId, const QString &convUid) return call->id; } +const QString +UtilsAdapter::getCallStatusStr(int statusInt) +{ + const auto status = static_cast<lrc::api::call::Status>(statusInt); + return lrc::api::call::to_string(status); +} + + // returns true if name is valid registered name bool UtilsAdapter::validateRegNameForm(const QString ®Name) diff --git a/src/utils.h b/src/utils.h index f97d0d61c..4ffc5f283 100644 --- a/src/utils.h +++ b/src/utils.h @@ -504,6 +504,7 @@ public: Q_INVOKABLE void stopPreviewing(); Q_INVOKABLE bool hasVideoCall(); Q_INVOKABLE const QString getCallId(const QString &accountId, const QString &convUid); + Q_INVOKABLE const QString getCallStatusStr(int statusInt); Q_INVOKABLE QString getStringUTF8(QString string); Q_INVOKABLE bool validateRegNameForm(const QString ®Name); Q_INVOKABLE QString getRecordQualityString(int value); -- GitLab