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;