From 090f79c897626f3bd477576f5c975ebee6fbffac Mon Sep 17 00:00:00 2001 From: songwentao Date: Fri, 20 Aug 2021 10:19:10 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BB=BB=E5=8A=A1=E6=A0=8F=E5=9B=9E?= =?UTF-8?q?=E6=94=B6=E7=AB=99=E6=8B=96=E6=8B=BD=E5=88=A0=E9=99=A4=E5=8A=A8?= =?UTF-8?q?=E4=BD=9C=E6=94=AF=E6=8C=81ctrl+z=E6=92=A4=E5=9B=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 弃用gio进程删除文件,使用文管的删除接口,删除后,文件进入到桌面回收站,ctrl+Z调用可以直接恢复文件到桌面. Log: 新增回收站拖拽删除动作支持ctrl+z撤回功能 Task: https://pms.uniontech.com/zentao/task-view-83592.html Change-Id: Icdcc14ca0fde6d99f95f91779906d7aa225b81cf --- plugins/trash/CMakeLists.txt | 13 +++++++++++-- plugins/trash/trashwidget.cpp | 10 +++++++++- plugins/trash/trashwidget.h | 4 ++++ 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/plugins/trash/CMakeLists.txt b/plugins/trash/CMakeLists.txt index 58e2dee60..4e9277316 100644 --- a/plugins/trash/CMakeLists.txt +++ b/plugins/trash/CMakeLists.txt @@ -9,16 +9,25 @@ file(GLOB SRCS "*.h" "*.cpp" "../../widgets/*.h" "../../widgets/*.cpp") find_package(PkgConfig REQUIRED) find_package(Qt5Widgets REQUIRED) find_package(Qt5Svg REQUIRED) +find_package(Qt5DBus REQUIRED) find_package(DtkWidget REQUIRED) +pkg_check_modules(DFrameworkDBus REQUIRED dframeworkdbus) + add_definitions("${QT_DEFINITIONS} -DQT_PLUGIN") add_library(${PLUGIN_NAME} SHARED ${SRCS} resource.qrc) set_target_properties(${PLUGIN_NAME} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ../) -target_include_directories(${PLUGIN_NAME} PUBLIC ${DtkWidget_INCLUDE_DIRS} - ../../interfaces) + +target_include_directories(${PLUGIN_NAME} PUBLIC + ${DtkWidget_INCLUDE_DIRS} + ${DFrameworkDBus_INCLUDE_DIRS} + ../../interfaces) + target_link_libraries(${PLUGIN_NAME} PRIVATE ${DtkWidget_LIBRARIES} + ${DFrameworkDBus_LIBRARIES} ${Qt5Widgets_LIBRARIES} + ${Qt5DBus_LIBRARIES} ${Qt5Svg_LIBRARIES} ) diff --git a/plugins/trash/trashwidget.cpp b/plugins/trash/trashwidget.cpp index 47b7c7360..9594fb6a2 100644 --- a/plugins/trash/trashwidget.cpp +++ b/plugins/trash/trashwidget.cpp @@ -33,10 +33,15 @@ #include #include #include +#include TrashWidget::TrashWidget(QWidget *parent) : QWidget(parent) , m_popupApplet(new PopupControlWidget(this)) + , m_fileManagerInter(new DBusFileManager1("org.freedesktop.FileManager1", + "/org/freedesktop/FileManager1", + QDBusConnection::sessionBus(), + this)) { m_popupApplet->setVisible(false); @@ -220,5 +225,8 @@ void TrashWidget::moveToTrash(const QUrl &url) { const QFileInfo info = url.toLocalFile(); - QProcess::startDetached("gio", QStringList() << "trash" << "-f" << info.absoluteFilePath()); + QStringList argumentList; + argumentList << info.absoluteFilePath(); + + m_fileManagerInter->Trash(argumentList); } diff --git a/plugins/trash/trashwidget.h b/plugins/trash/trashwidget.h index 79bda86a9..2a8fceafe 100644 --- a/plugins/trash/trashwidget.h +++ b/plugins/trash/trashwidget.h @@ -35,6 +35,9 @@ #include #include +#include +using DBusFileManager1 = org::freedesktop::FileManager1; + class TrashWidget : public QWidget { Q_OBJECT @@ -65,6 +68,7 @@ private slots: private: PopupControlWidget *m_popupApplet; + DBusFileManager1 *m_fileManagerInter; QPixmap m_icon; QIcon m_defaulticon;