mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-10-01 01:26:01 -04:00
Add context menu entry to clean the Recycle Bin in databases
This implements the feature request (issue) #503.
This commit is contained in:
parent
b01953a5a3
commit
dea65b637c
BIN
share/icons/application/16x16/actions/group-empty-trash.png
Normal file
BIN
share/icons/application/16x16/actions/group-empty-trash.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
@ -1267,3 +1267,38 @@ void DatabaseWidget::hideMessage()
|
||||
m_messageWidget->animatedHide();
|
||||
}
|
||||
}
|
||||
|
||||
bool DatabaseWidget::isRecycleBinSelected() const
|
||||
{
|
||||
return m_groupView->currentGroup() && m_groupView->currentGroup() == m_db->metadata()->recycleBin();
|
||||
}
|
||||
|
||||
void DatabaseWidget::emptyTrash()
|
||||
{
|
||||
Group* currentGroup = m_groupView->currentGroup();
|
||||
if (!currentGroup) {
|
||||
Q_ASSERT(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (currentGroup == m_db->metadata()->recycleBin()) {
|
||||
QMessageBox::StandardButton result = MessageBox::question(
|
||||
this, tr("Empty recycle bin?"),
|
||||
tr("Are you sure you want to permanently delete everytning from your recycle bin?"),
|
||||
QMessageBox::Yes | QMessageBox::No);
|
||||
|
||||
if (result == QMessageBox::Yes) {
|
||||
// destroying direct entries of the recycle bin
|
||||
QList<Entry*> subEntries = currentGroup->entries();
|
||||
for (Entry* entry : subEntries) {
|
||||
delete entry;
|
||||
}
|
||||
// destroying direct subgroups of the recycle bin
|
||||
QList<Group*> subGroups = currentGroup->children();
|
||||
for (Group* group : subGroups) {
|
||||
delete group;
|
||||
}
|
||||
refreshSearch();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -102,6 +102,7 @@ public:
|
||||
void closeUnlockDialog();
|
||||
void blockAutoReload(bool block = true);
|
||||
void refreshSearch();
|
||||
bool isRecycleBinSelected() const;
|
||||
|
||||
signals:
|
||||
void closeRequest();
|
||||
@ -152,6 +153,7 @@ public slots:
|
||||
void switchToImportKeepass1(const QString& fileName);
|
||||
void databaseModified();
|
||||
void databaseSaved();
|
||||
void emptyTrash();
|
||||
|
||||
// Search related slots
|
||||
void search(const QString& searchtext);
|
||||
|
@ -197,6 +197,7 @@ MainWindow::MainWindow()
|
||||
m_ui->actionGroupNew->setIcon(filePath()->icon("actions", "group-new", false));
|
||||
m_ui->actionGroupEdit->setIcon(filePath()->icon("actions", "group-edit", false));
|
||||
m_ui->actionGroupDelete->setIcon(filePath()->icon("actions", "group-delete", false));
|
||||
m_ui->actionGroupEmptyTrash->setIcon(filePath()->icon("actions", "group-empty-trash", false));
|
||||
|
||||
m_ui->actionSettings->setIcon(filePath()->icon("actions", "configure"));
|
||||
m_ui->actionSettings->setMenuRole(QAction::PreferencesRole);
|
||||
@ -295,6 +296,8 @@ MainWindow::MainWindow()
|
||||
SLOT(switchToGroupEdit()));
|
||||
m_actionMultiplexer.connect(m_ui->actionGroupDelete, SIGNAL(triggered()),
|
||||
SLOT(deleteGroup()));
|
||||
m_actionMultiplexer.connect(m_ui->actionGroupEmptyTrash, SIGNAL(triggered()),
|
||||
SLOT(emptyTrash()));
|
||||
|
||||
connect(m_ui->actionSettings, SIGNAL(triggered()), SLOT(switchToSettings()));
|
||||
connect(m_ui->actionPasswordGenerator, SIGNAL(toggled(bool)), SLOT(switchToPasswordGen(bool)));
|
||||
@ -413,6 +416,7 @@ void MainWindow::setMenuActionState(DatabaseWidget::Mode mode)
|
||||
bool singleEntrySelected = dbWidget->numberOfSelectedEntries() == 1;
|
||||
bool entriesSelected = dbWidget->numberOfSelectedEntries() > 0;
|
||||
bool groupSelected = dbWidget->isGroupSelected();
|
||||
bool recycleBinSelected = dbWidget->isRecycleBinSelected();
|
||||
|
||||
m_ui->actionEntryNew->setEnabled(!inSearch);
|
||||
m_ui->actionEntryClone->setEnabled(singleEntrySelected);
|
||||
@ -429,6 +433,8 @@ void MainWindow::setMenuActionState(DatabaseWidget::Mode mode)
|
||||
m_ui->actionGroupNew->setEnabled(groupSelected);
|
||||
m_ui->actionGroupEdit->setEnabled(groupSelected);
|
||||
m_ui->actionGroupDelete->setEnabled(groupSelected && dbWidget->canDeleteCurrentGroup());
|
||||
m_ui->actionGroupEmptyTrash->setVisible(recycleBinSelected);
|
||||
m_ui->actionGroupEmptyTrash->setEnabled(recycleBinSelected);
|
||||
m_ui->actionChangeMasterKey->setEnabled(true);
|
||||
m_ui->actionChangeDatabaseSettings->setEnabled(true);
|
||||
m_ui->actionDatabaseSave->setEnabled(true);
|
||||
|
@ -162,7 +162,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<height>29</height>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuFile">
|
||||
@ -235,8 +235,10 @@
|
||||
<string>&Groups</string>
|
||||
</property>
|
||||
<addaction name="actionGroupNew"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionGroupEdit"/>
|
||||
<addaction name="actionGroupDelete"/>
|
||||
<addaction name="actionGroupEmptyTrash"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuTools">
|
||||
<property name="title">
|
||||
@ -521,6 +523,14 @@
|
||||
<string>Re&pair database</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionGroupEmptyTrash">
|
||||
<property name="text">
|
||||
<string>Empty recycle bin</string>
|
||||
</property>
|
||||
<property name="visible">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
|
Loading…
Reference in New Issue
Block a user