Refactor Database Settings (#9485)

Includes following changes:

* Encryption Settings now has a similar key with the new database wizard for switching between Advanced and Simple Settings
* The extra UI layer DatabaseSettingsDialog.ui has been removed. DatabaseSettingsDialog class now inherits EditWidget instead of DialogyWidget (just like Application Settings).
* Extra classes for separate page settings (DatabaseSettingsPageFdoSecrets, DatabaseSettingsPageKeeShare) have been removed. Instead the widgets are used directly in DatabaseSettingsDialog. Same could be done later to Application 

---------

Co-authored-by: Jonathan White <support@dmapps.us>
This commit is contained in:
Sami Vänttinen 2024-06-22 14:25:32 +03:00 committed by GitHub
parent 88b76244cf
commit fbdd97b1be
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
36 changed files with 152 additions and 391 deletions

View File

@ -1599,14 +1599,6 @@ To prevent this error from appearing, you must go to &quot;Database Settings / S
<source>&lt;p&gt;In addition to a password, you can use a secret file to enhance the security of your database. This file can be generated in your database&apos;s security settings.&lt;/p&gt;&lt;p&gt;This is &lt;strong&gt;not&lt;/strong&gt; your *.kdbx database file!&lt;/p&gt;</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Click to add a key file.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&lt;a href=&quot;#&quot; style=&quot;text-decoration: underline&quot;&gt;I have a key file&lt;/a&gt;</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Use hardware key [Serial: %1]</source>
<translation type="unfinished"></translation>
@ -1639,6 +1631,14 @@ Are you sure you want to continue with this file?.</source>
<source>Refresh Hardware Keys</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Click to add a key file.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&lt;a href=&quot;#&quot; style=&quot;text-decoration: underline&quot;&gt;I have a key file&lt;/a&gt;</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>DatabaseSettingWidgetMetaData</name>
@ -1673,6 +1673,14 @@ Are you sure you want to continue with this file?.</source>
<source>Maintenance</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>KeeShare</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Secret Service Integration</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Remote Sync</source>
<translation type="unfinished"></translation>

View File

@ -115,6 +115,7 @@ set(keepassx_SOURCES
gui/ApplicationSettingsWidget.cpp
gui/Icons.cpp
gui/SearchWidget.cpp
gui/SettingsWidget.cpp
gui/SortFilterHideProxyModel.cpp
gui/SquareSvgWidget.cpp
gui/ShortcutSettingsPage.cpp
@ -167,7 +168,6 @@ set(keepassx_SOURCES
gui/osutils/OSUtilsBase.cpp
gui/osutils/ScreenLockListener.cpp
gui/osutils/ScreenLockListenerPrivate.cpp
gui/settings/SettingsWidget.cpp
gui/widgets/ElidedLabel.cpp
gui/widgets/KPToolBar.cpp
gui/widgets/PopupHelpWidget.cpp

View File

@ -9,7 +9,6 @@ if(WITH_XC_FDOSECRETS)
widgets/RowButtonHelper.cpp
# per database settings page
DatabaseSettingsPageFdoSecrets.cpp
widgets/DatabaseSettingsWidgetFdoSecrets.cpp
# prompt dialog

View File

@ -1,49 +0,0 @@
/*
* Copyright (C) 2019 Aetf <aetf@unlimitedcodeworks.xyz>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 or (at your option)
* version 3 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "DatabaseSettingsPageFdoSecrets.h"
#include "fdosecrets/widgets/DatabaseSettingsWidgetFdoSecrets.h"
#include "gui/Icons.h"
QString DatabaseSettingsPageFdoSecrets::name()
{
return QObject::tr("Secret Service Integration");
}
QIcon DatabaseSettingsPageFdoSecrets::icon()
{
return icons()->icon(QStringLiteral("freedesktop"));
}
QWidget* DatabaseSettingsPageFdoSecrets::createWidget()
{
return new DatabaseSettingsWidgetFdoSecrets;
}
void DatabaseSettingsPageFdoSecrets::loadSettings(QWidget* widget, QSharedPointer<Database> db)
{
auto settingsWidget = qobject_cast<DatabaseSettingsWidgetFdoSecrets*>(widget);
settingsWidget->loadSettings(db);
}
void DatabaseSettingsPageFdoSecrets::saveSettings(QWidget* widget)
{
auto settingsWidget = qobject_cast<DatabaseSettingsWidgetFdoSecrets*>(widget);
settingsWidget->saveSettings();
}

View File

@ -1,36 +0,0 @@
/*
* Copyright (C) 2019 Aetf <aetf@unlimitedcodeworks.xyz>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 or (at your option)
* version 3 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef KEEPASSXC_DATABASESETTINGSPAGEFDOSECRETS_H
#define KEEPASSXC_DATABASESETTINGSPAGEFDOSECRETS_H
#include "gui/dbsettings/DatabaseSettingsDialog.h"
class DatabaseSettingsPageFdoSecrets : public IDatabaseSettingsPage
{
Q_DISABLE_COPY(DatabaseSettingsPageFdoSecrets)
public:
DatabaseSettingsPageFdoSecrets() = default;
QString name() override;
QIcon icon() override;
QWidget* createWidget() override;
void loadSettings(QWidget* widget, QSharedPointer<Database> db) override;
void saveSettings(QWidget* widget) override;
};
#endif // KEEPASSXC_DATABASESETTINGSPAGEFDOSECRETS_H

View File

@ -34,6 +34,9 @@
#include "FileDialog.h"
#include "MessageBox.h"
#ifdef WITH_XC_BROWSER
#include "browser/BrowserSettingsPage.h"
#endif
class ApplicationSettingsWidget::ExtraPage
{
@ -97,6 +100,9 @@ ApplicationSettingsWidget::ApplicationSettingsWidget(QWidget* parent)
m_generalUi->setupUi(m_generalWidget);
addPage(tr("General"), icons()->icon("preferences-other"), m_generalWidget);
addPage(tr("Security"), icons()->icon("security-high"), m_secWidget);
#ifdef WITH_XC_BROWSER
addSettingsPage(new BrowserSettingsPage());
#endif
if (!autoType()->isAvailable()) {
m_generalUi->generalSettingsTabWidget->removeTab(1);

View File

@ -72,7 +72,6 @@
#ifdef WITH_XC_BROWSER
#include "browser/BrowserService.h"
#include "browser/BrowserSettingsPage.h"
#endif
#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS) && !defined(QT_NO_DBUS)
@ -222,7 +221,6 @@ MainWindow::MainWindow()
m_ui->settingsWidget->addSettingsPage(new ShortcutSettingsPage());
#ifdef WITH_XC_BROWSER
m_ui->settingsWidget->addSettingsPage(new BrowserSettingsPage());
connect(
browserService(), &BrowserService::requestUnlock, m_ui->tabWidget, &DatabaseTabWidget::performBrowserUnlock);
#endif

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 KeePassXC Team <team@keepassxc.org>
* Copyright (C) 2023 KeePassXC Team <team@keepassxc.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -22,8 +22,6 @@ SettingsWidget::SettingsWidget(QWidget* parent)
{
}
SettingsWidget::~SettingsWidget() = default;
void SettingsWidget::discard()
{
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 KeePassXC Team <team@keepassxc.org>
* Copyright (C) 2023 KeePassXC Team <team@keepassxc.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -31,8 +31,7 @@ class SettingsWidget : public QWidget
public:
explicit SettingsWidget(QWidget* parent = nullptr);
Q_DISABLE_COPY(SettingsWidget);
~SettingsWidget() override;
~SettingsWidget() override = default;
public slots:
/**
@ -50,7 +49,7 @@ public slots:
*
* @return true on success, false on failure
*/
virtual bool save() = 0;
virtual bool saveSettings() = 0;
/**
* Discard settings.
@ -62,6 +61,8 @@ signals:
private:
bool m_advancedMode = false;
Q_DISABLE_COPY(SettingsWidget);
};
#endif // KEEPASSXC_SETTINGSWIDGET_H

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 KeePassXC Team <team@keepassxc.org>
* Copyright (C) 2023 KeePassXC Team <team@keepassxc.org>
* Copyright (C) 2012 Felix Geyer <debfx@fobos.de>
*
* This program is free software: you can redistribute it and/or modify
@ -17,8 +17,6 @@
*/
#include "DatabaseSettingsDialog.h"
#include "ui_DatabaseSettingsDialog.h"
#include "DatabaseSettingsWidgetDatabaseKey.h"
#include "DatabaseSettingsWidgetEncryption.h"
#include "DatabaseSettingsWidgetGeneral.h"
@ -28,10 +26,10 @@
#include "../remote/DatabaseSettingsWidgetRemote.h"
#include "DatabaseSettingsWidgetMaintenance.h"
#ifdef WITH_XC_KEESHARE
#include "keeshare/DatabaseSettingsPageKeeShare.h"
#include "keeshare/DatabaseSettingsWidgetKeeShare.h"
#endif
#ifdef WITH_XC_FDOSECRETS
#include "fdosecrets/DatabaseSettingsPageFdoSecrets.h"
#include "fdosecrets/widgets/DatabaseSettingsWidgetFdoSecrets.h"
#endif
#include "core/Database.h"
@ -40,50 +38,29 @@
#include <QScrollArea>
class DatabaseSettingsDialog::ExtraPage
{
public:
ExtraPage(IDatabaseSettingsPage* page, QWidget* widget)
: settingsPage(page)
, widget(widget)
{
}
void loadSettings(QSharedPointer<Database> db) const
{
settingsPage->loadSettings(widget, db);
}
void saveSettings() const
{
settingsPage->saveSettings(widget);
}
private:
QSharedPointer<IDatabaseSettingsPage> settingsPage;
QWidget* widget;
};
DatabaseSettingsDialog::DatabaseSettingsDialog(QWidget* parent)
: DialogyWidget(parent)
, m_ui(new Ui::DatabaseSettingsDialog())
: EditWidget(parent)
, m_generalWidget(new DatabaseSettingsWidgetGeneral(this))
, m_securityTabWidget(new QTabWidget(this))
, m_databaseKeyWidget(new DatabaseSettingsWidgetDatabaseKey(this))
, m_encryptionWidget(new DatabaseSettingsWidgetEncryption(this))
#ifdef WITH_XC_BROWSER
, m_browserWidget(new DatabaseSettingsWidgetBrowser(this))
#endif
#ifdef WITH_XC_KEESHARE
, m_keeShareWidget(new DatabaseSettingsWidgetKeeShare(this))
#endif
#ifdef WITH_XC_FDOSECRETS
, m_fdoSecretsWidget(new DatabaseSettingsWidgetFdoSecrets(this))
#endif
, m_maintenanceWidget(new DatabaseSettingsWidgetMaintenance(this))
, m_remoteWidget(new DatabaseSettingsWidgetRemote(this))
{
m_ui->setupUi(this);
connect(this, SIGNAL(accepted()), SLOT(save()));
connect(this, SIGNAL(rejected()), SLOT(reject()));
connect(m_ui->buttonBox, SIGNAL(accepted()), SLOT(save()));
connect(m_ui->buttonBox, SIGNAL(rejected()), SLOT(reject()));
m_ui->categoryList->addCategory(tr("General"), icons()->icon("preferences-other"));
m_ui->stackedWidget->addWidget(m_generalWidget);
m_ui->categoryList->addCategory(tr("Security"), icons()->icon("security-high"));
m_ui->stackedWidget->addWidget(m_securityTabWidget);
addPage(tr("General"), icons()->icon("preferences-other"), m_generalWidget);
addPage(tr("Security"), icons()->icon("security-high"), m_securityTabWidget);
auto* scrollArea = new QScrollArea(parent);
scrollArea->setFrameShape(QFrame::NoFrame);
@ -93,106 +70,99 @@ DatabaseSettingsDialog::DatabaseSettingsDialog(QWidget* parent)
scrollArea->setWidgetResizable(true);
scrollArea->setWidget(m_databaseKeyWidget);
m_securityTabWidget->setObjectName("securityTabWidget");
m_securityTabWidget->addTab(scrollArea, tr("Database Credentials"));
m_securityTabWidget->addTab(m_encryptionWidget, tr("Encryption Settings"));
m_securityTabWidget->setCurrentIndex(0);
m_ui->categoryList->addCategory(tr("Remote Sync"), icons()->icon("remote-sync"));
m_ui->stackedWidget->addWidget(m_remoteWidget);
addPage(tr("Remote Sync"), icons()->icon("remote-sync"), m_remoteWidget);
#ifdef WITH_XC_BROWSER
m_ui->categoryList->addCategory(tr("Browser Integration"), icons()->icon("internet-web-browser"));
m_ui->stackedWidget->addWidget(m_browserWidget);
addPage(tr("Browser Integration"), icons()->icon("internet-web-browser"), m_browserWidget);
#endif
#ifdef WITH_XC_KEESHARE
addSettingsPage(new DatabaseSettingsPageKeeShare());
addPage(tr("KeeShare"), icons()->icon("preferences-system-network-sharing"), m_keeShareWidget);
#endif
#ifdef WITH_XC_FDOSECRETS
addSettingsPage(new DatabaseSettingsPageFdoSecrets());
addPage(tr("Secret Service Integration"), icons()->icon(QStringLiteral("freedesktop")), m_fdoSecretsWidget);
#endif
m_ui->categoryList->addCategory(tr("Maintenance"), icons()->icon("hammer-wrench"));
m_ui->stackedWidget->addWidget(m_maintenanceWidget);
addPage(tr("Maintenance"), icons()->icon("hammer-wrench"), m_maintenanceWidget);
m_ui->stackedWidget->setCurrentIndex(0);
connect(m_ui->categoryList, SIGNAL(categoryChanged(int)), m_ui->stackedWidget, SLOT(setCurrentIndex(int)));
setCurrentPage(0);
}
DatabaseSettingsDialog::~DatabaseSettingsDialog() = default;
void DatabaseSettingsDialog::load(const QSharedPointer<Database>& db)
{
m_ui->categoryList->setCurrentCategory(0);
m_generalWidget->load(db);
m_databaseKeyWidget->load(db);
m_encryptionWidget->load(db);
m_generalWidget->loadSettings(db);
m_databaseKeyWidget->loadSettings(db);
m_encryptionWidget->loadSettings(db);
m_remoteWidget->loadSettings(db);
#ifdef WITH_XC_BROWSER
m_browserWidget->load(db);
m_browserWidget->loadSettings(db);
#endif
m_maintenanceWidget->load(db);
m_remoteWidget->load(db);
for (const ExtraPage& page : asConst(m_extraPages)) {
page.loadSettings(db);
}
m_db = db;
}
#ifdef WITH_XC_KEESHARE
m_keeShareWidget->loadSettings(db);
#endif
#ifdef WITH_XC_FDOSECRETS
m_fdoSecretsWidget->loadSettings(db);
#endif
m_maintenanceWidget->loadSettings(db);
void DatabaseSettingsDialog::addSettingsPage(IDatabaseSettingsPage* page)
{
const int category = m_ui->categoryList->currentCategory();
QWidget* widget = page->createWidget();
widget->setParent(this);
m_extraPages.append(ExtraPage(page, widget));
m_ui->stackedWidget->addWidget(widget);
m_ui->categoryList->addCategory(page->name(), page->icon());
m_ui->categoryList->setCurrentCategory(category);
m_db = db;
}
/**
* Show page and tab with database database key settings.
*/
void DatabaseSettingsDialog::showDatabaseKeySettings()
void DatabaseSettingsDialog::showDatabaseKeySettings(int index)
{
m_ui->categoryList->setCurrentCategory(1);
m_securityTabWidget->setCurrentIndex(0);
setCurrentPage(1);
m_securityTabWidget->setCurrentIndex(index);
}
void DatabaseSettingsDialog::showRemoteSettings()
{
m_ui->categoryList->setCurrentCategory(2);
setCurrentPage(2);
}
void DatabaseSettingsDialog::save()
{
if (!m_generalWidget->save()) {
m_ui->categoryList->setCurrentCategory(0);
if (!m_generalWidget->saveSettings()) {
setCurrentPage(0);
return;
}
if (!m_databaseKeyWidget->save()) {
m_ui->categoryList->setCurrentCategory(1);
if (!m_databaseKeyWidget->saveSettings()) {
setCurrentPage(1);
m_securityTabWidget->setCurrentIndex(0);
return;
}
if (!m_encryptionWidget->save()) {
m_ui->categoryList->setCurrentCategory(1);
if (!m_encryptionWidget->saveSettings()) {
setCurrentPage(1);
m_securityTabWidget->setCurrentIndex(1);
return;
}
if (!m_remoteWidget->save()) {
m_ui->categoryList->setCurrentCategory(2);
if (!m_remoteWidget->saveSettings()) {
setCurrentPage(2);
return;
}
// Browser settings don't have anything to save
for (const ExtraPage& extraPage : asConst(m_extraPages)) {
extraPage.saveSettings();
}
#ifdef WITH_XC_KEESHARE
m_keeShareWidget->saveSettings();
#endif
#ifdef WITH_XC_FDOSECRETS
m_fdoSecretsWidget->saveSettings();
#endif
emit editFinished(true);
}

View File

@ -1,4 +1,5 @@
/*
* Copyright (C) 2023 KeePassXC Team <team@keepassxc.org>
* Copyright (C) 2012 Felix Geyer <debfx@fobos.de>
*
* This program is free software: you can redistribute it and/or modify
@ -15,11 +16,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef KEEPASSX_DATABASESETTINGSWIDGET_H
#define KEEPASSX_DATABASESETTINGSWIDGET_H
#ifndef KEEPASSXC_DATABASESETTINGSDIALOG_H
#define KEEPASSXC_DATABASESETTINGSDIALOG_H
#include "config-keepassx.h"
#include "gui/DialogyWidget.h"
#include "gui/EditWidget.h"
#include <QPointer>
@ -30,27 +31,17 @@ class DatabaseSettingsWidgetDatabaseKey;
#ifdef WITH_XC_BROWSER
class DatabaseSettingsWidgetBrowser;
#endif
#ifdef WITH_XC_KEESHARE
class DatabaseSettingsWidgetKeeShare;
#endif
#ifdef WITH_XC_FDOSECRETS
class DatabaseSettingsWidgetFdoSecrets;
#endif
class DatabaseSettingsWidgetMaintenance;
class DatabaseSettingsWidgetRemote;
class QTabWidget;
namespace Ui
{
class DatabaseSettingsDialog;
}
class IDatabaseSettingsPage
{
public:
virtual ~IDatabaseSettingsPage() = default;
virtual QString name() = 0;
virtual QIcon icon() = 0;
virtual QWidget* createWidget() = 0;
virtual void loadSettings(QWidget* widget, QSharedPointer<Database> db) = 0;
virtual void saveSettings(QWidget* widget) = 0;
};
class DatabaseSettingsDialog : public DialogyWidget
class DatabaseSettingsDialog : public EditWidget
{
Q_OBJECT
@ -60,8 +51,7 @@ public:
Q_DISABLE_COPY(DatabaseSettingsDialog);
void load(const QSharedPointer<Database>& db);
void addSettingsPage(IDatabaseSettingsPage* page);
void showDatabaseKeySettings();
void showDatabaseKeySettings(int index = 0);
void showRemoteSettings();
signals:
@ -72,26 +62,22 @@ private slots:
void reject();
private:
enum Page
{
General = 0,
Security = 1
};
QSharedPointer<Database> m_db;
const QScopedPointer<Ui::DatabaseSettingsDialog> m_ui;
QPointer<DatabaseSettingsWidgetGeneral> m_generalWidget;
QPointer<QTabWidget> m_securityTabWidget;
QPointer<DatabaseSettingsWidgetDatabaseKey> m_databaseKeyWidget;
QPointer<DatabaseSettingsWidgetEncryption> m_encryptionWidget;
#ifdef WITH_XC_BROWSER
QPointer<DatabaseSettingsWidgetBrowser> m_browserWidget;
#endif
#ifdef WITH_XC_KEESHARE
QPointer<DatabaseSettingsWidgetKeeShare> m_keeShareWidget;
#endif
#ifdef WITH_XC_FDOSECRETS
QPointer<DatabaseSettingsWidgetFdoSecrets> m_fdoSecretsWidget;
#endif
QPointer<DatabaseSettingsWidgetMaintenance> m_maintenanceWidget;
QPointer<DatabaseSettingsWidgetRemote> m_remoteWidget;
class ExtraPage;
QList<ExtraPage> m_extraPages;
};
#endif // KEEPASSX_DATABASESETTINGSWIDGET_H
#endif // KEEPASSXC_DATABASESETTINGSDIALOG_H

View File

@ -1,39 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DatabaseSettingsDialog</class>
<widget class="QWidget" name="DatabaseSettingsDialog">
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,0">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2" stretch="0,1">
<item>
<widget class="CategoryListWidget" name="categoryList" native="true"/>
</item>
<item>
<widget class="QStackedWidget" name="stackedWidget">
<property name="currentIndex">
<number>-1</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>CategoryListWidget</class>
<extends>QWidget</extends>
<header>gui/CategoryListWidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 KeePassXC Team <team@keepassxc.org>
* Copyright (C) 2023 KeePassXC Team <team@keepassxc.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -31,7 +31,7 @@ DatabaseSettingsWidget::~DatabaseSettingsWidget() = default;
*
* @param db database object to be configured
*/
void DatabaseSettingsWidget::load(QSharedPointer<Database> db)
void DatabaseSettingsWidget::loadSettings(QSharedPointer<Database> db)
{
m_db = std::move(db);
initialize();

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 KeePassXC Team <team@keepassxc.org>
* Copyright (C) 2023 KeePassXC Team <team@keepassxc.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -18,7 +18,7 @@
#ifndef KEEPASSXC_DATABASESETTINGSWIDGET_H
#define KEEPASSXC_DATABASESETTINGSWIDGET_H
#include "gui/settings/SettingsWidget.h"
#include "gui/SettingsWidget.h"
class Database;
@ -34,7 +34,7 @@ public:
Q_DISABLE_COPY(DatabaseSettingsWidget);
~DatabaseSettingsWidget() override;
virtual void load(QSharedPointer<Database> db);
virtual void loadSettings(QSharedPointer<Database> db);
const QSharedPointer<Database> getDatabase() const;

View File

@ -82,7 +82,7 @@ void DatabaseSettingsWidgetBrowser::showEvent(QShowEvent* event)
QWidget::showEvent(event);
}
bool DatabaseSettingsWidgetBrowser::save()
bool DatabaseSettingsWidgetBrowser::saveSettings()
{
return true;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2022 KeePassXC Team <team@keepassxc.org>
* Copyright (C) 2023 KeePassXC Team <team@keepassxc.org>
* Copyright (C) 2018 Sami Vänttinen <sami.vanttinen@protonmail.com>
*
* This program is free software: you can redistribute it and/or modify
@ -47,7 +47,7 @@ public:
public slots:
void initialize() override;
void uninitialize() override;
bool save() override;
bool saveSettings() override;
private slots:
void removeSelectedKey();

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 KeePassXC Team <team@keepassxc.org>
* Copyright (C) 2023 KeePassXC Team <team@keepassxc.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -46,10 +46,10 @@ DatabaseSettingsWidgetDatabaseKey::DatabaseSettingsWidgetDatabaseKey(QWidget* pa
vbox->setSizeConstraint(QLayout::SetMinimumSize);
vbox->setSpacing(20);
// primary password option
// Primary password option
vbox->addWidget(m_passwordEditWidget);
// additional key options
// Additional key options
m_additionalKeyOptionsToggle->setObjectName("additionalKeyOptionsToggle");
vbox->addWidget(m_additionalKeyOptionsToggle);
vbox->addWidget(m_additionalKeyOptions);
@ -71,12 +71,12 @@ DatabaseSettingsWidgetDatabaseKey::DatabaseSettingsWidgetDatabaseKey(QWidget* pa
DatabaseSettingsWidgetDatabaseKey::~DatabaseSettingsWidgetDatabaseKey() = default;
void DatabaseSettingsWidgetDatabaseKey::load(QSharedPointer<Database> db)
void DatabaseSettingsWidgetDatabaseKey::loadSettings(QSharedPointer<Database> db)
{
DatabaseSettingsWidget::load(db);
DatabaseSettingsWidget::loadSettings(db);
if (!m_db->key() || m_db->key()->keys().isEmpty()) {
// database has no key, we are about to add a new one
// Database has no key, we are about to add a new one
m_passwordEditWidget->changeVisiblePage(KeyComponentWidget::Page::Edit);
m_passwordEditWidget->setPasswordVisible(true);
// Focus won't work until the UI settles
@ -126,7 +126,7 @@ void DatabaseSettingsWidgetDatabaseKey::uninitialize()
{
}
bool DatabaseSettingsWidgetDatabaseKey::save()
bool DatabaseSettingsWidgetDatabaseKey::saveSettings()
{
m_isDirty |= (m_passwordEditWidget->visiblePage() == KeyComponentWidget::Page::Edit);
m_isDirty |= (m_keyFileEditWidget->visiblePage() == KeyComponentWidget::Page::Edit);
@ -135,7 +135,7 @@ bool DatabaseSettingsWidgetDatabaseKey::save()
#endif
if (m_db->key() && !m_db->key()->keys().isEmpty() && !m_isDirty) {
// key unchanged
// Key unchanged
return true;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 KeePassXC Team <team@keepassxc.org>
* Copyright (C) 2023 KeePassXC Team <team@keepassxc.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -15,8 +15,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef KEEPASSXC_DATABASESETTINGSPAGECHANGEDBKEY_H
#define KEEPASSXC_DATABASESETTINGSPAGECHANGEDBKEY_H
#ifndef KEEPASSXC_DATABASESETTINGSWIDGETDATABASEKEY_H
#define KEEPASSXC_DATABASESETTINGSWIDGETDATABASEKEY_H
#include "DatabaseSettingsWidget.h"
#include "config-keepassx.h"
@ -42,12 +42,12 @@ public:
Q_DISABLE_COPY(DatabaseSettingsWidgetDatabaseKey);
~DatabaseSettingsWidgetDatabaseKey() override;
void load(QSharedPointer<Database> db) override;
void loadSettings(QSharedPointer<Database> db) override;
public slots:
void initialize() override;
void uninitialize() override;
bool save() override;
bool saveSettings() override;
void discard() override;
private slots:
@ -77,4 +77,4 @@ private:
#endif
};
#endif // KEEPASSXC_DATABASESETTINGSPAGECHANGEDBKEY_H
#endif // KEEPASSXC_DATABASESETTINGSWIDGETDATABASEKEY_H

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 KeePassXC Team <team@keepassxc.org>
* Copyright (C) 2023 KeePassXC Team <team@keepassxc.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -73,7 +73,7 @@ DatabaseSettingsWidgetEncryption::DatabaseSettingsWidgetEncryption(QWidget* pare
connect(m_ui->decryptionTimeSlider, SIGNAL(valueChanged(int)), SLOT(updateDecryptionTime(int)));
// conditions under which a key re-transformation is needed
// Conditions under which a key re-transformation is needed
connect(m_ui->decryptionTimeSlider, SIGNAL(valueChanged(int)), SLOT(markDirty()));
connect(m_ui->compatibilitySelection, SIGNAL(currentIndexChanged(int)), SLOT(markDirty()));
connect(m_ui->algorithmComboBox, SIGNAL(currentIndexChanged(int)), SLOT(markDirty()));
@ -256,7 +256,7 @@ void DatabaseSettingsWidgetEncryption::markDirty()
m_isDirty = true;
}
bool DatabaseSettingsWidgetEncryption::save()
bool DatabaseSettingsWidgetEncryption::saveSettings()
{
Q_ASSERT(m_db);
if (!m_db) {
@ -269,7 +269,7 @@ bool DatabaseSettingsWidgetEncryption::save()
}
if (m_db->key() && !m_db->key()->keys().isEmpty() && !m_isDirty) {
// nothing has changed, don't re-transform
// Nothing has changed, don't re-transform
return true;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 KeePassXC Team <team@keepassxc.org>
* Copyright (C) 2023 KeePassXC Team <team@keepassxc.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -40,7 +40,7 @@ public:
public slots:
void initialize() override;
void uninitialize() override;
bool save() override;
bool saveSettings() override;
protected:
void showEvent(QShowEvent* event) override;

View File

@ -537,6 +537,7 @@
<tabstop>transformBenchmarkButton</tabstop>
<tabstop>memorySpinBox</tabstop>
<tabstop>parallelismSpinBox</tabstop>
<tabstop>advancedSettingsButton</tabstop>
</tabstops>
<resources/>
<connections/>

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 KeePassXC Team <team@keepassxc.org>
* Copyright (C) 2023 KeePassXC Team <team@keepassxc.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -82,7 +82,7 @@ void DatabaseSettingsWidgetGeneral::showEvent(QShowEvent* event)
m_ui->dbNameEdit->setFocus();
}
bool DatabaseSettingsWidgetGeneral::save()
bool DatabaseSettingsWidgetGeneral::saveSettings()
{
auto* meta = m_db->metadata();

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 KeePassXC Team <team@keepassxc.org>
* Copyright (C) 2023 KeePassXC Team <team@keepassxc.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -38,7 +38,7 @@ public:
public slots:
void initialize() override;
void uninitialize() override;
bool save() override;
bool saveSettings() override;
protected:
void showEvent(QShowEvent* event) override;

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2021 KeePassXC Team <team@keepassxc.org>
* Copyright (C) 2023 KeePassXC Team <team@keepassxc.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -40,7 +40,7 @@ public:
public slots:
void initialize() override;
void uninitialize() override{};
inline bool save() override
inline bool saveSettings() override
{
return true;
};

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 KeePassXC Team <team@keepassxc.org>
* Copyright (C) 2023 KeePassXC Team <team@keepassxc.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -51,7 +51,7 @@ void DatabaseSettingWidgetMetaData::uninitialize()
{
}
bool DatabaseSettingWidgetMetaData::save()
bool DatabaseSettingWidgetMetaData::saveSettings()
{
Metadata* meta = m_db->metadata();
meta->setName(m_ui->databaseName->text());

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 KeePassXC Team <team@keepassxc.org>
* Copyright (C) 2023 KeePassXC Team <team@keepassxc.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -38,7 +38,7 @@ public:
public slots:
void initialize() override;
void uninitialize() override;
bool save() override;
bool saveSettings() override;
protected:
void showEvent(QShowEvent* event) override;

View File

@ -69,7 +69,7 @@ void DatabaseSettingsWidgetRemote::uninitialize()
{
}
bool DatabaseSettingsWidgetRemote::save()
bool DatabaseSettingsWidgetRemote::saveSettings()
{
if (m_modified) {
auto ans = MessageBox::question(this,

View File

@ -43,7 +43,7 @@ public:
public slots:
void initialize() override;
void uninitialize() override;
bool save() override;
bool saveSettings() override;
private slots:
void saveCurrentSettings();

View File

@ -18,7 +18,7 @@
#ifndef KEEPASSXC_REPORTSWIDGET_H
#define KEEPASSXC_REPORTSWIDGET_H
#include "gui/settings/SettingsWidget.h"
#include "gui/SettingsWidget.h"
class Database;

View File

@ -1,6 +1,6 @@
/*
* Copyright (C) 2018 KeePassXC Team <team@keepassxc.org>
* Copyright (C) 2023 KeePassXC Team <team@keepassxc.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -69,7 +69,7 @@ void NewDatabaseWizardPage::initializePage()
return;
}
m_pageWidget->load(m_db);
m_pageWidget->loadSettings(m_db);
}
bool NewDatabaseWizardPage::validatePage()
@ -79,7 +79,7 @@ bool NewDatabaseWizardPage::validatePage()
return false;
}
bool valid = m_pageWidget->save();
bool valid = m_pageWidget->saveSettings();
m_pageWidget->uninitialize();
return valid;
}

View File

@ -2,7 +2,6 @@ if(WITH_XC_KEESHARE)
set(keeshare_SOURCES
SettingsPageKeeShare.cpp
SettingsWidgetKeeShare.cpp
DatabaseSettingsPageKeeShare.cpp
DatabaseSettingsWidgetKeeShare.cpp
group/EditGroupWidgetKeeShare.cpp
group/EditGroupPageKeeShare.cpp

View File

@ -1,49 +0,0 @@
/*
* Copyright (C) 2018 KeePassXC Team <team@keepassxc.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 or (at your option)
* version 3 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "DatabaseSettingsPageKeeShare.h"
#include "core/Database.h"
#include "gui/Icons.h"
#include "keeshare/DatabaseSettingsWidgetKeeShare.h"
QString DatabaseSettingsPageKeeShare::name()
{
return "KeeShare";
}
QIcon DatabaseSettingsPageKeeShare::icon()
{
return icons()->icon("preferences-system-network-sharing");
}
QWidget* DatabaseSettingsPageKeeShare::createWidget()
{
return new DatabaseSettingsWidgetKeeShare();
}
void DatabaseSettingsPageKeeShare::loadSettings(QWidget* widget, QSharedPointer<Database> db)
{
DatabaseSettingsWidgetKeeShare* settingsWidget = reinterpret_cast<DatabaseSettingsWidgetKeeShare*>(widget);
settingsWidget->loadSettings(db);
}
void DatabaseSettingsPageKeeShare::saveSettings(QWidget* widget)
{
DatabaseSettingsWidgetKeeShare* settingsWidget = reinterpret_cast<DatabaseSettingsWidgetKeeShare*>(widget);
settingsWidget->saveSettings();
}

View File

@ -1,33 +0,0 @@
/*
* Copyright (C) 2018 KeePassXC Team <team@keepassxc.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 or (at your option)
* version 3 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef KEEPASSXC_DATABASESETTINGSPAGEKEESHARE_H
#define KEEPASSXC_DATABASESETTINGSPAGEKEESHARE_H
#include "gui/dbsettings/DatabaseSettingsDialog.h"
class DatabaseSettingsPageKeeShare : public IDatabaseSettingsPage
{
public:
QString name() override;
QIcon icon() override;
QWidget* createWidget() override;
void loadSettings(QWidget* widget, QSharedPointer<Database> db) override;
void saveSettings(QWidget* widget) override;
};
#endif // KEEPASSXC_DATABASESETTINGSPAGEKEESHARE_H

View File

@ -1,6 +1,6 @@
/*
* Copyright (C) 2018 KeePassXC Team <team@keepassxc.org>
* Copyright (C) 2023 KeePassXC Team <team@keepassxc.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -36,7 +36,7 @@ DatabaseSettingsWidgetKeeShare::~DatabaseSettingsWidgetKeeShare()
{
}
void DatabaseSettingsWidgetKeeShare::loadSettings(QSharedPointer<Database> db)
void DatabaseSettingsWidgetKeeShare::loadSettings(const QSharedPointer<Database>& db)
{
m_db = db;

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 KeePassXC Team <team@keepassxc.org>
* Copyright (C) 2023 KeePassXC Team <team@keepassxc.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -37,7 +37,7 @@ public:
explicit DatabaseSettingsWidgetKeeShare(QWidget* parent = nullptr);
~DatabaseSettingsWidgetKeeShare();
void loadSettings(QSharedPointer<Database> db);
void loadSettings(const QSharedPointer<Database>& db);
void saveSettings();
private:

View File

@ -54,6 +54,7 @@
#include "gui/databasekey/KeyFileEditWidget.h"
#include "gui/databasekey/PasswordEditWidget.h"
#include "gui/dbsettings/DatabaseSettingsDialog.h"
#include "gui/dbsettings/DatabaseSettingsWidgetEncryption.h"
#include "gui/entry/EditEntryWidget.h"
#include "gui/entry/EntryView.h"
#include "gui/group/EditGroupWidget.h"
@ -1604,7 +1605,7 @@ void TestGui::testDatabaseSettings()
int autosaveDelayTestValue = 2;
dbSettingsCategoryList->setCurrentCategory(1); // go into security category
auto securityTabWidget = dbSettingsStackedWidget->findChild<QTabWidget*>();
auto securityTabWidget = dbSettingsStackedWidget->findChild<QTabWidget*>("securityTabWidget");
QCOMPARE(securityTabWidget->currentIndex(), 0);
// Interact with the password edit option