try to fix persistent call window

This commit is contained in:
Gaelle Braud 2025-09-04 21:05:42 +02:00
parent bad52def4d
commit 251f404ced
3 changed files with 24 additions and 27 deletions

View file

@ -159,11 +159,7 @@ CallGui *CallList::getCurrentCall() const {
} }
void CallList::setCurrentCall(CallGui *callGui) { void CallList::setCurrentCall(CallGui *callGui) {
auto callCore = callGui ? callGui->mCore : nullptr; setCurrentCallCore(callGui ? callGui->mCore : nullptr);
if (mCurrentCall != callCore) {
mCurrentCall = callCore;
emit currentCallChanged();
}
} }
void CallList::setCurrentCallCore(QSharedPointer<CallCore> call) { void CallList::setCurrentCallCore(QSharedPointer<CallCore> call) {
@ -184,16 +180,12 @@ void CallList::setHaveCall(bool haveCall) {
} }
} }
QSharedPointer<CallCore> CallList::getNextCall() const { QSharedPointer<CallCore> CallList::getNextCall() {
QSharedPointer<CallCore> call;
auto currentCall = getCurrentCallCore(); auto currentCall = getCurrentCallCore();
for (auto it = mList.rbegin(); !call && it != mList.rend(); ++it) { for (auto &item : getSharedList<CallCore>()) {
if (*it != currentCall) { if (item != currentCall) return item;
call = it->objectCast<CallCore>();
} }
} return nullptr;
return call;
} }
void CallList::onStateChanged() { void CallList::onStateChanged() {
@ -202,21 +194,26 @@ void CallList::onStateChanged() {
case LinphoneEnums::CallState::StreamsRunning: case LinphoneEnums::CallState::StreamsRunning:
case LinphoneEnums::CallState::Resuming: { case LinphoneEnums::CallState::Resuming: {
auto sharedCall = get(call); auto sharedCall = get(call);
setCurrentCallCore(sharedCall.objectCast<CallCore>()); setCurrentCallCore(sharedCall ? sharedCall.objectCast<CallCore>() : nullptr);
break; break;
} }
case LinphoneEnums::CallState::Released: { case LinphoneEnums::CallState::Released: {
auto sharedCall = get(call); auto sharedCall = get(call);
if (sharedCall) {
auto currentCall = getCurrentCallCore(); auto currentCall = getCurrentCallCore();
sharedCall->disconnect(this);
// Update current call // Update current call
if (sharedCall == currentCall) { if (currentCall == sharedCall) {
auto nextCall = getNextCall();
if (nextCall) {
// Unpause the next call. The current call will change on resume. // Unpause the next call. The current call will change on resume.
// Assumption: All calls that are not the current are paused. // Assumption: All calls that are not the current are paused.
auto nextCall = getNextCall(); nextCall->lSetPaused(false);
if (nextCall) nextCall->lSetPaused(false); }
setCurrentCallCore(nextCall);
}
bool removed = remove(sharedCall);
} }
sharedCall->disconnect(this);
remove(sharedCall);
break; break;
} }
default: { default: {

View file

@ -45,7 +45,7 @@ public:
CallGui *getCurrentCall() const; // Used for Ui CallGui *getCurrentCall() const; // Used for Ui
QSharedPointer<CallCore> getCurrentCallCore() const; QSharedPointer<CallCore> getCurrentCallCore() const;
void setCurrentCall(CallGui* callGui); void setCurrentCall(CallGui *callGui);
void setCurrentCallCore(QSharedPointer<CallCore> call); void setCurrentCallCore(QSharedPointer<CallCore> call);
bool getHaveCall() const; bool getHaveCall() const;
@ -53,7 +53,7 @@ public:
// Get the next call after the current one. Used to switch the current call. // Get the next call after the current one. Used to switch the current call.
// At the moment, it select the last call in the list. // At the moment, it select the last call in the list.
QSharedPointer<CallCore> getNextCall() const; QSharedPointer<CallCore> getNextCall();
virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
signals: signals:

View file

@ -483,8 +483,8 @@ void AccountModel::setPresence(LinphoneEnums::Presence presence,
QString presenceNote) { QString presenceNote) {
mustBeInLinphoneThread(log().arg(Q_FUNC_INFO)); mustBeInLinphoneThread(log().arg(Q_FUNC_INFO));
lDebug() << log().arg("presence set request to: " + LinphoneEnums::toString(presence) + " user initiated? " + lDebug() << log().arg("presence set request to: " + LinphoneEnums::toString(presence) + " | user initiated? " +
(userInitiated ? "true" : "false") + " reset to auto? " + (resetToAuto ? "true" : "false")); (userInitiated ? "true" : "false") + " | reset to auto? " + (resetToAuto ? "true" : "false"));
auto core = CoreModel::getInstance()->getCore(); auto core = CoreModel::getInstance()->getCore();