fix handle app activity for macos #LINQT-2295
This commit is contained in:
parent
b19420afa9
commit
6890362c41
2 changed files with 19 additions and 16 deletions
|
|
@ -1099,28 +1099,30 @@ bool App::notify(QObject *receiver, QEvent *event) {
|
||||||
return done;
|
return done;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void App::handleAccountActivity(QSharedPointer<AccountCore> accountCore) {
|
||||||
|
if (!accountCore) return;
|
||||||
|
auto accountPresence = accountCore->getPresence();
|
||||||
|
if ((mMainWindow && mMainWindow->isActive() || (mCallsWindow && mCallsWindow->isActive())) &&
|
||||||
|
accountPresence == LinphoneEnums::Presence::Away) {
|
||||||
|
accountCore->lSetPresence(LinphoneEnums::Presence::Online, false);
|
||||||
|
} else if (((!mMainWindow || !mMainWindow->isActive() || !mMainWindow->isVisible()) &&
|
||||||
|
(!mCallsWindow || !mCallsWindow->isActive() || !mCallsWindow->isVisible())) &&
|
||||||
|
accountPresence == LinphoneEnums::Presence::Online) {
|
||||||
|
accountCore->lSetPresence(LinphoneEnums::Presence::Away, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void App::handleAppActivity() {
|
void App::handleAppActivity() {
|
||||||
auto handle = [this](QSharedPointer<AccountCore> accountCore) {
|
|
||||||
if (!accountCore) return;
|
|
||||||
auto accountPresence = accountCore->getPresence();
|
|
||||||
if ((mMainWindow && mMainWindow->isActive() || (mCallsWindow && mCallsWindow->isActive())) &&
|
|
||||||
accountPresence == LinphoneEnums::Presence::Away)
|
|
||||||
accountCore->lSetPresence(LinphoneEnums::Presence::Online, false);
|
|
||||||
else if (((!mMainWindow || !mMainWindow->isActive() || !mMainWindow->isVisible()) &&
|
|
||||||
(!mCallsWindow || !mCallsWindow->isActive() || !mCallsWindow->isVisible())) &&
|
|
||||||
accountPresence == LinphoneEnums::Presence::Online)
|
|
||||||
accountCore->lSetPresence(LinphoneEnums::Presence::Away, false);
|
|
||||||
};
|
|
||||||
if (mAccountList) {
|
if (mAccountList) {
|
||||||
for (auto &account : mAccountList->getSharedList<AccountCore>())
|
for (auto &account : mAccountList->getSharedList<AccountCore>())
|
||||||
handle(account);
|
handleAccountActivity(account);
|
||||||
} else {
|
} else {
|
||||||
connect(
|
connect(
|
||||||
this, &App::accountsChanged, this,
|
this, &App::accountsChanged, this,
|
||||||
[this, &handle] {
|
[this] {
|
||||||
if (mAccountList) {
|
if (mAccountList) {
|
||||||
for (auto &account : mAccountList->getSharedList<AccountCore>())
|
for (auto &account : mAccountList->getSharedList<AccountCore>())
|
||||||
handle(account);
|
handleAccountActivity(account);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Qt::SingleShotConnection);
|
Qt::SingleShotConnection);
|
||||||
|
|
@ -1441,12 +1443,12 @@ bool App::event(QEvent *event) {
|
||||||
} else if (event->type() == QEvent::ApplicationActivate) {
|
} else if (event->type() == QEvent::ApplicationActivate) {
|
||||||
for (int i = 0; i < getAccountList()->rowCount(); ++i) {
|
for (int i = 0; i < getAccountList()->rowCount(); ++i) {
|
||||||
auto accountCore = getAccountList()->getAt<AccountCore>(i);
|
auto accountCore = getAccountList()->getAt<AccountCore>(i);
|
||||||
emit accountCore->lSetPresence(LinphoneEnums::Presence::Online, false, false);
|
handleAccountActivity(accountCore);
|
||||||
}
|
}
|
||||||
} else if (event->type() == QEvent::ApplicationDeactivate) {
|
} else if (event->type() == QEvent::ApplicationDeactivate) {
|
||||||
for (int i = 0; i < getAccountList()->rowCount(); ++i) {
|
for (int i = 0; i < getAccountList()->rowCount(); ++i) {
|
||||||
auto accountCore = getAccountList()->getAt<AccountCore>(i);
|
auto accountCore = getAccountList()->getAt<AccountCore>(i);
|
||||||
emit accountCore->lSetPresence(LinphoneEnums::Presence::Away, false, false);
|
handleAccountActivity(accountCore);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -145,6 +145,7 @@ public:
|
||||||
void setCoreStarted(bool started);
|
void setCoreStarted(bool started);
|
||||||
|
|
||||||
QQuickWindow *getCallsWindow();
|
QQuickWindow *getCallsWindow();
|
||||||
|
void handleAccountActivity(QSharedPointer<AccountCore> accountCore);
|
||||||
Q_INVOKABLE void handleAppActivity();
|
Q_INVOKABLE void handleAppActivity();
|
||||||
QQuickWindow *getOrCreateCallsWindow(QVariant callGui = QVariant());
|
QQuickWindow *getOrCreateCallsWindow(QVariant callGui = QVariant());
|
||||||
void setCallsWindowProperty(const char *id, QVariant property);
|
void setCallsWindowProperty(const char *id, QVariant property);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue