fix #LINQT-1558 back button on login page without refreshing
This commit is contained in:
parent
5144df7896
commit
d68248e152
2 changed files with 30 additions and 10 deletions
|
|
@ -64,8 +64,27 @@ void AccountList::setSelf(QSharedPointer<AccountList> me) {
|
||||||
}
|
}
|
||||||
mModelConnection->invokeToCore([this, accounts, defaultAccountCore, isInitialization]() {
|
mModelConnection->invokeToCore([this, accounts, defaultAccountCore, isInitialization]() {
|
||||||
mustBeInMainThread(getClassName());
|
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);
|
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);
|
setDefaultAccount(defaultAccountCore);
|
||||||
if (isInitialization) setInitialized(true);
|
if (isInitialization) setInitialized(true);
|
||||||
delete accounts;
|
delete accounts;
|
||||||
|
|
|
||||||
|
|
@ -112,10 +112,13 @@ AbstractWindow {
|
||||||
active: AppCpp.coreStarted
|
active: AppCpp.coreStarted
|
||||||
sourceComponent: AccountProxy {
|
sourceComponent: AccountProxy {
|
||||||
sourceModel: AppCpp.accounts
|
sourceModel: AppCpp.accounts
|
||||||
onInitializedChanged: {
|
onInitializedChanged: if (isInitialized) {
|
||||||
mainWindow.accountProxy = this
|
mainWindow.accountProxy = this
|
||||||
mainWindow.initStackViewItem()
|
mainWindow.initStackViewItem()
|
||||||
}
|
}
|
||||||
|
onHaveAccountChanged: {
|
||||||
|
if (isInitialized) mainWindow.initStackViewItem()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -123,6 +126,10 @@ AbstractWindow {
|
||||||
id: mainWindowStackView
|
id: mainWindowStackView
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
initialItem: splashScreen
|
initialItem: splashScreen
|
||||||
|
Component.onCompleted: {
|
||||||
|
clear()
|
||||||
|
push(splashScreen)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Component {
|
Component {
|
||||||
id: splashScreen
|
id: splashScreen
|
||||||
|
|
@ -151,14 +158,10 @@ AbstractWindow {
|
||||||
id: loginPage
|
id: loginPage
|
||||||
LoginPage {
|
LoginPage {
|
||||||
objectName: "loginPage"
|
objectName: "loginPage"
|
||||||
showBackButton: false
|
|
||||||
onGoBack: openMainPage()
|
onGoBack: openMainPage()
|
||||||
onUseSIPButtonClicked: mainWindowStackView.push(sipLoginPage)
|
onUseSIPButtonClicked: mainWindowStackView.push(sipLoginPage)
|
||||||
onGoToRegister: mainWindowStackView.replace(registerPage)
|
onGoToRegister: mainWindowStackView.replace(registerPage)
|
||||||
Component.onCompleted: if (accountProxy?.haveAccount) showBackButton = true
|
showBackButton: accountProxy?.haveAccount
|
||||||
StackView.onActivated:{
|
|
||||||
if (accountProxy?.haveAccount) showBackButton = true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Component {
|
Component {
|
||||||
|
|
@ -172,9 +175,7 @@ AbstractWindow {
|
||||||
mainWindowStackView.pop()
|
mainWindowStackView.pop()
|
||||||
}
|
}
|
||||||
onGoToRegister: mainWindowStackView.replace(registerPage)
|
onGoToRegister: mainWindowStackView.replace(registerPage)
|
||||||
StackView.onActivated:{
|
showBackButton: !SettingsCpp.assistantGoDirectlyToThirdPartySipAccountLogin || accountProxy?.haveAccount
|
||||||
if (!SettingsCpp.assistantGoDirectlyToThirdPartySipAccountLogin || accountProxy?.haveAccount) showBackButton = true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Component {
|
Component {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue