mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-07-12 09:39:38 -04:00

* Remove individual feature flags in favor of a single `KPXC_MINIMAL` flag that removes advanced features from the build. Basic features are no longer guarded by feature flags. * Basic features: Auto-Type, Yubikey, KeeShare * Advanced features include: Browser (and passkeys), SSH Agent, and Secret Service * Networking, Documentation, and Update Checking remain as feature flags to accommodate various distro requirements. This change also cleans up the main CMakeLists.txt by re-arranging some content and placing macros into a dedicated include file. The minimum CMake version was bumped to 3.16.0 to conform to our minimum Ubuntu support of Focal (20.04). This also allows us to default to C++20, we fall back to C++17 for Qt versions less than 5.15.0 due to lack of support. Lastly this change removes the KEEPASSXC_BUILD_TYPE="PreRelease" which is never used. We only support "Snapshot" and "Release" now.
184 lines
5.7 KiB
C++
184 lines
5.7 KiB
C++
/*
|
|
* 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
|
|
* 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 "ReportsDialog.h"
|
|
#include "ui_ReportsDialog.h"
|
|
|
|
#include "ReportsPageHealthcheck.h"
|
|
#include "ReportsPageHibp.h"
|
|
#include "ReportsPageStatistics.h"
|
|
#ifdef KPXC_FEATURE_BROWSER
|
|
#include "ReportsPageBrowserStatistics.h"
|
|
#include "ReportsWidgetBrowserStatistics.h"
|
|
#endif
|
|
#ifdef KPXC_FEATURE_BROWSER_PASSKEYS
|
|
#include "ReportsPagePasskeys.h"
|
|
#include "ReportsWidgetPasskeys.h"
|
|
#endif
|
|
#include "ReportsWidgetHealthcheck.h"
|
|
#include "ReportsWidgetHibp.h"
|
|
|
|
#include "core/Global.h"
|
|
#include "core/Group.h"
|
|
|
|
class ReportsDialog::ExtraPage
|
|
{
|
|
public:
|
|
ExtraPage(QSharedPointer<IReportsPage> p, QWidget* w)
|
|
: page(p)
|
|
, widget(w)
|
|
{
|
|
}
|
|
void loadSettings(QSharedPointer<Database> db) const
|
|
{
|
|
page->loadSettings(widget, db);
|
|
}
|
|
void saveSettings() const
|
|
{
|
|
page->saveSettings(widget);
|
|
}
|
|
|
|
private:
|
|
QSharedPointer<IReportsPage> page;
|
|
QWidget* widget;
|
|
};
|
|
|
|
ReportsDialog::ReportsDialog(QWidget* parent)
|
|
: DialogyWidget(parent)
|
|
, m_ui(new Ui::ReportsDialog())
|
|
, m_healthPage(new ReportsPageHealthcheck())
|
|
, m_hibpPage(new ReportsPageHibp())
|
|
, m_statPage(new ReportsPageStatistics())
|
|
#ifdef KPXC_FEATURE_BROWSER
|
|
, m_browserStatPage(new ReportsPageBrowserStatistics())
|
|
#endif
|
|
#ifdef KPXC_FEATURE_BROWSER_PASSKEYS
|
|
, m_passkeysPage(new ReportsPagePasskeys())
|
|
#endif
|
|
, m_editEntryWidget(new EditEntryWidget(this))
|
|
{
|
|
m_ui->setupUi(this);
|
|
|
|
connect(m_ui->buttonBox, SIGNAL(rejected()), SLOT(reject()));
|
|
addPage(m_statPage);
|
|
addPage(m_healthPage);
|
|
#ifdef KPXC_FEATURE_BROWSER_PASSKEYS
|
|
addPage(m_passkeysPage);
|
|
#endif
|
|
#ifdef KPXC_FEATURE_BROWSER
|
|
addPage(m_browserStatPage);
|
|
#endif
|
|
addPage(m_hibpPage);
|
|
|
|
m_ui->stackedWidget->setCurrentIndex(0);
|
|
|
|
m_editEntryWidget->setObjectName("editEntryWidget");
|
|
m_editEntryWidget->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
|
|
m_ui->stackedWidget->addWidget(m_editEntryWidget);
|
|
adjustSize();
|
|
|
|
connect(m_ui->categoryList, SIGNAL(categoryChanged(int)), m_ui->stackedWidget, SLOT(setCurrentIndex(int)));
|
|
connect(m_healthPage->m_healthWidget, SIGNAL(entryActivated(Entry*)), SLOT(entryActivationSignalReceived(Entry*)));
|
|
connect(m_hibpPage->m_hibpWidget, SIGNAL(entryActivated(Entry*)), SLOT(entryActivationSignalReceived(Entry*)));
|
|
#ifdef KPXC_FEATURE_BROWSER
|
|
connect(m_browserStatPage->m_browserWidget,
|
|
SIGNAL(entryActivated(Entry*)),
|
|
SLOT(entryActivationSignalReceived(Entry*)));
|
|
#endif
|
|
#ifdef KPXC_FEATURE_BROWSER_PASSKEYS
|
|
connect(
|
|
m_passkeysPage->m_passkeysWidget, SIGNAL(entryActivated(Entry*)), SLOT(entryActivationSignalReceived(Entry*)));
|
|
#endif
|
|
connect(m_editEntryWidget, SIGNAL(editFinished(bool)), SLOT(switchToMainView(bool)));
|
|
}
|
|
|
|
ReportsDialog::~ReportsDialog() = default;
|
|
|
|
void ReportsDialog::load(const QSharedPointer<Database>& db)
|
|
{
|
|
m_ui->categoryList->setCurrentCategory(0);
|
|
for (const ExtraPage& page : asConst(m_extraPages)) {
|
|
page.loadSettings(db);
|
|
}
|
|
m_db = db;
|
|
}
|
|
|
|
void ReportsDialog::addPage(QSharedPointer<IReportsPage> page)
|
|
{
|
|
const auto category = m_ui->categoryList->currentCategory();
|
|
const auto 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);
|
|
}
|
|
|
|
#ifdef KPXC_FEATURE_BROWSER_PASSKEYS
|
|
void ReportsDialog::activatePasskeysPage()
|
|
{
|
|
m_ui->stackedWidget->setCurrentWidget(m_passkeysPage->m_passkeysWidget);
|
|
auto index = m_ui->stackedWidget->currentIndex();
|
|
m_ui->categoryList->setCurrentCategory(index);
|
|
}
|
|
#endif
|
|
|
|
void ReportsDialog::reject()
|
|
{
|
|
emit editFinished(true);
|
|
}
|
|
|
|
void ReportsDialog::entryActivationSignalReceived(Entry* entry)
|
|
{
|
|
m_sender = static_cast<QWidget*>(sender());
|
|
m_editEntryWidget->loadEntry(entry, false, false, entry->group()->hierarchy().join(" > "), m_db);
|
|
m_ui->stackedWidget->setCurrentWidget(m_editEntryWidget);
|
|
}
|
|
|
|
void ReportsDialog::switchToMainView(bool previousDialogAccepted)
|
|
{
|
|
// Sanity check
|
|
if (!m_sender) {
|
|
return;
|
|
}
|
|
|
|
// Return to the previous widget
|
|
m_ui->stackedWidget->setCurrentWidget(m_sender);
|
|
|
|
// If "OK" was clicked, and if we came from the Health Check pane,
|
|
// re-compute Health Check
|
|
if (previousDialogAccepted) {
|
|
if (m_sender == m_healthPage->m_healthWidget) {
|
|
m_healthPage->m_healthWidget->calculateHealth();
|
|
} else if (m_sender == m_hibpPage->m_hibpWidget) {
|
|
m_hibpPage->m_hibpWidget->refreshAfterEdit();
|
|
}
|
|
#ifdef KPXC_FEATURE_BROWSER
|
|
if (m_sender == m_browserStatPage->m_browserWidget) {
|
|
m_browserStatPage->m_browserWidget->calculateBrowserStatistics();
|
|
}
|
|
#endif
|
|
#ifdef KPXC_FEATURE_BROWSER_PASSKEYS
|
|
if (m_sender == m_passkeysPage->m_passkeysWidget) {
|
|
m_passkeysPage->m_passkeysWidget->updateEntries();
|
|
}
|
|
#endif
|
|
}
|
|
|
|
// Don't process the same sender twice
|
|
m_sender = nullptr;
|
|
}
|