Add account removed signal emission/handling in account core/model

This commit is contained in:
Christophe Deschamps 2024-08-31 07:54:17 +02:00
parent 08a822991b
commit 34f559b7d7
11 changed files with 16 additions and 19 deletions

View file

@ -172,6 +172,8 @@ void AccountCore::setSelf(QSharedPointer<AccountCore> 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) {

View file

@ -165,6 +165,7 @@ signals:
void conferenceFactoryAddressChanged();
void audioVideoConferenceFactoryAddressChanged();
void limeServerUrlChanged();
void removed();
// Account requests
void lSetPictureUri(QString pictureUri);

View file

@ -84,17 +84,6 @@ void AccountList::setSelf(QSharedPointer<AccountList> me) {
mModelConnection->makeConnectToModel(&CoreModel::accountAdded, &AccountList::lUpdate);
lUpdate();
mModelConnection->makeConnectToModel(
&CoreModel::accountRemoved,
[this](const std::shared_ptr<linphone::Core> &core, const std::shared_ptr<linphone::Account> &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<AccountCore> AccountList::getDefaultAccountCore() const {

View file

@ -54,7 +54,6 @@ signals:
void lUpdate();
void haveAccountChanged();
void defaultAccountChanged();
void accountRemoved(bool wasLast);
private:
bool mHaveAccount = false;

View file

@ -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);
}

View file

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

View file

@ -88,6 +88,7 @@ void AccountModel::setDefault() {
void AccountModel::removeAccount() {
CoreModel::getInstance()->getCore()->removeAccount(mMonitor);
emit removed();
}
void AccountModel::resetMissedCallsCount() {

View file

@ -92,6 +92,7 @@ signals:
void conferenceFactoryAddressChanged(QString value);
void audioVideoConferenceFactoryAddressChanged(QString value);
void limeServerUrlChanged(QString value);
void removed();
private:
DECLARE_ABSTRACT_OBJECT

View file

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

View file

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

View file

@ -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}
]
}
Connections {
target: account.core
onRemoved: accountRemoved()
}
}