mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-03-12 17:16:43 -04:00
Add ability to expire entries from context menus (#8731)
Closes #1972 Add ability to immediately expire an entry from the context menu --------- Co-authored-by: Jonathan White <support@dmapps.us>
This commit is contained in:
parent
abf5a2ef8b
commit
fbad1b51f0
1
COPYING
1
COPYING
@ -178,6 +178,7 @@ Files: share/icons/application/scalable/actions/application-exit.svg
|
||||
share/icons/application/scalable/actions/entry-delete.svg
|
||||
share/icons/application/scalable/actions/entry-restore.svg
|
||||
share/icons/application/scalable/actions/entry-edit.svg
|
||||
share/icons/application/scalable/actions/entry-expire.svg
|
||||
share/icons/application/scalable/actions/entry-new.svg
|
||||
share/icons/application/scalable/actions/favicon-download.svg
|
||||
share/icons/application/scalable/actions/fingerprint.svg
|
||||
|
@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M9 8H11V14H9V8M13 1H7V3H13V1M17.03 7.39C18.26 8.93 19 10.88 19 13C19 17.97 15 22 10 22C5.03 22 1 17.97 1 13S5.03 4 10 4C12.12 4 14.07 4.74 15.62 6L17.04 4.56C17.55 5 18 5.46 18.45 5.97L17.03 7.39M17 13C17 9.13 13.87 6 10 6S3 9.13 3 13 6.13 20 10 20 17 16.87 17 13M21 7V13H23V7H21M21 17H23V15H21V17Z" /></svg>
|
After Width: | Height: | Size: 377 B |
@ -40,6 +40,7 @@
|
||||
<file>application/scalable/actions/edit-clear-locationbar-rtl.svg</file>
|
||||
<file>application/scalable/actions/entry-clone.svg</file>
|
||||
<file>application/scalable/actions/entry-delete.svg</file>
|
||||
<file>application/scalable/actions/entry-expire.svg</file>
|
||||
<file>application/scalable/actions/entry-restore.svg</file>
|
||||
<file>application/scalable/actions/entry-edit.svg</file>
|
||||
<file>application/scalable/actions/entry-new.svg</file>
|
||||
|
@ -5836,10 +5836,6 @@ We recommend you use the AppImage available on our downloads page.</source>
|
||||
<numerusform></numerusform>
|
||||
</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Copy Password and TOTP</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>&XML File…</source>
|
||||
<translation type="unfinished"></translation>
|
||||
@ -5868,10 +5864,6 @@ We recommend you use the AppImage available on our downloads page.</source>
|
||||
<source>No Tags</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Toggle Show Menubar</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Remove Passkey From Entry</source>
|
||||
<translation type="unfinished"></translation>
|
||||
@ -5880,6 +5872,10 @@ We recommend you use the AppImage available on our downloads page.</source>
|
||||
<source>Empty Recycle Bin</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Toggle Show Menubar</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Show Group Panel</source>
|
||||
<translation type="unfinished"></translation>
|
||||
@ -5892,6 +5888,14 @@ We recommend you use the AppImage available on our downloads page.</source>
|
||||
<source>Password Generator</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>E&xpire Entry…</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Copy Password and TOTP</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ManageDatabase</name>
|
||||
@ -8833,6 +8837,13 @@ This option is deprecated, use --set-key-file instead.</source>
|
||||
<source>Exclude from reports</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message numerus="yes">
|
||||
<source>Expire Entry(s)…</source>
|
||||
<translation type="unfinished">
|
||||
<numerusform></numerusform>
|
||||
<numerusform></numerusform>
|
||||
</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Only show entries that have a URL</source>
|
||||
<translation type="unfinished"></translation>
|
||||
@ -8859,6 +8870,14 @@ This option is deprecated, use --set-key-file instead.</source>
|
||||
</context>
|
||||
<context>
|
||||
<name>ReportsWidgetHealthcheck</name>
|
||||
<message>
|
||||
<source>Show expired entries</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source> (Expired)</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Hover over reason to show additional details. Double-click entries to edit.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
@ -8922,18 +8941,17 @@ This option is deprecated, use --set-key-file instead.</source>
|
||||
<source>Exclude from reports</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Show expired entries</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<message numerus="yes">
|
||||
<source>Expire Entry(s)…</source>
|
||||
<translation type="unfinished">
|
||||
<numerusform></numerusform>
|
||||
<numerusform></numerusform>
|
||||
</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Show entries that have been excluded from reports</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source> (Expired)</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ReportsWidgetHibp</name>
|
||||
@ -9032,6 +9050,13 @@ This option is deprecated, use --set-key-file instead.</source>
|
||||
<source>Exclude from reports</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message numerus="yes">
|
||||
<source>Expire Entry(s)…</source>
|
||||
<translation type="unfinished">
|
||||
<numerusform></numerusform>
|
||||
<numerusform></numerusform>
|
||||
</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ReportsWidgetPasskeys</name>
|
||||
|
@ -459,6 +459,12 @@ bool Entry::willExpireInDays(int days) const
|
||||
return m_data.timeInfo.expires() && m_data.timeInfo.expiryTime() < Clock::currentDateTime().addDays(days);
|
||||
}
|
||||
|
||||
void Entry::expireNow()
|
||||
{
|
||||
setExpiryTime(Clock::currentDateTimeUtc());
|
||||
setExpires(true);
|
||||
}
|
||||
|
||||
bool Entry::isRecycled() const
|
||||
{
|
||||
const Database* db = database();
|
||||
|
@ -126,6 +126,7 @@ public:
|
||||
bool hasTotp() const;
|
||||
bool isExpired() const;
|
||||
bool willExpireInDays(int days) const;
|
||||
void expireNow();
|
||||
bool isRecycled() const;
|
||||
bool isAttributeReference(const QString& key) const;
|
||||
bool isAttributeReferenceOf(const QString& key, const QUuid& uuid) const;
|
||||
|
@ -564,6 +564,17 @@ void DatabaseWidget::setupTotp()
|
||||
setupTotpDialog->open();
|
||||
}
|
||||
|
||||
void DatabaseWidget::expireSelectedEntries()
|
||||
{
|
||||
const QModelIndexList selected = m_entryView->selectionModel()->selectedRows();
|
||||
for (const auto& index : selected) {
|
||||
auto entry = m_entryView->entryFromIndex(index);
|
||||
if (entry) {
|
||||
entry->expireNow();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DatabaseWidget::deleteSelectedEntries()
|
||||
{
|
||||
const QModelIndexList selected = m_entryView->selectionModel()->selectedRows();
|
||||
|
@ -167,6 +167,7 @@ public slots:
|
||||
void replaceDatabase(QSharedPointer<Database> db);
|
||||
void createEntry();
|
||||
void cloneEntry();
|
||||
void expireSelectedEntries();
|
||||
void deleteSelectedEntries();
|
||||
void restoreSelectedEntries();
|
||||
void deleteEntries(QList<Entry*> entries, bool confirm = true);
|
||||
|
@ -143,6 +143,7 @@ MainWindow::MainWindow()
|
||||
m_entryContextMenu->addSeparator();
|
||||
#endif
|
||||
m_entryContextMenu->addAction(m_ui->actionEntryEdit);
|
||||
m_entryContextMenu->addAction(m_ui->actionEntryExpire);
|
||||
m_entryContextMenu->addAction(m_ui->actionEntryClone);
|
||||
m_entryContextMenu->addAction(m_ui->actionEntryDelete);
|
||||
m_entryContextMenu->addAction(m_ui->actionEntryNew);
|
||||
@ -311,6 +312,7 @@ MainWindow::MainWindow()
|
||||
// Unfortunately, Qt::AA_DontShowShortcutsInContextMenus is broken, have to manually enable them
|
||||
m_ui->actionEntryNew->setShortcutVisibleInContextMenu(true);
|
||||
m_ui->actionEntryEdit->setShortcutVisibleInContextMenu(true);
|
||||
m_ui->actionEntryExpire->setShortcutVisibleInContextMenu(true);
|
||||
m_ui->actionEntryDelete->setShortcutVisibleInContextMenu(true);
|
||||
m_ui->actionEntryRestore->setShortcutVisibleInContextMenu(true);
|
||||
m_ui->actionEntryClone->setShortcutVisibleInContextMenu(true);
|
||||
@ -407,6 +409,7 @@ MainWindow::MainWindow()
|
||||
m_ui->actionEntryNew->setIcon(icons()->icon("entry-new"));
|
||||
m_ui->actionEntryClone->setIcon(icons()->icon("entry-clone"));
|
||||
m_ui->actionEntryEdit->setIcon(icons()->icon("entry-edit"));
|
||||
m_ui->actionEntryExpire->setIcon(icons()->icon("entry-expire"));
|
||||
m_ui->actionEntryDelete->setIcon(icons()->icon("entry-delete"));
|
||||
m_ui->actionEntryRestore->setIcon(icons()->icon("entry-restore"));
|
||||
m_ui->actionEntryAutoType->setIcon(icons()->icon("auto-type"));
|
||||
@ -524,8 +527,9 @@ MainWindow::MainWindow()
|
||||
connect(m_ui->actionQuit, SIGNAL(triggered()), SLOT(appExit()));
|
||||
|
||||
m_actionMultiplexer.connect(m_ui->actionEntryNew, SIGNAL(triggered()), SLOT(createEntry()));
|
||||
m_actionMultiplexer.connect(m_ui->actionEntryClone, SIGNAL(triggered()), SLOT(cloneEntry()));
|
||||
m_actionMultiplexer.connect(m_ui->actionEntryEdit, SIGNAL(triggered()), SLOT(switchToEntryEdit()));
|
||||
m_actionMultiplexer.connect(m_ui->actionEntryExpire, SIGNAL(triggered()), SLOT(expireSelectedEntries()));
|
||||
m_actionMultiplexer.connect(m_ui->actionEntryClone, SIGNAL(triggered()), SLOT(cloneEntry()));
|
||||
m_actionMultiplexer.connect(m_ui->actionEntryDelete, SIGNAL(triggered()), SLOT(deleteSelectedEntries()));
|
||||
m_actionMultiplexer.connect(m_ui->actionEntryRestore, SIGNAL(triggered()), SLOT(restoreSelectedEntries()));
|
||||
|
||||
@ -952,6 +956,7 @@ void MainWindow::updateMenuActionState()
|
||||
m_ui->actionEntryNew->setEnabled(inDatabase && !inRecycleBin);
|
||||
m_ui->actionEntryClone->setEnabled(singleEntrySelected && !inRecycleBin);
|
||||
m_ui->actionEntryEdit->setEnabled(singleEntrySelected);
|
||||
m_ui->actionEntryExpire->setEnabled(multiEntrySelected);
|
||||
m_ui->actionEntryDelete->setEnabled(multiEntrySelected);
|
||||
m_ui->actionEntryRestore->setVisible(multiEntrySelected && inRecycleBin);
|
||||
m_ui->actionEntryRestore->setEnabled(multiEntrySelected && inRecycleBin);
|
||||
|
@ -314,6 +314,7 @@
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionEntryNew"/>
|
||||
<addaction name="actionEntryEdit"/>
|
||||
<addaction name="actionEntryExpire"/>
|
||||
<addaction name="actionEntryClone"/>
|
||||
<addaction name="actionEntryDelete"/>
|
||||
<addaction name="separator"/>
|
||||
@ -507,6 +508,14 @@
|
||||
<string>View or edit entry</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionEntryExpire">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>E&xpire Entry…</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionEntryDelete">
|
||||
<property name="text">
|
||||
<string>&Delete Entry…</string>
|
||||
|
@ -275,6 +275,11 @@ void ReportsWidgetBrowserStatistics::customMenuRequested(QPoint pos)
|
||||
});
|
||||
}
|
||||
|
||||
// Create the "expire entry" menu item
|
||||
const auto expEntry = new QAction(icons()->icon("entry-expire"), tr("Expire Entry(s)…", "", selected.size()), this);
|
||||
menu->addAction(expEntry);
|
||||
connect(expEntry, &QAction::triggered, this, &ReportsWidgetBrowserStatistics::expireSelectedEntries);
|
||||
|
||||
// Create the "delete entry" menu item
|
||||
const auto deleteEntry =
|
||||
new QAction(icons()->icon("entry-delete"), tr("Delete Entry(s)…", "", selected.size()), this);
|
||||
@ -327,6 +332,28 @@ void ReportsWidgetBrowserStatistics::saveSettings()
|
||||
// Nothing to do - the tab is passive
|
||||
}
|
||||
|
||||
QList<Entry*> ReportsWidgetBrowserStatistics::getSelectedEntries()
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
void ReportsWidgetBrowserStatistics::expireSelectedEntries()
|
||||
{
|
||||
for (auto entry : getSelectedEntries()) {
|
||||
entry->expireNow();
|
||||
}
|
||||
|
||||
calculateBrowserStatistics();
|
||||
}
|
||||
|
||||
void ReportsWidgetBrowserStatistics::deleteSelectedEntries()
|
||||
{
|
||||
const auto& selectedEntries = getSelectedEntries();
|
||||
|
@ -53,6 +53,8 @@ public slots:
|
||||
void calculateBrowserStatistics();
|
||||
void emitEntryActivated(const QModelIndex& index);
|
||||
void customMenuRequested(QPoint);
|
||||
QList<Entry*> getSelectedEntries();
|
||||
void expireSelectedEntries();
|
||||
void deleteSelectedEntries();
|
||||
void deletePluginDataFromSelectedEntries();
|
||||
|
||||
|
@ -325,6 +325,11 @@ void ReportsWidgetHealthcheck::customMenuRequested(QPoint pos)
|
||||
});
|
||||
}
|
||||
|
||||
// Create the "Expire entry" menu item
|
||||
const auto expEntry = new QAction(icons()->icon("entry-expire"), tr("Expire Entry(s)…", "", selected.size()), this);
|
||||
menu->addAction(expEntry);
|
||||
connect(expEntry, &QAction::triggered, this, &ReportsWidgetHealthcheck::expireSelectedEntries);
|
||||
|
||||
// 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);
|
||||
@ -367,7 +372,7 @@ void ReportsWidgetHealthcheck::saveSettings()
|
||||
// nothing to do - the tab is passive
|
||||
}
|
||||
|
||||
void ReportsWidgetHealthcheck::deleteSelectedEntries()
|
||||
QList<Entry*> ReportsWidgetHealthcheck::getSelectedEntries()
|
||||
{
|
||||
QList<Entry*> selectedEntries;
|
||||
for (auto index : m_ui->healthcheckTableView->selectionModel()->selectedRows()) {
|
||||
@ -377,7 +382,21 @@ void ReportsWidgetHealthcheck::deleteSelectedEntries()
|
||||
selectedEntries << entry;
|
||||
}
|
||||
}
|
||||
return selectedEntries;
|
||||
}
|
||||
|
||||
void ReportsWidgetHealthcheck::expireSelectedEntries()
|
||||
{
|
||||
for (auto entry : getSelectedEntries()) {
|
||||
entry->expireNow();
|
||||
}
|
||||
|
||||
calculateHealth();
|
||||
}
|
||||
|
||||
void ReportsWidgetHealthcheck::deleteSelectedEntries()
|
||||
{
|
||||
QList<Entry*> selectedEntries = getSelectedEntries();
|
||||
bool permanent = !m_db->metadata()->recycleBinEnabled();
|
||||
if (GuiTools::confirmDeleteEntries(this, selectedEntries, permanent)) {
|
||||
GuiTools::deleteEntriesResolveReferences(this, selectedEntries, permanent);
|
||||
|
@ -53,6 +53,8 @@ public slots:
|
||||
void calculateHealth();
|
||||
void emitEntryActivated(const QModelIndex& index);
|
||||
void customMenuRequested(QPoint);
|
||||
QList<Entry*> getSelectedEntries();
|
||||
void expireSelectedEntries();
|
||||
void deleteSelectedEntries();
|
||||
|
||||
private:
|
||||
|
@ -374,6 +374,11 @@ void ReportsWidgetHibp::customMenuRequested(QPoint pos)
|
||||
});
|
||||
}
|
||||
|
||||
// Create the "Expire entry" menu item
|
||||
const auto expEntry = new QAction(icons()->icon("entry-expire"), tr("Expire Entry(s)…", "", selected.size()), this);
|
||||
menu->addAction(expEntry);
|
||||
connect(expEntry, &QAction::triggered, this, &ReportsWidgetHibp::expireSelectedEntries);
|
||||
|
||||
// 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);
|
||||
@ -411,7 +416,7 @@ void ReportsWidgetHibp::customMenuRequested(QPoint pos)
|
||||
menu->popup(m_ui->hibpTableView->viewport()->mapToGlobal(pos));
|
||||
}
|
||||
|
||||
void ReportsWidgetHibp::deleteSelectedEntries()
|
||||
QList<Entry*> ReportsWidgetHibp::getSelectedEntries()
|
||||
{
|
||||
QList<Entry*> selectedEntries;
|
||||
for (auto index : m_ui->hibpTableView->selectionModel()->selectedRows()) {
|
||||
@ -421,7 +426,21 @@ void ReportsWidgetHibp::deleteSelectedEntries()
|
||||
selectedEntries << entry;
|
||||
}
|
||||
}
|
||||
return selectedEntries;
|
||||
}
|
||||
|
||||
void ReportsWidgetHibp::expireSelectedEntries()
|
||||
{
|
||||
for (auto entry : getSelectedEntries()) {
|
||||
entry->expireNow();
|
||||
}
|
||||
|
||||
makeHibpTable();
|
||||
}
|
||||
|
||||
void ReportsWidgetHibp::deleteSelectedEntries()
|
||||
{
|
||||
QList<Entry*> selectedEntries = getSelectedEntries();
|
||||
bool permanent = !m_db->metadata()->recycleBinEnabled();
|
||||
if (GuiTools::confirmDeleteEntries(this, selectedEntries, permanent)) {
|
||||
GuiTools::deleteEntriesResolveReferences(this, selectedEntries, permanent);
|
||||
|
@ -58,6 +58,8 @@ public slots:
|
||||
void fetchFailed(const QString& error);
|
||||
void makeHibpTable();
|
||||
void customMenuRequested(QPoint);
|
||||
QList<Entry*> getSelectedEntries();
|
||||
void expireSelectedEntries();
|
||||
void deleteSelectedEntries();
|
||||
|
||||
private:
|
||||
|
Loading…
x
Reference in New Issue
Block a user