diff --git a/containments/desktop/plugins/folder/foldermodel.h b/containments/desktop/plugins/folder/foldermodel.h --- a/containments/desktop/plugins/folder/foldermodel.h +++ b/containments/desktop/plugins/folder/foldermodel.h @@ -306,6 +306,7 @@ void updatePasteAction(); void addDragImage(QDrag *drag, int x, int y); void setStatus(Status status); + static bool isTrashEmpty(); QList selectedUrls() const; KDirModel *m_dirModel; KDirWatch *m_dirWatch; diff --git a/containments/desktop/plugins/folder/foldermodel.cpp b/containments/desktop/plugins/folder/foldermodel.cpp --- a/containments/desktop/plugins/folder/foldermodel.cpp +++ b/containments/desktop/plugins/folder/foldermodel.cpp @@ -1618,8 +1618,7 @@ 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 @@ // 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 @@ 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"))) {