Changeset View
Changeset View
Standalone View
Standalone View
src/dolphincontextmenu.cpp
Show All 21 Lines | |||||
22 | 22 | | |||
23 | #include "dolphin_generalsettings.h" | 23 | #include "dolphin_generalsettings.h" | ||
24 | #include "dolphinmainwindow.h" | 24 | #include "dolphinmainwindow.h" | ||
25 | #include "dolphinnewfilemenu.h" | 25 | #include "dolphinnewfilemenu.h" | ||
26 | #include "dolphinremoveaction.h" | 26 | #include "dolphinremoveaction.h" | ||
27 | #include "dolphinviewcontainer.h" | 27 | #include "dolphinviewcontainer.h" | ||
28 | #include "panels/places/placesitem.h" | 28 | #include "panels/places/placesitem.h" | ||
29 | #include "panels/places/placesitemmodel.h" | 29 | #include "panels/places/placesitemmodel.h" | ||
30 | #include "trash/dolphintrash.h" | ||||
30 | #include "views/dolphinview.h" | 31 | #include "views/dolphinview.h" | ||
31 | #include "views/viewmodecontroller.h" | 32 | #include "views/viewmodecontroller.h" | ||
32 | 33 | | |||
33 | #include <KAbstractFileItemActionPlugin> | 34 | #include <KAbstractFileItemActionPlugin> | ||
34 | #include <KActionCollection> | 35 | #include <KActionCollection> | ||
35 | #include <KFileItemActions> | 36 | #include <KFileItemActions> | ||
36 | #include <KFileItemListProperties> | 37 | #include <KFileItemListProperties> | ||
37 | #include <KIO/EmptyTrashJob> | 38 | #include <KIO/EmptyTrashJob> | ||
▲ Show 20 Lines • Show All 96 Lines • ▼ Show 20 Line(s) | 131 | { | |||
134 | QMenu::keyReleaseEvent(ev); | 135 | QMenu::keyReleaseEvent(ev); | ||
135 | } | 136 | } | ||
136 | 137 | | |||
137 | void DolphinContextMenu::openTrashContextMenu() | 138 | void DolphinContextMenu::openTrashContextMenu() | ||
138 | { | 139 | { | ||
139 | Q_ASSERT(m_context & TrashContext); | 140 | Q_ASSERT(m_context & TrashContext); | ||
140 | 141 | | |||
141 | QAction* emptyTrashAction = new QAction(QIcon::fromTheme(QStringLiteral("trash-empty")), i18nc("@action:inmenu", "Empty Trash"), this); | 142 | QAction* emptyTrashAction = new QAction(QIcon::fromTheme(QStringLiteral("trash-empty")), i18nc("@action:inmenu", "Empty Trash"), this); | ||
142 | KConfig trashConfig(QStringLiteral("trashrc"), KConfig::SimpleConfig); | 143 | emptyTrashAction->setEnabled(!Trash::isEmpty()); | ||
elvisangelaccio: This could just be `Trash::isEmpty()` (same with the other static methods). | |||||
143 | emptyTrashAction->setEnabled(!trashConfig.group("Status").readEntry("Empty", true)); | | |||
144 | addAction(emptyTrashAction); | 144 | addAction(emptyTrashAction); | ||
145 | 145 | | |||
146 | addCustomActions(); | 146 | addCustomActions(); | ||
147 | 147 | | |||
148 | QAction* propertiesAction = m_mainWindow->actionCollection()->action(QStringLiteral("properties")); | 148 | QAction* propertiesAction = m_mainWindow->actionCollection()->action(QStringLiteral("properties")); | ||
149 | addAction(propertiesAction); | 149 | addAction(propertiesAction); | ||
150 | 150 | | |||
151 | addShowMenuBarAction(); | 151 | addShowMenuBarAction(); | ||
152 | 152 | | |||
153 | if (exec(m_pos) == emptyTrashAction) { | 153 | if (exec(m_pos) == emptyTrashAction) { | ||
154 | KIO::JobUiDelegate uiDelegate; | 154 | Trash::empty(m_mainWindow); | ||
155 | uiDelegate.setWindow(m_mainWindow); | | |||
156 | if (uiDelegate.askDeleteConfirmation(QList<QUrl>(), KIO::JobUiDelegate::EmptyTrash, KIO::JobUiDelegate::DefaultConfirmation)) { | | |||
157 | KIO::Job* job = KIO::emptyTrash(); | | |||
158 | KJobWidgets::setWindow(job, m_mainWindow); | | |||
159 | job->uiDelegate()->setAutoErrorHandlingEnabled(true); | | |||
160 | } | | |||
161 | } | 155 | } | ||
162 | } | 156 | } | ||
163 | 157 | | |||
164 | void DolphinContextMenu::openTrashItemContextMenu() | 158 | void DolphinContextMenu::openTrashItemContextMenu() | ||
165 | { | 159 | { | ||
166 | Q_ASSERT(m_context & TrashContext); | 160 | Q_ASSERT(m_context & TrashContext); | ||
167 | Q_ASSERT(m_context & ItemContext); | 161 | Q_ASSERT(m_context & ItemContext); | ||
168 | 162 | | |||
▲ Show 20 Lines • Show All 331 Lines • Show Last 20 Lines |
This could just be Trash::isEmpty() (same with the other static methods).