From 8c0cecfa3aa65c6c9c908f6b6bebbb754f1c232a Mon Sep 17 00:00:00 2001 From: rekols Date: Mon, 16 Apr 2018 15:44:35 +0800 Subject: [PATCH] refactor(datetime_plugin): use DDBusSender Change-Id: Ieb5d336fdff0bf14e575dbd0b853813092ceb3e9 --- plugins/datetime/CMakeLists.txt | 8 +++++--- plugins/datetime/datetimeplugin.cpp | 14 +++++++++++--- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/plugins/datetime/CMakeLists.txt b/plugins/datetime/CMakeLists.txt index f3cbcefbf..d537b9b2b 100644 --- a/plugins/datetime/CMakeLists.txt +++ b/plugins/datetime/CMakeLists.txt @@ -9,6 +9,7 @@ file(GLOB SRCS "*.h" "*.cpp") find_package(PkgConfig REQUIRED) find_package(Qt5Widgets REQUIRED) find_package(Qt5Svg REQUIRED) +find_package(Qt5DBus REQUIRED) find_package(DtkWidget REQUIRED) add_definitions("${QT_DEFINITIONS} -DQT_PLUGIN") @@ -16,9 +17,10 @@ add_library(${PLUGIN_NAME} SHARED ${SRCS} resources.qrc) set_target_properties(${PLUGIN_NAME} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ../) target_include_directories(${PLUGIN_NAME} PUBLIC ${DtkWidget_INCLUDE_DIRS} ../../interfaces) target_link_libraries(${PLUGIN_NAME} PRIVATE - ${DtkWidget_LIBRARIES} - ${Qt5Widgets_LIBRARIES} - ${Qt5Svg_LIBRARIES} + ${Qt5DBus_LIBRARIES} + ${DtkWidget_LIBRARIES} + ${Qt5Widgets_LIBRARIES} + ${Qt5Svg_LIBRARIES} ) install(TARGETS ${PLUGIN_NAME} LIBRARY DESTINATION lib/dde-dock/plugins) diff --git a/plugins/datetime/datetimeplugin.cpp b/plugins/datetime/datetimeplugin.cpp index 7da363a89..e1ef4c0cf 100644 --- a/plugins/datetime/datetimeplugin.cpp +++ b/plugins/datetime/datetimeplugin.cpp @@ -21,6 +21,7 @@ #include "datetimeplugin.h" +#include #include #include @@ -152,10 +153,17 @@ void DatetimePlugin::invokedMenuItem(const QString &itemKey, const QString &menu Q_UNUSED(itemKey) Q_UNUSED(checked) - if (menuId == "open") - QProcess::startDetached("dbus-send --print-reply --dest=com.deepin.dde.ControlCenter /com/deepin/dde/ControlCenter com.deepin.dde.ControlCenter.ShowModule \"string:datetime\""); - else + if (menuId == "open") { + DDBusSender() + .service("com.deepin.dde.ControlCenter") + .interface("com.deepin.dde.ControlCenter") + .path("/com/deepin/dde/ControlCenter") + .method(QString("ShowModule")) + .arg(QString("datetime")) + .call(); + } else { m_centralWidget->toggleHourFormat(); + } } void DatetimePlugin::updateCurrentTimeString()