diff --git a/src/lib/autofill/passwordmanager.cpp b/src/lib/autofill/passwordmanager.cpp index be548ecee..3a1198f55 100644 --- a/src/lib/autofill/passwordmanager.cpp +++ b/src/lib/autofill/passwordmanager.cpp @@ -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)) { diff --git a/src/lib/autofill/passwordmanager.h b/src/lib/autofill/passwordmanager.h index e8deab72d..d11993aa2 100644 --- a/src/lib/autofill/passwordmanager.h +++ b/src/lib/autofill/passwordmanager.h @@ -67,6 +67,7 @@ public: QHash availableBackends() const; PasswordBackend* activeBackend() const; + void switchBackend(PasswordBackend* backend); bool registerBackend(const QString &id, PasswordBackend* backend); void unregisterBackend(PasswordBackend* backend); diff --git a/src/lib/preferences/autofillmanager.cpp b/src/lib/preferences/autofillmanager.cpp index ef285b213..2dee6b40d 100644 --- a/src/lib/preferences/autofillmanager.cpp +++ b/src/lib/preferences/autofillmanager.cpp @@ -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())); }