From e44ddfa5ab16af7cdcfc1c835e1baa8b32beaa67 Mon Sep 17 00:00:00 2001 From: David Faure Date: Thu, 21 Aug 2014 22:01:23 +0200 Subject: [PATCH] Remove KonqOperations::emptyTrash() and port to KIO::emptyTrash() instead. --- src/dolphincontextmenu.cpp | 10 +++++++++- src/panels/places/placespanel.cpp | 23 ++++++++--------------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/dolphincontextmenu.cpp b/src/dolphincontextmenu.cpp index 1fca7509bf..22272fb74b 100644 --- a/src/dolphincontextmenu.cpp +++ b/src/dolphincontextmenu.cpp @@ -35,6 +35,8 @@ #include #include #include +#include +#include #include #include #include @@ -158,7 +160,13 @@ void DolphinContextMenu::openTrashContextMenu() addShowMenuBarAction(); if (exec(m_pos) == emptyTrashAction) { - KonqOperations::emptyTrash(m_mainWindow); + KIO::JobUiDelegate uiDelegate; + uiDelegate.setWindow(m_mainWindow); + if (uiDelegate.askDeleteConfirmation(QList(), KIO::JobUiDelegate::EmptyTrash, KIO::JobUiDelegate::DefaultConfirmation)) { + KIO::Job* job = KIO::emptyTrash(); + KJobWidgets::setWindow(job, m_mainWindow); + job->ui()->setAutoErrorHandlingEnabled(true); + } } } diff --git a/src/panels/places/placespanel.cpp b/src/panels/places/placespanel.cpp index 487751931a..ce6c7b7ab3 100644 --- a/src/panels/places/placespanel.cpp +++ b/src/panels/places/placespanel.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -426,7 +427,8 @@ void PlacesPanel::slotTrashUpdated(KJob* job) if (job->error()) { emit errorMessage(job->errorString()); } - org::kde::KDirNotify::emitFilesAdded(QUrl("trash:/")); + // as long as KIO doesn't do this, do it ourselves + KNotification::event("Trash: emptied", QString(), QPixmap(), 0, KNotification::DefaultEvent); } void PlacesPanel::slotStorageSetupDone(int index, bool success) @@ -450,20 +452,11 @@ void PlacesPanel::slotStorageSetupDone(int index, bool success) void PlacesPanel::emptyTrash() { - const QString text = i18nc("@info", "Do you really want to empty the Trash? All items will be deleted."); - const bool del = KMessageBox::warningContinueCancel(window(), - text, - QString(), - KGuiItem(i18nc("@action:button", "Empty Trash"), - KIcon("user-trash")) - ) == KMessageBox::Continue; - if (del) { - QByteArray packedArgs; - QDataStream stream(&packedArgs, QIODevice::WriteOnly); - stream << int(1); - KIO::Job *job = KIO::special(KUrl("trash:/"), packedArgs); - KNotification::event("Trash: emptied", QString() , QPixmap() , 0, KNotification::DefaultEvent); - KJobWidgets::setWindow(job, parentWidget()); + KIO::JobUiDelegate uiDelegate; + uiDelegate.setWindow(window()); + if (uiDelegate.askDeleteConfirmation(QList(), KIO::JobUiDelegate::EmptyTrash, KIO::JobUiDelegate::DefaultConfirmation)) { + KIO::Job* job = KIO::emptyTrash(); + KJobWidgets::setWindow(job, window()); connect(job, &KIO::Job::result, this, &PlacesPanel::slotTrashUpdated); } }