feat: 任务栏回收站拖拽删除动作支持ctrl+z撤回

弃用gio进程删除文件,使用文管的删除接口,删除后,文件进入到桌面回收站,ctrl+Z调用可以直接恢复文件到桌面.

Log: 新增回收站拖拽删除动作支持ctrl+z撤回功能
Task: https://pms.uniontech.com/zentao/task-view-83592.html
Change-Id: Icdcc14ca0fde6d99f95f91779906d7aa225b81cf
This commit is contained in:
songwentao 2021-08-20 10:19:10 +08:00
parent 7aec7a0cf8
commit 090f79c897
3 changed files with 24 additions and 3 deletions

View File

@ -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}
)

View File

@ -33,10 +33,15 @@
#include <QDragEnterEvent>
#include <QJsonDocument>
#include <QApplication>
#include <QDBusConnection>
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);
}

View File

@ -35,6 +35,9 @@
#include <QAction>
#include <QIcon>
#include <org_freedesktop_filemanager1.h>
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;