mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-10-01 01:26:01 -04:00
Settings UI integration.
This commit is contained in:
parent
f6fa6d6563
commit
af394ff65c
@ -32,7 +32,6 @@
|
||||
#include "gui/FileDialog.h"
|
||||
#include "gui/entry/EntryView.h"
|
||||
#include "gui/group/GroupView.h"
|
||||
#include "http/Service.h"
|
||||
|
||||
DatabaseManagerStruct::DatabaseManagerStruct()
|
||||
: dbWidget(Q_NULLPTR)
|
||||
@ -54,8 +53,6 @@ DatabaseTabWidget::DatabaseTabWidget(QWidget* parent)
|
||||
|
||||
connect(this, SIGNAL(tabCloseRequested(int)), SLOT(closeDatabase(int)));
|
||||
connect(autoType(), SIGNAL(globalShortcutTriggered()), SLOT(performGlobalAutoType()));
|
||||
|
||||
(new Service(this))->start();
|
||||
}
|
||||
|
||||
DatabaseTabWidget::~DatabaseTabWidget()
|
||||
|
@ -20,6 +20,7 @@
|
||||
|
||||
#include <QtGui/QCloseEvent>
|
||||
#include <QtGui/QShortcut>
|
||||
#include <QtGui/QLineEdit>
|
||||
|
||||
#include "autotype/AutoType.h"
|
||||
#include "core/Config.h"
|
||||
@ -32,6 +33,40 @@
|
||||
#include "gui/entry/EntryView.h"
|
||||
#include "gui/group/GroupView.h"
|
||||
|
||||
#include "http/Service.h"
|
||||
#include "http/HttpSettings.h"
|
||||
#include "http/OptionDialog.h"
|
||||
#include "gui/SettingsWidget.h"
|
||||
|
||||
class HttpPlugin: public ISettingsPage {
|
||||
public:
|
||||
HttpPlugin(DatabaseTabWidget * tabWidget): m_service(new Service(tabWidget)) {
|
||||
}
|
||||
virtual ~HttpPlugin() {
|
||||
}
|
||||
virtual QString name() {
|
||||
return QObject::tr("Http");
|
||||
}
|
||||
virtual QWidget * createWidget() {
|
||||
OptionDialog * dlg = new OptionDialog();
|
||||
QObject::connect(dlg, SIGNAL(removeSharedEncryptionKeys()), m_service.data(), SLOT(removeSharedEncryptionKeys()));
|
||||
QObject::connect(dlg, SIGNAL(removeStoredPermissions()), m_service.data(), SLOT(removeStoredPermissions()));
|
||||
return dlg;
|
||||
}
|
||||
virtual void loadSettings(QWidget * widget) {
|
||||
qobject_cast<OptionDialog*>(widget)->loadSettings();
|
||||
}
|
||||
virtual void saveSettings(QWidget * widget) {
|
||||
qobject_cast<OptionDialog*>(widget)->saveSettings();
|
||||
if (HttpSettings::isEnabled())
|
||||
m_service->start();
|
||||
else
|
||||
m_service->stop();
|
||||
}
|
||||
private:
|
||||
QScopedPointer<Service> m_service;
|
||||
};
|
||||
|
||||
const QString MainWindow::BaseWindowTitle = "KeePassX";
|
||||
|
||||
MainWindow::MainWindow()
|
||||
@ -39,6 +74,8 @@ MainWindow::MainWindow()
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
m_ui->settingsWidget->addSettingsPage(new HttpPlugin(m_ui->tabWidget));
|
||||
|
||||
setWindowIcon(filePath()->applicationIcon());
|
||||
QAction* toggleViewAction = m_ui->toolBar->toggleViewAction();
|
||||
toggleViewAction->setText(tr("Show toolbar"));
|
||||
|
@ -22,6 +22,27 @@
|
||||
#include "autotype/AutoType.h"
|
||||
#include "core/Config.h"
|
||||
|
||||
class SettingsWidget::ExtraPage
|
||||
{
|
||||
public:
|
||||
ExtraPage(ISettingsPage* page, QWidget* widget): settingsPage(page), widget(widget)
|
||||
{}
|
||||
|
||||
void loadSettings() const
|
||||
{
|
||||
settingsPage->loadSettings(widget);
|
||||
}
|
||||
|
||||
void saveSettings() const
|
||||
{
|
||||
settingsPage->saveSettings(widget);
|
||||
}
|
||||
|
||||
private:
|
||||
QSharedPointer<ISettingsPage> settingsPage;
|
||||
QWidget* widget;
|
||||
};
|
||||
|
||||
SettingsWidget::SettingsWidget(QWidget* parent)
|
||||
: EditWidget(parent)
|
||||
, m_secWidget(new QWidget())
|
||||
@ -50,6 +71,14 @@ SettingsWidget::~SettingsWidget()
|
||||
{
|
||||
}
|
||||
|
||||
void SettingsWidget::addSettingsPage(ISettingsPage *page)
|
||||
{
|
||||
QWidget * widget = page->createWidget();
|
||||
widget->setParent(this);
|
||||
m_extraPages.append(ExtraPage(page, widget));
|
||||
add(page->name(), widget);
|
||||
}
|
||||
|
||||
void SettingsWidget::loadSettings()
|
||||
{
|
||||
m_generalUi->rememberLastDatabasesCheckBox->setChecked(config()->get("RememberLastDatabases").toBool());
|
||||
@ -66,6 +95,9 @@ void SettingsWidget::loadSettings()
|
||||
m_secUi->clearClipboardCheckBox->setChecked(config()->get("security/clearclipboard").toBool());
|
||||
m_secUi->clearClipboardSpinBox->setValue(config()->get("security/clearclipboardtimeout").toInt());
|
||||
|
||||
Q_FOREACH (const ExtraPage& page, m_extraPages)
|
||||
page.loadSettings();
|
||||
|
||||
setCurrentRow(0);
|
||||
}
|
||||
|
||||
@ -80,6 +112,9 @@ void SettingsWidget::saveSettings()
|
||||
config()->set("security/clearclipboard", m_secUi->clearClipboardCheckBox->isChecked());
|
||||
config()->set("security/clearclipboardtimeout", m_secUi->clearClipboardSpinBox->value());
|
||||
|
||||
Q_FOREACH (const ExtraPage& page, m_extraPages)
|
||||
page.saveSettings();
|
||||
|
||||
Q_EMIT editFinished(true);
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,15 @@ namespace Ui {
|
||||
class SettingsWidgetSecurity;
|
||||
}
|
||||
|
||||
class ISettingsPage {
|
||||
public:
|
||||
virtual ~ISettingsPage() {}
|
||||
virtual QString name() = 0;
|
||||
virtual QWidget * createWidget() = 0;
|
||||
virtual void loadSettings(QWidget * widget) = 0;
|
||||
virtual void saveSettings(QWidget * widget) = 0;
|
||||
};
|
||||
|
||||
class SettingsWidget : public EditWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -32,6 +41,7 @@ class SettingsWidget : public EditWidget
|
||||
public:
|
||||
explicit SettingsWidget(QWidget* parent = Q_NULLPTR);
|
||||
~SettingsWidget();
|
||||
void addSettingsPage(ISettingsPage * page);
|
||||
void loadSettings();
|
||||
|
||||
Q_SIGNALS:
|
||||
@ -49,6 +59,8 @@ private:
|
||||
const QScopedPointer<Ui::SettingsWidgetGeneral> m_generalUi;
|
||||
Qt::Key m_globalAutoTypeKey;
|
||||
Qt::KeyboardModifiers m_globalAutoTypeModifiers;
|
||||
class ExtraPage;
|
||||
QList<ExtraPage> m_extraPages;
|
||||
};
|
||||
|
||||
#endif // KEEPASSX_SETTINGSWIDGET_H
|
||||
|
Loading…
Reference in New Issue
Block a user