Commit 7e98c5d7 authored by Kai Uwe Broulik's avatar Kai Uwe Broulik 🍇
Browse files

[Folder View] Update "Empty Trash" enabled state for files inside Trash and links to Trash

Previously this was only done for files inside Trash. Now also the context menu of a Trash link has correct state.

BUG: 392738
FIXED-IN: 5.12.5

Differential Revision: https://phabricator.kde.org/D11944
parent bf12647c
......@@ -1618,8 +1618,7 @@ void FolderModel::updateActions()
if (emptyTrash) {
if (isTrash) {
emptyTrash->setVisible(true);
KConfig trashConfig(QStringLiteral("trashrc"), KConfig::SimpleConfig);
emptyTrash->setEnabled(!trashConfig.group("Status").readEntry("Empty", true));
emptyTrash->setEnabled(!isTrashEmpty());
} else {
emptyTrash->setVisible(false);
}
......@@ -1738,6 +1737,7 @@ void FolderModel::openContextMenu(QQuickItem *visualParent)
// called before we open the menu, it would correct visibility again when opening
// the context menu for other items later.
emptyTrashAction->setVisible(true);
emptyTrashAction->setEnabled(!isTrashEmpty());
menu->addAction(emptyTrashAction);
}
} else {
......@@ -1961,6 +1961,12 @@ void FolderModel::restoreSelectedFromTrash()
job->uiDelegate()->setAutoErrorHandlingEnabled(true);
}
bool FolderModel::isTrashEmpty()
{
KConfig trashConfig(QStringLiteral("trashrc"), KConfig::SimpleConfig);
return trashConfig.group("Status").readEntry("Empty", true);
}
void FolderModel::undoTextChanged(const QString &text)
{
if (QAction *action = m_actionCollection.action(QStringLiteral("undo"))) {
......
......@@ -306,6 +306,7 @@ class FOLDERPLUGIN_TESTS_EXPORT FolderModel : public QSortFilterProxyModel, publ
void updatePasteAction();
void addDragImage(QDrag *drag, int x, int y);
void setStatus(Status status);
static bool isTrashEmpty();
QList<QUrl> selectedUrls() const;
KDirModel *m_dirModel;
KDirWatch *m_dirWatch;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment