mirror of
https://invent.kde.org/system/dolphin
synced 2024-10-28 03:21:56 +00:00
Remove KonqOperations::emptyTrash() and port to KIO::emptyTrash() instead.
This commit is contained in:
parent
5a6ac1b5f7
commit
e44ddfa5ab
|
@ -35,6 +35,8 @@
|
||||||
#include <KGlobal>
|
#include <KGlobal>
|
||||||
#include <KIconLoader>
|
#include <KIconLoader>
|
||||||
#include <KIO/RestoreJob>
|
#include <KIO/RestoreJob>
|
||||||
|
#include <KIO/EmptyTrashJob>
|
||||||
|
#include <KIO/JobUiDelegate>
|
||||||
#include <KJobUiDelegate>
|
#include <KJobUiDelegate>
|
||||||
#include <KJobWidgets>
|
#include <KJobWidgets>
|
||||||
#include <KMenu>
|
#include <KMenu>
|
||||||
|
@ -158,7 +160,13 @@ void DolphinContextMenu::openTrashContextMenu()
|
||||||
addShowMenuBarAction();
|
addShowMenuBarAction();
|
||||||
|
|
||||||
if (exec(m_pos) == emptyTrashAction) {
|
if (exec(m_pos) == emptyTrashAction) {
|
||||||
KonqOperations::emptyTrash(m_mainWindow);
|
KIO::JobUiDelegate uiDelegate;
|
||||||
|
uiDelegate.setWindow(m_mainWindow);
|
||||||
|
if (uiDelegate.askDeleteConfirmation(QList<QUrl>(), KIO::JobUiDelegate::EmptyTrash, KIO::JobUiDelegate::DefaultConfirmation)) {
|
||||||
|
KIO::Job* job = KIO::emptyTrash();
|
||||||
|
KJobWidgets::setWindow(job, m_mainWindow);
|
||||||
|
job->ui()->setAutoErrorHandlingEnabled(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include <KDirNotify>
|
#include <KDirNotify>
|
||||||
#include <KIcon>
|
#include <KIcon>
|
||||||
#include <KIO/Job>
|
#include <KIO/Job>
|
||||||
|
#include <KIO/EmptyTrashJob>
|
||||||
#include <KIO/JobUiDelegate>
|
#include <KIO/JobUiDelegate>
|
||||||
#include <KJobWidgets>
|
#include <KJobWidgets>
|
||||||
#include <KLocale>
|
#include <KLocale>
|
||||||
|
@ -426,7 +427,8 @@ void PlacesPanel::slotTrashUpdated(KJob* job)
|
||||||
if (job->error()) {
|
if (job->error()) {
|
||||||
emit errorMessage(job->errorString());
|
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)
|
void PlacesPanel::slotStorageSetupDone(int index, bool success)
|
||||||
|
@ -450,20 +452,11 @@ void PlacesPanel::slotStorageSetupDone(int index, bool success)
|
||||||
|
|
||||||
void PlacesPanel::emptyTrash()
|
void PlacesPanel::emptyTrash()
|
||||||
{
|
{
|
||||||
const QString text = i18nc("@info", "Do you really want to empty the Trash? All items will be deleted.");
|
KIO::JobUiDelegate uiDelegate;
|
||||||
const bool del = KMessageBox::warningContinueCancel(window(),
|
uiDelegate.setWindow(window());
|
||||||
text,
|
if (uiDelegate.askDeleteConfirmation(QList<QUrl>(), KIO::JobUiDelegate::EmptyTrash, KIO::JobUiDelegate::DefaultConfirmation)) {
|
||||||
QString(),
|
KIO::Job* job = KIO::emptyTrash();
|
||||||
KGuiItem(i18nc("@action:button", "Empty Trash"),
|
KJobWidgets::setWindow(job, window());
|
||||||
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());
|
|
||||||
connect(job, &KIO::Job::result, this, &PlacesPanel::slotTrashUpdated);
|
connect(job, &KIO::Job::result, this, &PlacesPanel::slotTrashUpdated);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue