refactor(datetime_plugin): use DDBusSender

Change-Id: Ieb5d336fdff0bf14e575dbd0b853813092ceb3e9
This commit is contained in:
rekols 2018-04-16 15:44:35 +08:00
parent 61002cd350
commit 8c0cecfa3a
Notes: gerrit 2018-04-17 14:41:45 +08:00
Code-Review+2: sbwtw <sbw@sbw.so>
Verified+1: Anonymous Coward #1000004
Submitted-by: rekols <rekols@foxmail.com>
Submitted-at: Tue, 17 Apr 2018 14:41:45 +0800
Reviewed-on: https://cr.deepin.io/33701
Project: dde/dde-dock
Branch: refs/heads/master
2 changed files with 16 additions and 6 deletions

View File

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

View File

@ -21,6 +21,7 @@
#include "datetimeplugin.h"
#include <DDBusSender>
#include <QLabel>
#include <QDebug>
@ -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()