fix automatic presence when app focus changes #LINQT-2172

This commit is contained in:
Gaelle Braud 2025-12-02 11:31:18 +01:00
parent b2ae9213a2
commit c8428d6ade

View file

@ -1069,9 +1069,8 @@ bool App::notify(QObject *receiver, QEvent *event) {
} }
void App::handleAppActivity() { void App::handleAppActivity() {
auto handle = [this](AccountGui *currentAcount) { auto handle = [this](QSharedPointer<AccountCore> accountCore) {
auto accountCore = currentAcount->mCore; if (!accountCore) return;
Q_ASSERT(accountCore);
auto accountPresence = accountCore->getPresence(); auto accountPresence = accountCore->getPresence();
if ((mMainWindow && mMainWindow->isActive() || (mCallsWindow && mCallsWindow->isActive())) && if ((mMainWindow && mMainWindow->isActive() || (mCallsWindow && mCallsWindow->isActive())) &&
accountPresence == LinphoneEnums::Presence::Away) accountPresence == LinphoneEnums::Presence::Away)
@ -1081,19 +1080,19 @@ void App::handleAppActivity() {
accountCore->lSetPresence(LinphoneEnums::Presence::Away); accountCore->lSetPresence(LinphoneEnums::Presence::Away);
}; };
if (mAccountList) { if (mAccountList) {
if (mAccountList->getDefaultAccount()) { for (auto &account : mAccountList->getSharedList<AccountCore>())
handle(mAccountList->getDefaultAccount()); handle(account);
} else { } else {
connect( connect(
mAccountList.get(), &AccountList::defaultAccountChanged, this, this, &App::accountsChanged, this,
[this, handle] { [this, &handle] {
if (mAccountList->getDefaultAccount()) { if (mAccountList) {
handle(mAccountList->getDefaultAccount()); for (auto &account : mAccountList->getSharedList<AccountCore>())
handle(account);
} }
}, },
Qt::SingleShotConnection); Qt::SingleShotConnection);
} }
}
} }
QQuickWindow *App::getCallsWindow() { QQuickWindow *App::getCallsWindow() {