Index: src/widgets/fileundomanager.cpp =================================================================== --- src/widgets/fileundomanager.cpp +++ src/widgets/fileundomanager.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include #include @@ -112,6 +113,11 @@ if (showProgressInfo) { KIO::getJobTracker()->registerJob(this); } + + d_ptr->m_privilegeExecutionEnabled = true; + d_ptr->m_operationType = d_ptr->Other; + d_ptr->m_caption = i18n("Undo Changes"); + d_ptr->m_message = i18n("Undoing this operation requires root privileges. Do you want to continue?"); } virtual ~UndoJob() {} @@ -509,6 +515,7 @@ QUrl dir = m_dirStack.pop(); //qDebug() << "creatingDir" << dir; m_currentJob = KIO::mkdir(dir); + m_currentJob->setParentJob(m_undoJob); m_undoJob->emitCreatingDir(dir); } else { m_undoState = MOVINGFILES; @@ -528,34 +535,38 @@ if (type == BasicOperation::Directory) { if (op.m_renamed) { //qDebug() << "rename" << op.m_dst << op.m_src; - m_currentJob = KIO::rename(op.m_dst, op.m_src, KIO::HideProgressInfo); + m_currentJob = KIO::rename(op.m_dst, op.m_src, KIO::HideProgressInfo | KIO::PrivilegeExecution); m_undoJob->emitMoving(op.m_dst, op.m_src); } else { assert(0); // this should not happen! } } else if (type == BasicOperation::Link) { //qDebug() << "symlink" << op.m_target << op.m_src; - m_currentJob = KIO::symlink(op.m_target, op.m_src, KIO::Overwrite | KIO::HideProgressInfo); + m_currentJob = KIO::symlink(op.m_target, op.m_src, KIO::Overwrite | KIO::HideProgressInfo | KIO::PrivilegeExecution); } else if (m_current.m_type == FileUndoManager::Copy) { if (m_undoState == MOVINGFILES) { // dest not stat'ed yet // Before we delete op.m_dst, let's check if it was modified (#20532) //qDebug() << "stat" << op.m_dst; m_currentJob = KIO::stat(op.m_dst, KIO::HideProgressInfo); m_undoState = STATINGFILE; // temporarily return; // no pop() yet, we'll finish the work in slotResult } else { // dest was stat'ed, and the deletion was approved in slotResult - m_currentJob = KIO::file_delete(op.m_dst, KIO::HideProgressInfo); + m_currentJob = KIO::file_delete(op.m_dst, KIO::HideProgressInfo | KIO::PrivilegeExecution); m_undoJob->emitDeleting(op.m_dst); m_undoState = MOVINGFILES; } } else if (m_current.isMoveCommand() || m_current.m_type == FileUndoManager::Trash) { //qDebug() << "file_move" << op.m_dst << op.m_src; - m_currentJob = KIO::file_move(op.m_dst, op.m_src, -1, KIO::Overwrite | KIO::HideProgressInfo); + m_currentJob = KIO::file_move(op.m_dst, op.m_src, -1, KIO::Overwrite | KIO::HideProgressInfo | KIO::PrivilegeExecution); m_currentJob->uiDelegateExtension()->createClipboardUpdater(m_currentJob, JobUiDelegateExtension::UpdateContent); m_undoJob->emitMoving(op.m_dst, op.m_src); } + if (m_currentJob) { + m_currentJob->setParentJob(m_undoJob); + } + m_current.m_opStack.removeLast(); // The above KIO jobs are lowlevel, they don't trigger KDirNotify notification // So we need to do it ourselves (but schedule it to the end of the undo, to compress them) @@ -575,7 +586,8 @@ if (!m_fileCleanupStack.isEmpty()) { QUrl file = m_fileCleanupStack.pop(); //qDebug() << "file_delete" << file; - m_currentJob = KIO::file_delete(file, KIO::HideProgressInfo); + m_currentJob = KIO::file_delete(file, KIO::HideProgressInfo | KIO::PrivilegeExecution); + m_currentJob->setParentJob(m_undoJob); m_undoJob->emitDeleting(file); QUrl url = file.adjusted(QUrl::RemoveFilename | QUrl::StripTrailingSlash); @@ -595,6 +607,7 @@ QUrl dir = m_dirCleanupStack.pop(); //qDebug() << "rmdir" << dir; m_currentJob = KIO::rmdir(dir); + m_currentJob->setParentJob(m_undoJob); m_undoJob->emitDeleting(dir); addDirToUpdate(dir); } else {