diff --git a/Linphone/core/account/AccountCore.cpp b/Linphone/core/account/AccountCore.cpp index feb202b01..baa52a071 100644 --- a/Linphone/core/account/AccountCore.cpp +++ b/Linphone/core/account/AccountCore.cpp @@ -172,6 +172,8 @@ void AccountCore::setSelf(QSharedPointer me) { mAccountModelConnection->makeConnectToModel(&AccountModel::limeServerUrlChanged, [this](QString value) { mAccountModelConnection->invokeToCore([this, value]() { onLimeServerUrlChanged(value); }); }); + mAccountModelConnection->makeConnectToModel( + &AccountModel::removed, [this]() { mAccountModelConnection->invokeToCore([this]() { emit removed(); }); }); // From GUI mAccountModelConnection->makeConnectToCore(&AccountCore::lSetPictureUri, [this](QString uri) { diff --git a/Linphone/core/account/AccountCore.hpp b/Linphone/core/account/AccountCore.hpp index 719e4a235..fd4fc74d8 100644 --- a/Linphone/core/account/AccountCore.hpp +++ b/Linphone/core/account/AccountCore.hpp @@ -165,6 +165,7 @@ signals: void conferenceFactoryAddressChanged(); void audioVideoConferenceFactoryAddressChanged(); void limeServerUrlChanged(); + void removed(); // Account requests void lSetPictureUri(QString pictureUri); diff --git a/Linphone/core/account/AccountList.cpp b/Linphone/core/account/AccountList.cpp index 4f2673b44..6eebccb76 100644 --- a/Linphone/core/account/AccountList.cpp +++ b/Linphone/core/account/AccountList.cpp @@ -84,17 +84,6 @@ void AccountList::setSelf(QSharedPointer me) { mModelConnection->makeConnectToModel(&CoreModel::accountAdded, &AccountList::lUpdate); lUpdate(); - - mModelConnection->makeConnectToModel( - &CoreModel::accountRemoved, - [this](const std::shared_ptr &core, const std::shared_ptr &account) { - mustBeInLinphoneThread(log().arg(Q_FUNC_INFO)); - bool wasLast = CoreModel::getInstance()->getCore()->getAccountList().size() == 0; - mModelConnection->invokeToCore([this, wasLast]() { - mustBeInMainThread(log().arg(Q_FUNC_INFO)); - emit accountRemoved(wasLast); - }); - }); } QSharedPointer AccountList::getDefaultAccountCore() const { diff --git a/Linphone/core/account/AccountList.hpp b/Linphone/core/account/AccountList.hpp index 2680bd806..9f5746c5a 100644 --- a/Linphone/core/account/AccountList.hpp +++ b/Linphone/core/account/AccountList.hpp @@ -54,7 +54,6 @@ signals: void lUpdate(); void haveAccountChanged(); void defaultAccountChanged(); - void accountRemoved(bool wasLast); private: bool mHaveAccount = false; diff --git a/Linphone/core/account/AccountProxy.cpp b/Linphone/core/account/AccountProxy.cpp index d977dc30a..f4972e9eb 100644 --- a/Linphone/core/account/AccountProxy.cpp +++ b/Linphone/core/account/AccountProxy.cpp @@ -27,7 +27,6 @@ AccountProxy::AccountProxy(QObject *parent) : SortFilterProxy(parent) { connect(mAccountList.get(), &AccountList::countChanged, this, &AccountProxy::resetDefaultAccount); connect(mAccountList.get(), &AccountList::defaultAccountChanged, this, &AccountProxy::resetDefaultAccount); connect(mAccountList.get(), &AccountList::haveAccountChanged, this, &AccountProxy::haveAccountChanged); - connect(mAccountList.get(), &AccountList::accountRemoved, this, &AccountProxy::accountRemoved); setSourceModel(mAccountList.get()); sort(0); } diff --git a/Linphone/core/account/AccountProxy.hpp b/Linphone/core/account/AccountProxy.hpp index 9ffe6126a..aaee2da68 100644 --- a/Linphone/core/account/AccountProxy.hpp +++ b/Linphone/core/account/AccountProxy.hpp @@ -53,7 +53,6 @@ signals: void filterTextChanged(); void defaultAccountChanged(); void haveAccountChanged(); - void accountRemoved(bool wasLast); protected: virtual bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override; diff --git a/Linphone/model/account/AccountModel.cpp b/Linphone/model/account/AccountModel.cpp index e9a8435eb..f1635ac3c 100644 --- a/Linphone/model/account/AccountModel.cpp +++ b/Linphone/model/account/AccountModel.cpp @@ -88,6 +88,7 @@ void AccountModel::setDefault() { void AccountModel::removeAccount() { CoreModel::getInstance()->getCore()->removeAccount(mMonitor); + emit removed(); } void AccountModel::resetMissedCallsCount() { diff --git a/Linphone/model/account/AccountModel.hpp b/Linphone/model/account/AccountModel.hpp index ab8ef4b74..c22a85c7d 100644 --- a/Linphone/model/account/AccountModel.hpp +++ b/Linphone/model/account/AccountModel.hpp @@ -92,6 +92,7 @@ signals: void conferenceFactoryAddressChanged(QString value); void audioVideoConferenceFactoryAddressChanged(QString value); void limeServerUrlChanged(QString value); + void removed(); private: DECLARE_ABSTRACT_OBJECT diff --git a/Linphone/view/App/Layout/MainLayout.qml b/Linphone/view/App/Layout/MainLayout.qml index 6296d19ea..107c128bf 100644 --- a/Linphone/view/App/Layout/MainLayout.qml +++ b/Linphone/view/App/Layout/MainLayout.qml @@ -23,6 +23,7 @@ Item { signal openNumPadRequest() signal displayContactRequested(string contactAddress) signal createContactRequested(string name, string address) + signal accountRemoved() function goToNewCall() { tabbar.currentIndex = 0 @@ -570,6 +571,7 @@ Item { id: accountSettingsPageComponent AccountSettingsPage { onGoBack: closeContextualMenuComponent() + onAccountRemoved: mainItem.accountRemoved() } } Component { diff --git a/Linphone/view/App/Main.qml b/Linphone/view/App/Main.qml index 49c49c01e..b023438f1 100644 --- a/Linphone/view/App/Main.qml +++ b/Linphone/view/App/Main.qml @@ -49,10 +49,6 @@ AppWindow { AccountProxy { id: accountProxy - onAccountRemoved:function (wasLast) { - if (wasLast) mainWindowStackView.replace(loginPage, StackView.Immediate) - else mainWindowStackView.replace(mainPage, StackView.Immediate) - } } StackView { id: mainWindowStackView @@ -155,6 +151,9 @@ AppWindow { id: mainPage MainLayout { onAddAccountRequest: mainWindowStackView.replace(loginPage) + onAccountRemoved: { + initStackViewItem() + } // StackView.onActivated: connectionSecured(0) // TODO : connect to cpp part when ready } } diff --git a/Linphone/view/Page/Main/AccountSettingsPage.qml b/Linphone/view/Page/Main/AccountSettingsPage.qml index 25e48af36..347f5d976 100644 --- a/Linphone/view/Page/Main/AccountSettingsPage.qml +++ b/Linphone/view/Page/Main/AccountSettingsPage.qml @@ -11,8 +11,13 @@ AbstractMasterDetailPage { titleText: qsTr("Mon compte") property AccountProxy accounts: AccountProxy{id: accountProxy} property AccountGui account: accountProxy.defaultAccount + signal accountRemoved() families: [ {title: qsTr("Général"), layout: "AccountSettingsGeneralLayout", model: account}, {title: qsTr("Paramètres de compte"), layout: "AccountSettingsParametersLayout", model: account} ] -} \ No newline at end of file + Connections { + target: account.core + onRemoved: accountRemoved() + } +}