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:
parent
90a4200981
commit
ffc47909a8
@ -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)
|
||||
}
|
||||
|
@ -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;
|
||||
};
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
};
|
||||
|
||||
|
@ -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">
|
||||
|
Loading…
Reference in New Issue
Block a user