fix #LINQT-1558 back button on login page without refreshing

This commit is contained in:
Gaelle Braud 2025-02-11 17:53:34 +01:00
parent 5144df7896
commit d68248e152
2 changed files with 30 additions and 10 deletions

View file

@ -64,8 +64,27 @@ void AccountList::setSelf(QSharedPointer<AccountList> 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<AccountCore>()) {
if (account->getRegistrationState() != LinphoneEnums::RegistrationState::Progress &&
account->getRegistrationState() != LinphoneEnums::RegistrationState::None) {
return true;
}
}
return false;
};
for (auto &account : getSharedList<AccountCore>()) {
disconnect(account.get(), &AccountCore::registrationStateChanged, this, nullptr);
}
resetData<AccountCore>(*accounts);
setHaveAccount(accounts->size() > 0);
for (auto &account : getSharedList<AccountCore>()) {
connect(account.get(), &AccountCore::registrationStateChanged, this,
[this, reallyHaveAccount] { setHaveAccount(reallyHaveAccount()); });
}
setHaveAccount(reallyHaveAccount());
setDefaultAccount(defaultAccountCore);
if (isInitialization) setInitialized(true);
delete accounts;

View file

@ -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 {