1
mirror of https://invent.kde.org/network/falkon.git synced 2024-11-11 09:32:12 +01:00

[PasswordManager] Moved saving selected backend to switchBackend().

-Also added PasswordManager::passwordBackendChanged() signal.
-Also some other options moved to AutoFillManager::currentPasswordBackendChanged()
This commit is contained in:
S. Razi Alavizadeh 2013-06-08 17:28:36 +04:30
parent aaf082a332
commit 102d90b77b
4 changed files with 26 additions and 13 deletions

View File

@ -131,8 +131,10 @@ PasswordBackend* PasswordManager::activeBackend()
return m_backend;
}
void PasswordManager::switchBackend(PasswordBackend* backend)
void PasswordManager::switchBackend(const QString &backendID)
{
PasswordBackend* backend = m_backends.value(backendID);
if (!backend) {
return;
}
@ -140,6 +142,13 @@ void PasswordManager::switchBackend(PasswordBackend* backend)
m_backend->setActive(false);
m_backend = backend;
m_backend->setActive(true);
Settings settings;
settings.beginGroup("PasswordManager");
settings.setValue("Backend", backendID);
settings.endGroup();
emit passwordBackendChanged();
}
bool PasswordManager::registerBackend(const QString &id, PasswordBackend* backend)

View File

@ -74,7 +74,7 @@ public:
QHash<QString, PasswordBackend*> availableBackends();
PasswordBackend* activeBackend();
void switchBackend(PasswordBackend* backend);
void switchBackend(const QString &backendID);
bool registerBackend(const QString &id, PasswordBackend* backend);
void unregisterBackend(PasswordBackend* backend);
@ -90,6 +90,9 @@ private:
PasswordBackend* m_backend;
DatabasePasswordBackend* m_databaseBackend;
QHash<QString, PasswordBackend*> m_backends;
signals:
void passwordBackendChanged();
};
// Hint to QVector to use std::realloc on item moving

View File

@ -46,6 +46,7 @@ AutoFillManager::AutoFillManager(QWidget* parent)
connect(ui->search, SIGNAL(textChanged(QString)), ui->treePass, SLOT(filterString(QString)));
connect(ui->changeBackend, SIGNAL(clicked()), this, SLOT(changePasswordBackend()));
connect(ui->backendOptions, SIGNAL(clicked()), this, SLOT(showBackendOptions()));
connect(m_passwordManager, SIGNAL(passwordBackendChanged()), this, SLOT(currentPasswordBackendChanged()));
connect(ui->removeExcept, SIGNAL(clicked()), this, SLOT(removeExcept()));
connect(ui->removeAllExcept, SIGNAL(clicked()), this, SLOT(removeAllExcept()));
@ -119,9 +120,6 @@ void AutoFillManager::changePasswordBackend()
// Switch backends
if (!item.isEmpty()) {
Settings settings;
settings.beginGroup("PasswordManager");
PasswordBackend* backend = 0;
QHashIterator<QString, PasswordBackend*> i(backends);
@ -129,21 +127,14 @@ void AutoFillManager::changePasswordBackend()
i.next();
if (i.value()->name() == item) {
backend = i.value();
settings.setValue("Backend", i.key());
break;
}
}
settings.endGroup();
if (backend) {
m_passwordManager->switchBackend(backend);
ui->backendOptions->setVisible(backend->hasSettings());
ui->currentBackend->setText(QString("<b>%1</b>").arg(backend->name()));
m_passwordManager->switchBackend(backends.key(backend));
}
}
QTimer::singleShot(0, this, SLOT(loadPasswords()));
}
void AutoFillManager::showBackendOptions()
@ -335,6 +326,14 @@ void AutoFillManager::slotExportPasswords()
QApplication::restoreOverrideCursor();
}
void AutoFillManager::currentPasswordBackendChanged()
{
ui->currentBackend->setText(QString("<b>%1</b>").arg(m_passwordManager->activeBackend()->name()));
ui->backendOptions->setVisible(m_passwordManager->activeBackend()->hasSettings());
QTimer::singleShot(0, this, SLOT(loadPasswords()));
}
AutoFillManager::~AutoFillManager()
{
delete ui;

View File

@ -58,6 +58,8 @@ private slots:
void slotImportPasswords();
void slotExportPasswords();
void currentPasswordBackendChanged();
private:
Ui::AutoFillManager* ui;