Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Qt6 #157

Closed
wants to merge 1 commit into from
Closed

Qt6 #157

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
root = true

[*]
charset = utf-8
end_of_line = lf

[CMakeLists.txt]
indent_style = space
indent_size = 4

[*.{cpp,h,ts,cmake}]
indent_style = space
indent_size = 4
10 changes: 5 additions & 5 deletions .reuse/dep5
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Copyright: UnionTech Software Technology Co., Ltd.
License: CC-BY-4.0

# Project file
Files: *.pro *.qrc *.pri *CMakeLists.txt *.cmake *.desktop *.service *.in .clang-format
Files: *.pro *.qrc *.pri *CMakeLists.txt *.cmake *.desktop *.service *.in .clang-format .editorconfig
Copyright: None
License: CC0-1.0

Expand All @@ -43,12 +43,12 @@ Files: dde-clipboard/dbus/* dbus/*.xml dde-clipboard/org.deepin.dde.Clipboard1.x
Copyright: The Qt Company Ltd.
License: CC0-1.0

# xml
Files: dde-clipboard/com.deepin.dde.Clipboard.xml
Copyright: UnionTech Software Technology Co., Ltd.
# wayland
Files: misc/wlr-data-control-unstable-v1.xml
Copyright: wlroots developer.
License: GPL-3.0-or-later

# test file
# test file
Files: tests/dde-clipboard/qrc/*.buf tests/dde-clipboard/ut_img.cpp tests/dde-clipboard-daemon/plugin/dde-clipboard-loader/ut_qrc.cpp
Copyright: UnionTech Software Technology Co., Ltd.
License: GPL-3.0-or-later
204 changes: 11 additions & 193 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,137 +2,38 @@ cmake_minimum_required(VERSION 3.16)

set(BIN_NAME dde-clipboard)

project(${BIN_NAME})
project(dde-clipboard)

#set(CMAKE_VERBOSE_MAKEFILE ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)

if (CMAKE_BUILD_TYPE STREQUAL "Debug")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -Wall")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -fsanitize=address -O0")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -fsanitize=address -O0")
endif()

if (DEFINED ENABLE_MIEEE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mieee")
endif()
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

# Install settings
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX /usr)
endif ()

include(GNUInstallDirs)

if (NOT (${CMAKE_BUILD_TYPE} MATCHES "Debug"))
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Ofast")

# generate qm
execute_process(COMMAND bash "translate_generation.sh"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
endif ()
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -Wall")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -fsanitize=address -O0")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -fsanitize=address -O0")
endif()

# Find the library
find_package(PkgConfig REQUIRED)
find_package(Dtk COMPONENTS Widget Core REQUIRED)
find_package(Qt5 COMPONENTS Core Gui Widgets DBus Test Concurrent REQUIRED)

find_package(ECM REQUIRED NO_MODULE)
set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH})
find_package(DWayland REQUIRED)

pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-qt)

if (NOT DEFINED SYSTEMD_USER_UNIT_DIR)
pkg_get_variable(SYSTEMD_USER_UNIT_DIR systemd systemduserunitdir)
endif()

find_package(DtkTools REQUIRED)
function(generation_dbus_adaptor xml class_name class_file option)
execute_process(COMMAND qdbusxml2cpp ${option} -a ${class_file} -c ${class_name} ${xml}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
endfunction(generation_dbus_adaptor)

set(DBUS_INTERFACE ${PROJECT_SOURCE_DIR}/dbus/interface)
function(generation_dbus_interface xml class_name class_file)
execute_process(COMMAND ${DTK_XML2CPP} -c ${class_name} -p ${class_file} ${xml}
WORKING_DIRECTORY ${DBUS_INTERFACE})
endfunction(generation_dbus_interface)

include_directories(
dde-clipboard
dde-clipboard/dbus
dde-clipboard/displaymanager
dde-clipboardloader
)

#----------------------------dde-clipboard------------------------------
generation_dbus_adaptor(
${CMAKE_SOURCE_DIR}/dde-clipboard/org.deepin.dde.Clipboard1.xml
ClipboardAdaptor
${CMAKE_CURRENT_BINARY_DIR}/clipboard_adaptor
-N
)

generation_dbus_interface(
${CMAKE_SOURCE_DIR}/dbus/org.deepin.dde.Display1.Monitor.xml
Monitor
${DBUS_INTERFACE}/monitor_interface
)

generation_dbus_interface(
${CMAKE_SOURCE_DIR}/dbus/org.deepin.dde.Display1.xml
Display1
${DBUS_INTERFACE}/display_interface
)

generation_dbus_interface(
${CMAKE_SOURCE_DIR}/dbus/org.deepin.dde.daemon.Dock1.xml
Dock1
${DBUS_INTERFACE}/dock_interface
)

include_directories(
${PROJECT_SOURCE_DIR}/dbus/interface
${PROJECT_SOURCE_DIR}/dbus/types
${PROJECT_SOURCE_DIR}/dbus
)

aux_source_directory(dbus/types DBUS_TYPES)
aux_source_directory(dbus/interface DBUS_INTERFACES)

set(Clipboard_DBUS_SCRS
${CMAKE_CURRENT_BINARY_DIR}/clipboard_adaptor.h
${CMAKE_CURRENT_BINARY_DIR}/clipboard_adaptor.cpp
)

file(GLOB_RECURSE Clipboard_SCRS
"dde-clipboard/*.h"
"dde-clipboard/*.cpp"
)
list(REMOVE_ITEM Clipboard_SCRS "${CMAKE_SOURCE_DIR}/dde-clipboard/main.cpp")

add_executable(${BIN_NAME}
${Clipboard_SCRS}
${Clipboard_DBUS_SCRS}
dde-clipboard/main.cpp
${DBUS_INTERFACES}
${DBUS_TYPES}
)
include(GNUInstallDirs)

target_link_libraries(${BIN_NAME} PRIVATE
Dtk::Widget
Dtk::Core
PkgConfig::GIO
Qt5::Core
Qt5::Widgets
Qt5::GuiPrivate
Qt5::Gui
Qt5::DBus
)
add_subdirectory(dde-clipboard)
add_subdirectory(dde-clipboard-daemon)
add_subdirectory(tests)

macro(install_symlink filepath wantsdir)
file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/link/${wantsdir}/)
Expand Down Expand Up @@ -163,86 +64,3 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/dde-clipboard.service DESTINATION ${SY

install_symlink(dde-clipboard.service dde-session-initialized.target.wants)

## bin
install(TARGETS ${BIN_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR})

#----------------------------dde-clipboard-daemon------------------------------
set(BIN_NAME dde-clipboard-daemon)

file(GLOB_RECURSE dde-clipboard-daemon_SCRS
"dde-clipboard-daemon/*.h"
"dde-clipboard-daemon/*.cpp"
)

add_executable(${BIN_NAME}
${dde-clipboard-daemon_SCRS}
)

target_link_libraries(${BIN_NAME} PRIVATE
Qt5::Gui
Qt5::DBus
Qt5::Widgets
Dtk::Core
Qt5::Concurrent
DWaylandClient
)

install(TARGETS ${BIN_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR})

configure_file(
misc/org.deepin.dde.ClipboardLoader1.service.in
org.deepin.dde.ClipboardLoader1.service
@ONLY
)

configure_file(
misc/org.deepin.dde.daemon.Clipboard1.service.in
org.deepin.dde.daemon.Clipboard1.service
@ONLY
)
configure_file(
misc/dde-clipboard-daemon.service.in
dde-clipboard-daemon.service
@ONLY
)

install(FILES ${CMAKE_CURRENT_BINARY_DIR}/org.deepin.dde.ClipboardLoader1.service
DESTINATION ${CMAKE_INSTALL_DATADIR}/dbus-1/services
)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/org.deepin.dde.daemon.Clipboard1.service
DESTINATION ${CMAKE_INSTALL_DATADIR}/dbus-1/services
)

install(FILES ${CMAKE_CURRENT_BINARY_DIR}/dde-clipboard-daemon.service DESTINATION ${SYSTEMD_USER_UNIT_DIR})

#----------------------------ut-dde-clipboard------------------------------
set(UT_BIN_NAME ut-dde-clipboard)

file(GLOB_RECURSE ut_Clipboard_SCRS
"tests/dde-clipboard/*.h"
"tests/dde-clipboard/*.cpp"
"tests/dde-clipboard/*.qrc"
)

add_executable(${UT_BIN_NAME}
${Clipboard_SCRS}
${Clipboard_DBUS_SCRS}
${ut_Clipboard_SCRS}
${DBUS_INTERFACES}
${DBUS_TYPES}
)
# 用于测试覆盖率的编译条件
target_compile_options(${UT_BIN_NAME} PRIVATE -fprofile-arcs -ftest-coverage)

target_link_libraries(${UT_BIN_NAME} PRIVATE
Dtk::Widget
PkgConfig::GIO
Qt5::Core
Qt5::Widgets
Qt5::DBus
Qt5::Test
Qt5::GuiPrivate
-lpthread
-lgcov
-lgtest
)
22 changes: 22 additions & 0 deletions dbus/types/types.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
set(dbus_types
${CMAKE_CURRENT_LIST_DIR}/brightnessmap.h
${CMAKE_CURRENT_LIST_DIR}/brightnessmap.cpp
${CMAKE_CURRENT_LIST_DIR}/dockrect.h
${CMAKE_CURRENT_LIST_DIR}/dockrect.cpp
${CMAKE_CURRENT_LIST_DIR}/reflectlist.h
${CMAKE_CURRENT_LIST_DIR}/reflectlist.cpp
${CMAKE_CURRENT_LIST_DIR}/resolution.h
${CMAKE_CURRENT_LIST_DIR}/resolution.cpp
${CMAKE_CURRENT_LIST_DIR}/resolutionlist.h
${CMAKE_CURRENT_LIST_DIR}/resolutionlist.cpp
${CMAKE_CURRENT_LIST_DIR}/rotationlist.h
${CMAKE_CURRENT_LIST_DIR}/rotationlist.cpp
${CMAKE_CURRENT_LIST_DIR}/screenrect.h
${CMAKE_CURRENT_LIST_DIR}/screenrect.cpp
${CMAKE_CURRENT_LIST_DIR}/touchscreeninfolist.h
${CMAKE_CURRENT_LIST_DIR}/touchscreeninfolist.cpp
${CMAKE_CURRENT_LIST_DIR}/touchscreeninfolist_v2.h
${CMAKE_CURRENT_LIST_DIR}/touchscreeninfolist_v2.cpp
${CMAKE_CURRENT_LIST_DIR}/touchscreenmap.h
${CMAKE_CURRENT_LIST_DIR}/touchscreenmap.cpp
)
38 changes: 38 additions & 0 deletions dde-clipboard-daemon/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@

# Find the library
find_package(Qt6 COMPONENTS Core Gui Widgets DBus Test Concurrent WaylandClient REQUIRED)

find_package(Qt6WaylandScannerTools REQUIRED)

set(BIN_NAME dde-clipboard-daemon)

add_executable(${BIN_NAME})

set(dde-clipboard-daemon_SCRS
main.cpp
clipboarddaemon.h
clipboarddaemon.cpp
clipboardloader.h
clipboardloader.cpp
waylandcopyclient.h
waylandcopyclient.cpp
)

qt_generate_wayland_protocol_client_sources(dde-clipboard-daemon FILES
${CMAKE_CURRENT_SOURCE_DIR}/../misc/wlr-data-control-unstable-v1.xml
)

target_sources(${BIN_NAME} PRIVATE
${dde-clipboard-daemon_SCRS}
)

target_link_libraries(${BIN_NAME} PRIVATE
Qt::Gui
Qt::DBus
Qt::Widgets
Qt::Concurrent
Qt::WaylandClient
Qt::WaylandClientPrivate
)

install(TARGETS ${BIN_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR})
15 changes: 4 additions & 11 deletions dde-clipboard-daemon/clipboarddaemon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
// SPDX-License-Identifier: GPL-3.0-or-later

#include "clipboarddaemon.h"

#include "clipboardloader.h"

#include <QDBusError>
#include <QDBusConnection>
#include <QDBusError>

ClipboardDaemon::ClipboardDaemon(QObject *parent)
: QObject(parent)
Expand All @@ -18,15 +19,7 @@ ClipboardDaemon::ClipboardDaemon(QObject *parent)
}

ClipboardLoader *clipboardLoader = new ClipboardLoader(this);
connection.registerObject("/org/deepin/dde/ClipboardLoader1", clipboardLoader,
connection.registerObject("/org/deepin/dde/ClipboardLoader1",
clipboardLoader,
QDBusConnection::ExportAllSlots | QDBusConnection::ExportAllSignals);

// 剪切板管理和提供UI数据的功能合并,WaylandCopyClient只实例化一次
#if 0
// 实例化wayland 剪切板管理器
if (qEnvironmentVariable("XDG_SESSION_TYPE").contains("wayland")) {
WaylandCopyClient *waylandClipboardManager = new WaylandCopyClient(this);
waylandClipboardManager->init(true);
}
#endif
}
2 changes: 1 addition & 1 deletion dde-clipboard-daemon/clipboarddaemon.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ class ClipboardDaemon : public QObject
explicit ClipboardDaemon(QObject *parent = nullptr);
};

#endif //CLIPBOARD_DAEMON_H
#endif // CLIPBOARD_DAEMON_H
Loading
Loading