mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-26 23:28:14 +03:00
Multi-Account: add possibility to delete an account
This commit is contained in:
parent
e02f1a222e
commit
1edd46b995
5 changed files with 38 additions and 1 deletions
|
@ -207,6 +207,16 @@ AccountState *AccountManager::addAccount(const AccountPtr& newAccount)
|
|||
return newAccountState.data();
|
||||
}
|
||||
|
||||
void AccountManager::deleteAccount(AccountState* account)
|
||||
{
|
||||
auto it = std::find(_accounts.begin(), _accounts.end(), account);
|
||||
if (it == _accounts.end()) { return; }
|
||||
auto copy = *it; // keep a reference to the shared pointer so it does not delete it just yet
|
||||
_accounts.erase(it);
|
||||
accountRemoved(account);
|
||||
}
|
||||
|
||||
|
||||
void AccountManager::shutdown()
|
||||
{
|
||||
auto accountsCopy = _accounts;
|
||||
|
|
|
@ -50,9 +50,16 @@ public:
|
|||
|
||||
/**
|
||||
* Return a list of all accounts.
|
||||
* (this is a list of QSharedPointer for internal reason, one should normaly not keep a copy of them)
|
||||
*/
|
||||
QList<AccountStatePtr> accounts() { return _accounts; }
|
||||
|
||||
/**
|
||||
* Delete the AccountState
|
||||
*/
|
||||
void deleteAccount(AccountState *account);
|
||||
|
||||
|
||||
private:
|
||||
void save(const AccountPtr& account, QSettings& settings);
|
||||
AccountPtr load(QSettings& settings);
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "account.h"
|
||||
#include "accountstate.h"
|
||||
#include "quotainfo.h"
|
||||
#include "accountmanager.h"
|
||||
#include "creds/abstractcredentials.h"
|
||||
|
||||
#include <math.h>
|
||||
|
@ -126,6 +127,8 @@ AccountSettings::AccountSettings(AccountState *accountState, QWidget *parent) :
|
|||
this, SLOT(slotUpdateQuota(qint64,qint64)));
|
||||
slotUpdateQuota(quotaInfo->lastQuotaTotalBytes(), quotaInfo->lastQuotaUsedBytes());
|
||||
|
||||
connect(ui->deleteButton, SIGNAL(clicked()) , this, SLOT(slotDeleteAccount()));
|
||||
|
||||
connect( ProgressDispatcher::instance(), SIGNAL(progressInfo(QString, ProgressInfo)),
|
||||
this, SLOT(slotSetProgress(QString, ProgressInfo)) );
|
||||
|
||||
|
@ -643,4 +646,20 @@ void AccountSettings::refreshSelectiveSyncStatus()
|
|||
}
|
||||
}
|
||||
|
||||
void AccountSettings::slotDeleteAccount()
|
||||
{
|
||||
int ret = QMessageBox::question( this, tr("Confirm Account Delete"),
|
||||
tr("<p>Do you really want to delete the account <i>%1</i>?</p>"
|
||||
"<p><b>Note:</b> This will not remove the files from your client.</p>")
|
||||
.arg(_accountState->account()->displayName()),
|
||||
QMessageBox::Yes|QMessageBox::No );
|
||||
|
||||
if( ret == QMessageBox::No ) {
|
||||
return;
|
||||
}
|
||||
|
||||
AccountManager::instance()->deleteAccount(_accountState);
|
||||
}
|
||||
|
||||
|
||||
} // namespace OCC
|
||||
|
|
|
@ -77,6 +77,7 @@ protected slots:
|
|||
void slotFolderWizardAccepted();
|
||||
void slotFolderWizardRejected();
|
||||
void slotHideProgress();
|
||||
void slotDeleteAccount();
|
||||
void refreshSelectiveSyncStatus();
|
||||
|
||||
private:
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<widget class="QPushButton" name="deleteButton">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
|
|
Loading…
Reference in a new issue