Changeset View
Changeset View
Standalone View
Standalone View
src/dolphincontextmenu.cpp
Show First 20 Lines • Show All 50 Lines • ▼ Show 20 Line(s) | |||||
51 | #include <QMimeDatabase> | 51 | #include <QMimeDatabase> | ||
52 | 52 | | |||
53 | #include <panels/places/placesitem.h> | 53 | #include <panels/places/placesitem.h> | ||
54 | #include <panels/places/placesitemmodel.h> | 54 | #include <panels/places/placesitemmodel.h> | ||
55 | 55 | | |||
56 | 56 | | |||
57 | #include "views/dolphinview.h" | 57 | #include "views/dolphinview.h" | ||
58 | #include "views/viewmodecontroller.h" | 58 | #include "views/viewmodecontroller.h" | ||
59 | #include "trash/dolphintrash.h" | ||||
59 | 60 | | |||
60 | DolphinContextMenu::DolphinContextMenu(DolphinMainWindow* parent, | 61 | DolphinContextMenu::DolphinContextMenu(DolphinMainWindow* parent, | ||
61 | const QPoint& pos, | 62 | const QPoint& pos, | ||
62 | const KFileItem& fileInfo, | 63 | const KFileItem& fileInfo, | ||
63 | const QUrl& baseUrl) : | 64 | const QUrl& baseUrl) : | ||
64 | QMenu(parent), | 65 | QMenu(parent), | ||
65 | m_pos(pos), | 66 | m_pos(pos), | ||
66 | m_mainWindow(parent), | 67 | m_mainWindow(parent), | ||
▲ Show 20 Lines • Show All 70 Lines • ▼ Show 20 Line(s) | 134 | { | |||
137 | QMenu::keyReleaseEvent(ev); | 138 | QMenu::keyReleaseEvent(ev); | ||
138 | } | 139 | } | ||
139 | 140 | | |||
140 | void DolphinContextMenu::openTrashContextMenu() | 141 | void DolphinContextMenu::openTrashContextMenu() | ||
141 | { | 142 | { | ||
142 | Q_ASSERT(m_context & TrashContext); | 143 | Q_ASSERT(m_context & TrashContext); | ||
143 | 144 | | |||
144 | QAction* emptyTrashAction = new QAction(QIcon::fromTheme(QStringLiteral("trash-empty")), i18nc("@action:inmenu", "Empty Trash"), this); | 145 | QAction* emptyTrashAction = new QAction(QIcon::fromTheme(QStringLiteral("trash-empty")), i18nc("@action:inmenu", "Empty Trash"), this); | ||
145 | KConfig trashConfig(QStringLiteral("trashrc"), KConfig::SimpleConfig); | 146 | emptyTrashAction->setEnabled(!Trash::instance().isEmpty()); | ||
146 | emptyTrashAction->setEnabled(!trashConfig.group("Status").readEntry("Empty", true)); | | |||
147 | addAction(emptyTrashAction); | 147 | addAction(emptyTrashAction); | ||
148 | 148 | | |||
149 | addCustomActions(); | 149 | addCustomActions(); | ||
150 | 150 | | |||
151 | QAction* propertiesAction = m_mainWindow->actionCollection()->action(QStringLiteral("properties")); | 151 | QAction* propertiesAction = m_mainWindow->actionCollection()->action(QStringLiteral("properties")); | ||
152 | addAction(propertiesAction); | 152 | addAction(propertiesAction); | ||
153 | 153 | | |||
154 | addShowMenuBarAction(); | 154 | addShowMenuBarAction(); | ||
155 | 155 | | |||
156 | if (exec(m_pos) == emptyTrashAction) { | 156 | if (exec(m_pos) == emptyTrashAction) { | ||
157 | KIO::JobUiDelegate uiDelegate; | 157 | Trash::instance().empty(m_mainWindow); | ||
158 | uiDelegate.setWindow(m_mainWindow); | | |||
159 | if (uiDelegate.askDeleteConfirmation(QList<QUrl>(), KIO::JobUiDelegate::EmptyTrash, KIO::JobUiDelegate::DefaultConfirmation)) { | | |||
160 | KIO::Job* job = KIO::emptyTrash(); | | |||
161 | KJobWidgets::setWindow(job, m_mainWindow); | | |||
162 | job->uiDelegate()->setAutoErrorHandlingEnabled(true); | | |||
163 | } | | |||
164 | } | 158 | } | ||
165 | } | 159 | } | ||
166 | 160 | | |||
167 | void DolphinContextMenu::openTrashItemContextMenu() | 161 | void DolphinContextMenu::openTrashItemContextMenu() | ||
168 | { | 162 | { | ||
169 | Q_ASSERT(m_context & TrashContext); | 163 | Q_ASSERT(m_context & TrashContext); | ||
170 | Q_ASSERT(m_context & ItemContext); | 164 | Q_ASSERT(m_context & ItemContext); | ||
171 | 165 | | |||
▲ Show 20 Lines • Show All 330 Lines • Show Last 20 Lines |