diff --git a/src/calladapter.cpp b/src/calladapter.cpp index b07246f6..6690934f 100644 --- a/src/calladapter.cpp +++ b/src/calladapter.cpp @@ -33,7 +33,6 @@ CallAdapter::CallAdapter(SystemTray* systemTray, LRCInstance* instance, QObject* parent) : QmlAdapterBase(instance, parent) - , oneSecondTimer_(new QTimer(this)) , systemTray_(systemTray) { accountId_ = lrcInstance_->getCurrentAccountId(); @@ -91,10 +90,6 @@ CallAdapter::onCallStatusChanged(const QString& accountId, const QString& callId { set_hasCall(lrcInstance_->hasActiveCall()); - // :/ one timer for all the call overlays - if (!hasCall_) - oneSecondTimer_->stop(); - #ifdef Q_OS_LINUX auto& accInfo = lrcInstance_->accountModel().getAccountInfo(accountId); auto& callModel = accInfo.callModel; @@ -437,13 +432,6 @@ CallAdapter::connectCallModel(const QString& accountId) { auto& accInfo = lrcInstance_->accountModel().getAccountInfo(accountId); - QObject::connect( - oneSecondTimer_, - &QTimer::timeout, - this, - [this] { setTime(accountId_, convUid_); }, - Qt::UniqueConnection); - connect( accInfo.callModel.get(), &lrc::api::NewCallModel::onParticipantsChanged, @@ -596,8 +584,6 @@ CallAdapter::sipInputPanelPlayDTMF(const QString& key) void CallAdapter::updateCallOverlay(const lrc::api::conversation::Info& convInfo) { - setTime(accountId_, convUid_); - oneSecondTimer_->start(1000); auto& accInfo = lrcInstance_->accountModel().getAccountInfo(accountId_); auto* call = lrcInstance_->getCallInfoForConversation(convInfo); @@ -952,19 +938,20 @@ CallAdapter::videoPauseThisCallToggle() Q_EMIT previewVisibilityNeedToChange(shouldShowPreview(false)); } -void -CallAdapter::setTime(const QString& accountId, const QString& convUid) +QString +CallAdapter::getCallDurationTime(const QString& accountId, const QString& convUid) { const auto callId = lrcInstance_->getCallIdForConversationUid(convUid, accountId); if (callId.isEmpty() || !lrcInstance_->getCurrentCallModel()->hasCall(callId)) { - return; + return QString(); } const auto callInfo = lrcInstance_->getCurrentCallModel()->getCall(callId); if (callInfo.status == lrc::api::call::Status::IN_PROGRESS || callInfo.status == lrc::api::call::Status::PAUSED) { - auto timeString = lrcInstance_->getCurrentCallModel()->getFormattedCallDuration(callId); - Q_EMIT updateTimeText(timeString); + return lrcInstance_->getCurrentCallModel()->getFormattedCallDuration(callId); } + + return QString(); } void diff --git a/src/calladapter.h b/src/calladapter.h index efb9ddcc..c110d974 100644 --- a/src/calladapter.h +++ b/src/calladapter.h @@ -77,6 +77,7 @@ public: Q_INVOKABLE void updateCall(const QString& convUid = {}, const QString& accountId = {}, bool forceCallOnly = false); + Q_INVOKABLE QString getCallDurationTime(const QString& accountId, const QString& convUid); Q_SIGNALS: void callStatusChanged(int index, const QString& accountId, const QString& convUid); @@ -115,8 +116,6 @@ private: // For Call Overlay void updateCallOverlay(const lrc::api::conversation::Info& convInfo); - void setTime(const QString& accountId, const QString& convUid); - QTimer* oneSecondTimer_; ScreenSaver screenSaver; void preventScreenSaver(bool state); diff --git a/src/mainview/components/AudioCallPage.qml b/src/mainview/components/AudioCallPage.qml index 2cbc0b14..670aaf13 100644 --- a/src/mainview/components/AudioCallPage.qml +++ b/src/mainview/components/AudioCallPage.qml @@ -113,11 +113,6 @@ Rectangle { Connections { target: CallAdapter - function onUpdateTimeText(time) { - audioCallOverlay.timeText = time - audioCallOverlay.setRecording(CallAdapter.isRecordingThisCall()) - } - function onUpdateOverlay(isPaused, isAudioOnly, isAudioMuted, isVideoMuted, isRecording, isSIP, isConferenceCall, bestName) { audioCallOverlay.showOnHoldImage(isPaused) audioCallPageRectCentralRect.visible = !isPaused diff --git a/src/mainview/components/CallOverlay.qml b/src/mainview/components/CallOverlay.qml index 1e03f290..2fbfa43a 100644 --- a/src/mainview/components/CallOverlay.qml +++ b/src/mainview/components/CallOverlay.qml @@ -34,7 +34,7 @@ import "../js/pluginhandlerpickercreation.js" as PluginHandlerPickerCreation import "../../commoncomponents" Rectangle { - id: callOverlayRect + id: root property string timeText: "00:00" property string remoteRecordingLabel: "" @@ -216,8 +216,8 @@ Rectangle { SipInputPanel { id: sipInputPanel - x: callOverlayRect.width / 2 - sipInputPanel.width / 2 - y: callOverlayRect.height / 2 - sipInputPanel.height / 2 + x: root.width / 2 - sipInputPanel.width / 2 + y: root.height / 2 - sipInputPanel.height / 2 } // Timer to decide when overlay fade out. @@ -227,20 +227,25 @@ Rectangle { onTriggered: { if (overlayUpperPartRect.state !== 'freezed') { overlayUpperPartRect.state = 'freezed' - resetRecordingLabelTimer.restart() + resetLabelsTimer.restart() } if (callOverlayButtonGroup.state !== 'freezed') { callOverlayButtonGroup.state = 'freezed' - resetRecordingLabelTimer.restart() + resetLabelsTimer.restart() } } } - // Timer to reset recording label text + // Timer to reset recording label and call duration time Timer { - id: resetRecordingLabelTimer + id: resetLabelsTimer + interval: 1000 + running: root.visible + repeat: true onTriggered: { + timeText = CallAdapter.getCallDurationTime(LRCInstance.currentAccountId, + LRCInstance.selectedConvUid) if (callOverlayButtonGroup.state === 'freezed' && !callViewContextMenu.peerIsRecording) remoteRecordingLabel = "" @@ -250,9 +255,9 @@ Rectangle { Rectangle { id: overlayUpperPartRect - anchors.top: callOverlayRect.top + anchors.top: root.top - width: callOverlayRect.width + width: root.width height: 50 opacity: 0 @@ -370,8 +375,8 @@ Rectangle { ResponsiveImage { id: onHoldImage - anchors.verticalCenter: callOverlayRect.verticalCenter - anchors.horizontalCenter: callOverlayRect.horizontalCenter + anchors.verticalCenter: root.verticalCenter + anchors.horizontalCenter: root.horizontalCenter width: 200 height: 200 @@ -384,23 +389,23 @@ Rectangle { CallOverlayButtonGroup { id: callOverlayButtonGroup - anchors.bottom: callOverlayRect.bottom + anchors.bottom: root.bottom anchors.bottomMargin: 10 - anchors.horizontalCenter: callOverlayRect.horizontalCenter + anchors.horizontalCenter: root.horizontalCenter height: 56 - width: callOverlayRect.width + width: root.width opacity: 0 onChatButtonClicked: { - callOverlayRect.overlayChatButtonClicked() + root.overlayChatButtonClicked() } onAddToConferenceButtonClicked: { // Create contact picker - conference. ContactPickerCreation.createContactPickerObjects( ContactList.CONFERENCE, - callOverlayRect) + root) ContactPickerCreation.openContactPicker() } @@ -434,10 +439,10 @@ Rectangle { MouseArea { id: callOverlayButtonGroupLeftSideMouseArea - anchors.bottom: callOverlayRect.bottom - anchors.left: callOverlayRect.left + anchors.bottom: root.bottom + anchors.left: root.left - width: callOverlayRect.width / 6 + width: root.width / 6 height: 60 hoverEnabled: true @@ -456,10 +461,10 @@ Rectangle { MouseArea { id: callOverlayButtonGroupRightSideMouseArea - anchors.bottom: callOverlayRect.bottom - anchors.right: callOverlayRect.right + anchors.bottom: root.bottom + anchors.right: root.right - width: callOverlayRect.width / 6 + width: root.width / 6 height: 60 hoverEnabled: true @@ -478,10 +483,10 @@ Rectangle { MouseArea { id: callOverlayRectMouseArea - anchors.top: callOverlayRect.top + anchors.top: root.top - width: callOverlayRect.width - height: callOverlayRect.height + width: root.width + height: root.height hoverEnabled: true propagateComposedEvents: true @@ -518,13 +523,13 @@ Rectangle { // Create contact picker - sip transfer. ContactPickerCreation.createContactPickerObjects( ContactList.TRANSFER, - callOverlayRect) + root) ContactPickerCreation.openContactPicker() } onPluginItemClicked: { // Create plugin handler picker - PLUGINS - PluginHandlerPickerCreation.createPluginHandlerPickerObjects(callOverlayRect, true) + PluginHandlerPickerCreation.createPluginHandlerPickerObjects(root, true) PluginHandlerPickerCreation.openPluginHandlerPicker() } } diff --git a/src/mainview/components/VideoCallPage.qml b/src/mainview/components/VideoCallPage.qml index 3221cb9a..1f0a33b1 100644 --- a/src/mainview/components/VideoCallPage.qml +++ b/src/mainview/components/VideoCallPage.qml @@ -177,10 +177,6 @@ Rectangle { Connections { target: CallAdapter - function onUpdateTimeText(time) { - videoCallOverlay.timeText = time - } - function onUpdateOverlay(isPaused, isAudioOnly, isAudioMuted, isVideoMuted, isRecording, isSIP, isConferenceCall, bestName) { videoCallOverlay.showOnHoldImage(isPaused)