mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-10-01 01:26:01 -04:00
Fixed HTTP settings and service start-up
This commit is contained in:
parent
eea9d7db97
commit
9cbdd58af5
@ -31,6 +31,39 @@
|
||||
|
||||
#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() {
|
||||
//delete m_service;
|
||||
}
|
||||
virtual QString name() {
|
||||
return QObject::tr("Http");
|
||||
}
|
||||
virtual QWidget * createWidget() {
|
||||
OptionDialog * dlg = new OptionDialog();
|
||||
QObject::connect(dlg, SIGNAL(removeSharedEncryptionKeys()), m_service, SLOT(removeSharedEncryptionKeys()));
|
||||
QObject::connect(dlg, SIGNAL(removeStoredPermissions()), m_service, 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:
|
||||
Service *m_service;
|
||||
};
|
||||
|
||||
const QString MainWindow::BaseWindowTitle = "KeePassX";
|
||||
|
||||
@ -43,6 +76,7 @@ MainWindow::MainWindow()
|
||||
m_countDefaultAttributes = m_ui->menuEntryCopyAttribute->actions().size();
|
||||
|
||||
restoreGeometry(config()->get("GUI/MainWindowGeometry").toByteArray());
|
||||
m_ui->settingsWidget->addSettingsPage(new HttpPlugin(m_ui->tabWidget));
|
||||
|
||||
setWindowIcon(filePath()->applicationIcon());
|
||||
QAction* toggleViewAction = m_ui->toolBar->toggleViewAction();
|
||||
@ -207,11 +241,6 @@ MainWindow::MainWindow()
|
||||
SLOT(openSearch()));
|
||||
|
||||
updateTrayIcon();
|
||||
|
||||
// Keepasshttp service
|
||||
Service *m_service = new Service(m_ui->tabWidget);
|
||||
if (HttpSettings::isEnabled())
|
||||
m_service->start();
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
|
@ -25,13 +25,35 @@
|
||||
|
||||
#include "http/OptionDialog.h"
|
||||
|
||||
#include "http/HttpSettings.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())
|
||||
, m_generalWidget(new QWidget())
|
||||
, m_secUi(new Ui::SettingsWidgetSecurity())
|
||||
, m_generalUi(new Ui::SettingsWidgetGeneral())
|
||||
, m_optionDialogUi(new OptionDialog())
|
||||
, m_globalAutoTypeKey(static_cast<Qt::Key>(0))
|
||||
, m_globalAutoTypeModifiers(Qt::NoModifier)
|
||||
{
|
||||
@ -41,9 +63,6 @@ SettingsWidget::SettingsWidget(QWidget* parent)
|
||||
m_generalUi->setupUi(m_generalWidget);
|
||||
add(tr("General"), m_generalWidget);
|
||||
add(tr("Security"), m_secWidget);
|
||||
add(tr("HTTP"), m_optionDialogUi);
|
||||
//QObject::connect(m_optionDialogUi, SIGNAL(removeSharedEncryptionKeys()), m_service, SLOT(removeSharedEncryptionKeys()));
|
||||
//QObject::connect(m_optionDialogUi, SIGNAL(removeStoredPermissions()), m_service, SLOT(removeStoredPermissions()));
|
||||
|
||||
m_generalUi->autoTypeShortcutWidget->setVisible(autoType()->isAvailable());
|
||||
m_generalUi->autoTypeShortcutLabel->setVisible(autoType()->isAvailable());
|
||||
@ -66,9 +85,16 @@ 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_optionDialogUi->loadSettings();
|
||||
m_generalUi->rememberLastDatabasesCheckBox->setChecked(config()->get("RememberLastDatabases").toBool());
|
||||
m_generalUi->openPreviousDatabasesOnStartupCheckBox->setChecked(
|
||||
config()->get("OpenPreviousDatabasesOnStartup").toBool());
|
||||
@ -109,12 +135,14 @@ void SettingsWidget::loadSettings()
|
||||
|
||||
m_secUi->autoTypeAskCheckBox->setChecked(config()->get("security/autotypeask").toBool());
|
||||
|
||||
Q_FOREACH (const ExtraPage& page, m_extraPages)
|
||||
page.loadSettings();
|
||||
|
||||
setCurrentRow(0);
|
||||
}
|
||||
|
||||
void SettingsWidget::saveSettings()
|
||||
{
|
||||
m_optionDialogUi->saveSettings();
|
||||
config()->set("RememberLastDatabases", m_generalUi->rememberLastDatabasesCheckBox->isChecked());
|
||||
config()->set("OpenPreviousDatabasesOnStartup",
|
||||
m_generalUi->openPreviousDatabasesOnStartupCheckBox->isChecked());
|
||||
@ -147,6 +175,9 @@ void SettingsWidget::saveSettings()
|
||||
|
||||
config()->set("security/autotypeask", m_secUi->autoTypeAskCheckBox->isChecked());
|
||||
|
||||
Q_FOREACH (const ExtraPage& page, m_extraPages)
|
||||
page.saveSettings();
|
||||
|
||||
Q_EMIT editFinished(true);
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,6 @@
|
||||
#define KEEPASSX_SETTINGSWIDGET_H
|
||||
|
||||
#include "gui/EditWidget.h"
|
||||
#include "http/OptionDialog.h"
|
||||
|
||||
namespace Ui {
|
||||
class SettingsWidgetGeneral;
|
||||
@ -56,11 +55,13 @@ private Q_SLOTS:
|
||||
private:
|
||||
QWidget* const m_secWidget;
|
||||
QWidget* const m_generalWidget;
|
||||
OptionDialog* const m_optionDialogUi;
|
||||
const QScopedPointer<Ui::SettingsWidgetSecurity> m_secUi;
|
||||
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