diff --git a/Linphone/core/account/AccountList.cpp b/Linphone/core/account/AccountList.cpp index 374cc5656..7e2f40442 100644 --- a/Linphone/core/account/AccountList.cpp +++ b/Linphone/core/account/AccountList.cpp @@ -64,8 +64,27 @@ void AccountList::setSelf(QSharedPointer me) { } mModelConnection->invokeToCore([this, accounts, defaultAccountCore, isInitialization]() { mustBeInMainThread(getClassName()); + auto reallyHaveAccount = [this]() -> bool { + // When an account is trying to connect, we don't want to display the features + // provided for the accounts that really stays in the account list + // (for example the back button to return on the main page in the login page) + for (auto &account : getSharedList()) { + if (account->getRegistrationState() != LinphoneEnums::RegistrationState::Progress && + account->getRegistrationState() != LinphoneEnums::RegistrationState::None) { + return true; + } + } + return false; + }; + for (auto &account : getSharedList()) { + disconnect(account.get(), &AccountCore::registrationStateChanged, this, nullptr); + } resetData(*accounts); - setHaveAccount(accounts->size() > 0); + for (auto &account : getSharedList()) { + connect(account.get(), &AccountCore::registrationStateChanged, this, + [this, reallyHaveAccount] { setHaveAccount(reallyHaveAccount()); }); + } + setHaveAccount(reallyHaveAccount()); setDefaultAccount(defaultAccountCore); if (isInitialization) setInitialized(true); delete accounts; diff --git a/Linphone/view/Page/Window/Main/MainWindow.qml b/Linphone/view/Page/Window/Main/MainWindow.qml index 35eac4a09..e554ba9c6 100644 --- a/Linphone/view/Page/Window/Main/MainWindow.qml +++ b/Linphone/view/Page/Window/Main/MainWindow.qml @@ -112,10 +112,13 @@ AbstractWindow { active: AppCpp.coreStarted sourceComponent: AccountProxy { sourceModel: AppCpp.accounts - onInitializedChanged: { + onInitializedChanged: if (isInitialized) { mainWindow.accountProxy = this mainWindow.initStackViewItem() } + onHaveAccountChanged: { + if (isInitialized) mainWindow.initStackViewItem() + } } } @@ -123,6 +126,10 @@ AbstractWindow { id: mainWindowStackView anchors.fill: parent initialItem: splashScreen + Component.onCompleted: { + clear() + push(splashScreen) + } } Component { id: splashScreen @@ -151,14 +158,10 @@ AbstractWindow { id: loginPage LoginPage { objectName: "loginPage" - showBackButton: false onGoBack: openMainPage() onUseSIPButtonClicked: mainWindowStackView.push(sipLoginPage) onGoToRegister: mainWindowStackView.replace(registerPage) - Component.onCompleted: if (accountProxy?.haveAccount) showBackButton = true - StackView.onActivated:{ - if (accountProxy?.haveAccount) showBackButton = true - } + showBackButton: accountProxy?.haveAccount } } Component { @@ -172,9 +175,7 @@ AbstractWindow { mainWindowStackView.pop() } onGoToRegister: mainWindowStackView.replace(registerPage) - StackView.onActivated:{ - if (!SettingsCpp.assistantGoDirectlyToThirdPartySipAccountLogin || accountProxy?.haveAccount) showBackButton = true - } + showBackButton: !SettingsCpp.assistantGoDirectlyToThirdPartySipAccountLogin || accountProxy?.haveAccount } } Component {