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

[PasswordManager] Backends can now have its own options dialog.

This commit is contained in:
nowrep 2013-05-18 19:50:12 +02:00
parent 90a4200981
commit ffc47909a8
5 changed files with 45 additions and 4 deletions

View File

@ -31,3 +31,13 @@ bool PasswordBackend::isActive() const
{
return m_active;
}
bool PasswordBackend::hasSettings() const
{
return false;
}
void PasswordBackend::showSettings(QWidget* parent)
{
Q_UNUSED(parent)
}

View File

@ -20,6 +20,8 @@
#include "passwordmanager.h"
class QWidget;
class PasswordBackend
{
public:
@ -41,6 +43,9 @@ public:
virtual void setActive(bool active);
bool isActive() const;
virtual bool hasSettings() const;
virtual void showSettings(QWidget* parent);
private:
bool m_active;
};

View File

@ -34,6 +34,7 @@
AutoFillManager::AutoFillManager(QWidget* parent)
: QWidget(parent)
, ui(new Ui::AutoFillManager)
, m_passwordManager(mApp->autoFill()->passwordManager())
, m_passwordsShown(false)
{
ui->setupUi(this);
@ -44,6 +45,7 @@ AutoFillManager::AutoFillManager(QWidget* parent)
connect(ui->showPasswords, SIGNAL(clicked()), this, SLOT(showPasswords()));
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(ui->removeExcept, SIGNAL(clicked()), this, SLOT(removeExcept()));
connect(ui->removeAllExcept, SIGNAL(clicked()), this, SLOT(removeAllExcept()));
@ -56,7 +58,8 @@ AutoFillManager::AutoFillManager(QWidget* parent)
ui->search->setPlaceholderText(tr("Search"));
// Password backends
ui->currentBackend->setText(QString("<b>%1</b>").arg(mApp->autoFill()->passwordManager()->activeBackend()->name()));
ui->currentBackend->setText(QString("<b>%1</b>").arg(m_passwordManager->activeBackend()->name()));
ui->backendOptions->setVisible(m_passwordManager->activeBackend()->hasSettings());
// Load passwords
QTimer::singleShot(0, this, SLOT(loadPasswords()));
@ -98,13 +101,13 @@ void AutoFillManager::loadPasswords()
void AutoFillManager::changePasswordBackend()
{
QHash<QString, PasswordBackend*> backends = mApp->autoFill()->passwordManager()->availableBackends();
QHash<QString, PasswordBackend*> backends = m_passwordManager->availableBackends();
QStringList items;
int current = 0;
foreach (const QString &key, backends.keys()) {
if (backends[key] == mApp->autoFill()->passwordManager()->activeBackend()) {
if (backends[key] == m_passwordManager->activeBackend()) {
current = items.size();
}
@ -128,12 +131,24 @@ void AutoFillManager::changePasswordBackend()
settings.endGroup();
mApp->autoFill()->passwordManager()->switchBackend(backend);
if (backend) {
m_passwordManager->switchBackend(backend);
ui->backendOptions->setVisible(backend);
}
}
QTimer::singleShot(0, this, SLOT(loadPasswords()));
}
void AutoFillManager::showBackendOptions()
{
PasswordBackend* backend = m_passwordManager->activeBackend();
if (backend->hasSettings()) {
backend->showSettings(this);
}
}
void AutoFillManager::showPasswords()
{
if (m_passwordsShown) {

View File

@ -22,6 +22,8 @@
#include "qz_namespace.h"
class PasswordManager;
namespace Ui
{
class AutoFillManager;
@ -40,6 +42,7 @@ public:
private slots:
void loadPasswords();
void changePasswordBackend();
void showBackendOptions();
void removePass();
void removeAllPass();
@ -55,6 +58,7 @@ private slots:
private:
Ui::AutoFillManager* ui;
PasswordManager* m_passwordManager;
bool m_passwordsShown;
};

View File

@ -36,6 +36,13 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="backendOptions">
<property name="text">
<string>Backend options</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">