mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-10-01 01:26:01 -04:00
Allow deleting extension plugin data from Browser Statistics
This commit is contained in:
parent
3c05dd248d
commit
2f0160438a
@ -8902,6 +8902,17 @@ This option is deprecated, use --set-key-file instead.</source>
|
||||
<source>Cannot generate valid passphrases because the wordlist is too short</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Delete plugin data?</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message numerus="yes">
|
||||
<source>Delete plugin data from Entry(s)?</source>
|
||||
<translation type="unfinished">
|
||||
<numerusform></numerusform>
|
||||
<numerusform></numerusform>
|
||||
</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>QtIOCompressor</name>
|
||||
@ -9053,6 +9064,13 @@ This option is deprecated, use --set-key-file instead.</source>
|
||||
<source> (Expired)</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message numerus="yes">
|
||||
<source>Delete plugin data from Entry(s)…</source>
|
||||
<translation type="unfinished">
|
||||
<numerusform></numerusform>
|
||||
<numerusform></numerusform>
|
||||
</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ReportsWidgetHealthcheck</name>
|
||||
|
@ -977,6 +977,15 @@ bool BrowserService::deleteEntry(const QString& uuid)
|
||||
return true;
|
||||
}
|
||||
|
||||
void BrowserService::removePluginData(Entry* entry) const
|
||||
{
|
||||
if (entry) {
|
||||
entry->beginUpdate();
|
||||
entry->customData()->remove(BrowserService::KEEPASSXCBROWSER_NAME);
|
||||
entry->endUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
QList<Entry*> BrowserService::searchEntries(const QSharedPointer<Database>& db,
|
||||
const QString& siteUrl,
|
||||
const QString& formUrl,
|
||||
|
@ -118,6 +118,7 @@ public:
|
||||
const QSharedPointer<Database>& selectedDb = {});
|
||||
bool updateEntry(const EntryParameters& entryParameters, const QString& uuid);
|
||||
bool deleteEntry(const QString& uuid);
|
||||
void removePluginData(Entry* entry) const;
|
||||
QJsonArray findEntries(const EntryParameters& entryParameters, const StringPairList& keyList, bool* entriesFound);
|
||||
void requestGlobalAutoType(const QString& search);
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021 KeePassXC Team <team@keepassxc.org>
|
||||
* Copyright (C) 2024 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
|
||||
@ -66,6 +66,21 @@ namespace GuiTools
|
||||
}
|
||||
}
|
||||
|
||||
bool confirmDeletePluginData(QWidget* parent, const QList<Entry*>& entries)
|
||||
{
|
||||
if (!parent || entries.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
auto answer = MessageBox::question(parent,
|
||||
QObject::tr("Delete plugin data?"),
|
||||
QObject::tr("Delete plugin data from Entry(s)?", "", entries.size()),
|
||||
MessageBox::Delete | MessageBox::Cancel,
|
||||
MessageBox::Cancel);
|
||||
|
||||
return answer == MessageBox::Delete;
|
||||
}
|
||||
|
||||
size_t deleteEntriesResolveReferences(QWidget* parent, const QList<Entry*>& entries, bool permanent)
|
||||
{
|
||||
if (!parent || entries.isEmpty()) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021 KeePassXC Team <team@keepassxc.org>
|
||||
* Copyright (C) 2024 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
|
||||
@ -26,6 +26,7 @@ class Entry;
|
||||
namespace GuiTools
|
||||
{
|
||||
bool confirmDeleteEntries(QWidget* parent, const QList<Entry*>& entries, bool permanent);
|
||||
bool confirmDeletePluginData(QWidget* parent, const QList<Entry*>& entries);
|
||||
size_t deleteEntriesResolveReferences(QWidget* parent, const QList<Entry*>& entries, bool permanent);
|
||||
} // namespace GuiTools
|
||||
#endif // KEEPASSXC_GUITOOLS_H
|
||||
|
@ -214,9 +214,7 @@ void DatabaseSettingsWidgetBrowser::removeStoredPermissions()
|
||||
}
|
||||
|
||||
if (entry->customData()->contains(BrowserService::KEEPASSXCBROWSER_NAME)) {
|
||||
entry->beginUpdate();
|
||||
entry->customData()->remove(BrowserService::KEEPASSXCBROWSER_NAME);
|
||||
entry->endUpdate();
|
||||
browserService()->removePluginData(entry);
|
||||
++counter;
|
||||
}
|
||||
progress.setValue(progress.value() + 1);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021 KeePassXC Team <team@keepassxc.org>
|
||||
* Copyright (C) 2024 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
|
||||
@ -27,7 +27,6 @@
|
||||
#include "gui/styles/StateColorPalette.h"
|
||||
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QMenu>
|
||||
#include <QShortcut>
|
||||
#include <QSortFilterProxyModel>
|
||||
@ -277,9 +276,19 @@ void ReportsWidgetBrowserStatistics::customMenuRequested(QPoint pos)
|
||||
}
|
||||
|
||||
// Create the "delete entry" menu item
|
||||
const auto delEntry = new QAction(icons()->icon("entry-delete"), tr("Delete Entry(s)…", "", selected.size()), this);
|
||||
menu->addAction(delEntry);
|
||||
connect(delEntry, &QAction::triggered, this, &ReportsWidgetBrowserStatistics::deleteSelectedEntries);
|
||||
const auto deleteEntry =
|
||||
new QAction(icons()->icon("entry-delete"), tr("Delete Entry(s)…", "", selected.size()), this);
|
||||
menu->addAction(deleteEntry);
|
||||
connect(deleteEntry, &QAction::triggered, this, &ReportsWidgetBrowserStatistics::deleteSelectedEntries);
|
||||
|
||||
// Create the "delete plugin data" menu item
|
||||
const auto deletePluginData =
|
||||
new QAction(icons()->icon("entry-delete"), tr("Delete plugin data from Entry(s)…", "", selected.size()), this);
|
||||
menu->addAction(deletePluginData);
|
||||
connect(deletePluginData,
|
||||
&QAction::triggered,
|
||||
this,
|
||||
&ReportsWidgetBrowserStatistics::deletePluginDataFromSelectedEntries);
|
||||
|
||||
// Create the "exclude from reports" menu item
|
||||
const auto exclude = new QAction(icons()->icon("reports-exclude"), tr("Exclude from reports"), this);
|
||||
@ -320,16 +329,9 @@ void ReportsWidgetBrowserStatistics::saveSettings()
|
||||
|
||||
void ReportsWidgetBrowserStatistics::deleteSelectedEntries()
|
||||
{
|
||||
QList<Entry*> selectedEntries;
|
||||
for (auto index : m_ui->browserStatisticsTableView->selectionModel()->selectedRows()) {
|
||||
auto row = m_modelProxy->mapToSource(index).row();
|
||||
auto entry = m_rowToEntry[row].second;
|
||||
if (entry) {
|
||||
selectedEntries << entry;
|
||||
}
|
||||
}
|
||||
|
||||
const auto& selectedEntries = getSelectedEntries();
|
||||
bool permanent = !m_db->metadata()->recycleBinEnabled();
|
||||
|
||||
if (GuiTools::confirmDeleteEntries(this, selectedEntries, permanent)) {
|
||||
GuiTools::deleteEntriesResolveReferences(this, selectedEntries, permanent);
|
||||
}
|
||||
@ -337,6 +339,18 @@ void ReportsWidgetBrowserStatistics::deleteSelectedEntries()
|
||||
calculateBrowserStatistics();
|
||||
}
|
||||
|
||||
void ReportsWidgetBrowserStatistics::deletePluginDataFromSelectedEntries()
|
||||
{
|
||||
const auto& selectedEntries = getSelectedEntries();
|
||||
if (GuiTools::confirmDeletePluginData(this, selectedEntries)) {
|
||||
for (auto& entry : selectedEntries) {
|
||||
browserService()->removePluginData(entry);
|
||||
}
|
||||
}
|
||||
|
||||
calculateBrowserStatistics();
|
||||
}
|
||||
|
||||
QMap<QString, QStringList> ReportsWidgetBrowserStatistics::getBrowserConfigFromEntry(Entry* entry) const
|
||||
{
|
||||
QMap<QString, QStringList> configList;
|
||||
@ -372,3 +386,17 @@ QMap<QString, QStringList> ReportsWidgetBrowserStatistics::getBrowserConfigFromE
|
||||
|
||||
return configList;
|
||||
}
|
||||
|
||||
QList<Entry*> ReportsWidgetBrowserStatistics::getSelectedEntries() const
|
||||
{
|
||||
QList<Entry*> selectedEntries;
|
||||
for (auto index : m_ui->browserStatisticsTableView->selectionModel()->selectedRows()) {
|
||||
auto row = m_modelProxy->mapToSource(index).row();
|
||||
auto entry = m_rowToEntry[row].second;
|
||||
if (entry) {
|
||||
selectedEntries << entry;
|
||||
}
|
||||
}
|
||||
|
||||
return selectedEntries;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021 KeePassXC Team <team@keepassxc.org>
|
||||
* Copyright (C) 2024 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
|
||||
@ -54,9 +54,11 @@ public slots:
|
||||
void emitEntryActivated(const QModelIndex& index);
|
||||
void customMenuRequested(QPoint);
|
||||
void deleteSelectedEntries();
|
||||
void deletePluginDataFromSelectedEntries();
|
||||
|
||||
private:
|
||||
void addStatisticsRow(bool hasUrls, bool hasSettings, Group*, Entry*, bool);
|
||||
QList<Entry*> getSelectedEntries() const;
|
||||
QMap<QString, QStringList> getBrowserConfigFromEntry(Entry* entry) const;
|
||||
|
||||
QScopedPointer<Ui::ReportsWidgetBrowserStatistics> m_ui;
|
||||
|
Loading…
Reference in New Issue
Block a user