From ecfc3eadbcf27f310efd21be5e228b70dbf56010 Mon Sep 17 00:00:00 2001 From: NewStart Date: Mon, 13 May 2024 04:02:58 -0400 Subject: [PATCH] =?UTF-8?q?=E7=A6=81=E6=AD=A2=E5=88=A0=E9=99=A4=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E7=9B=AE=E5=BD=95=E4=B8=8B=E7=9A=84=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=A4=B9=E5=92=8C=E6=A1=8C=E9=9D=A2=E7=9A=84?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E5=9B=BE=E6=A0=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libfm-qt-0.14.1/src/fileoperation.cpp | 34 +++++++++++++++++++++------ libfm-qt.spec | 5 +++- 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/libfm-qt-0.14.1/src/fileoperation.cpp b/libfm-qt-0.14.1/src/fileoperation.cpp index 0092a63..aa79ac0 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 a119179..da4c8d5 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形式 -- Gitee