diff --git a/libfm-qt-0.14.1/src/fileoperation.cpp b/libfm-qt-0.14.1/src/fileoperation.cpp index 0092a630a48f87441f35ef1254424d38923467d8..aa79ac0edb46daf3767bd97749de2f005e5d2325 100644 --- a/libfm-qt-0.14.1/src/fileoperation.cpp +++ b/libfm-qt-0.14.1/src/fileoperation.cpp @@ -26,6 +26,7 @@ #include #include "core/deletejob.h" +#include #include "core/trashjob.h" #include "core/untrashjob.h" #include "core/filetransferjob.h" @@ -414,10 +415,20 @@ FileOperation* FileOperation::deleteFiles(Fm::FilePathList srcFiles, bool prompt return nullptr; } } - for (int i = 0; i < srcFiles.size(); ++i) { - Fm::HistoryFolderList::globalInstance()->remove(srcFiles[i]); + QString desktop_path = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation); + Fm::FilePathList notUserDirPaths; + for(auto& path: srcFiles) { // 不删除用户目录下的默认文件夹及桌面的默认图标文件 + if(!Fm::isUserfile(path.localPath().get()) && + path.localPath().get() != desktop_path + "/computer.desktop" && + path.localPath().get() != desktop_path + "/user-home.desktop" && + path.localPath().get() != desktop_path + "/trash-can.desktop" && + path.localPath().get() != desktop_path + "/network.desktop") + { + Fm::HistoryFolderList::globalInstance()->remove(path); + notUserDirPaths.push_back(path); + } } - FileOperation* op = new FileOperation(FileOperation::Delete, std::move(srcFiles), parent, object); + FileOperation* op = new FileOperation(FileOperation::Delete, std::move(notUserDirPaths), parent, object); op->run(); return op; } @@ -434,11 +445,20 @@ FileOperation* FileOperation::trashFiles(Fm::FilePathList srcFiles, bool prompt, return nullptr; } } - // 删除已保存的历史路径,否则异常关闭文件管理器重启时会出现空标签页现象 - for (int i = 0; i < srcFiles.size(); ++i) { - Fm::HistoryFolderList::globalInstance()->remove(srcFiles[i]); + QString desktop_path = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation); + Fm::FilePathList notUserDirPaths; + for(auto& path: srcFiles) { // 不删除用户目录下的默认文件夹及桌面的默认图标文件 + if(!Fm::isUserfile(path.localPath().get()) && + path.localPath().get() != desktop_path + "/computer.desktop" && + path.localPath().get() != desktop_path + "/user-home.desktop" && + path.localPath().get() != desktop_path + "/trash-can.desktop" && + path.localPath().get() != desktop_path + "/network.desktop") + { + Fm::HistoryFolderList::globalInstance()->remove(path); + notUserDirPaths.push_back(path); + } } - FileOperation* op = new FileOperation(FileOperation::Trash, std::move(srcFiles), parent, object); + FileOperation* op = new FileOperation(FileOperation::Trash, std::move(notUserDirPaths), parent, object); op->run(); return op; } diff --git a/libfm-qt.spec b/libfm-qt.spec index a11917945088ef6453287ec5d12fe2fe498bba39..da4c8d55ea20ab53a1e3659b7fb4a358381aeea8 100644 --- a/libfm-qt.spec +++ b/libfm-qt.spec @@ -1,6 +1,6 @@ Name: libfm-qt Version: 0.14.1 -Release: 196%{?dist} +Release: 197%{?dist} Summary: Companion library for PCManFM License: GPLv2+ URL: http://www.gd-linux.com @@ -129,6 +129,9 @@ sed -i "s/Requires:.*/Requires: Qt5Widgets Qt5X11Extras/" %{buildroot}/%{_libdir %dir %{_datadir}/libfm-qt/translations %changelog +* Thu Sep 30 2021 Wu Shangmin - 0.14.1-197 +- 禁止删除用户目录下的默认文件夹和桌面的默认图标 + * Tue Sep 28 2021 Wu Shangmin - 0.14.1-196 - 拖动用户目录下的默认文件夹到其他路径时以copy的形式而不是以move形式