1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 02:36:34 +01:00

[PasswordManager] Correctly switch password backends.

This commit is contained in:
nowrep 2013-05-18 13:29:11 +02:00
parent 0fe79f3f71
commit 90a4200981
3 changed files with 16 additions and 1 deletions

View File

@ -126,6 +126,17 @@ PasswordBackend* PasswordManager::activeBackend() const
return m_backend;
}
void PasswordManager::switchBackend(PasswordBackend* backend)
{
if (!backend) {
return;
}
m_backend->setActive(false);
m_backend = backend;
m_backend->setActive(true);
}
bool PasswordManager::registerBackend(const QString &id, PasswordBackend* backend)
{
if (m_backends.contains(id)) {

View File

@ -67,6 +67,7 @@ public:
QHash<QString, PasswordBackend*> availableBackends() const;
PasswordBackend* activeBackend() const;
void switchBackend(PasswordBackend* backend);
bool registerBackend(const QString &id, PasswordBackend* backend);
void unregisterBackend(PasswordBackend* backend);

View File

@ -117,17 +117,20 @@ void AutoFillManager::changePasswordBackend()
Settings settings;
settings.beginGroup("PasswordManager");
PasswordBackend* backend = 0;
foreach (const QString &key, backends.keys()) {
if (backends[key]->name() == item) {
backend = backends[key];
settings.setValue("Backend", key);
break;
}
}
settings.endGroup();
mApp->autoFill()->passwordManager()->switchBackend(backend);
}
mApp->autoFill()->passwordManager()->loadSettings();
QTimer::singleShot(0, this, SLOT(loadPasswords()));
}