Skip to content

Commit

Permalink
feat: 合并新特性到uos
Browse files Browse the repository at this point in the history
合并新特性到uos(从uos-feature)

Log: 合并新特性到uos
Change-Id: I39f2b847100160fdca5b71942d4cb2f6ce5b8324
  • Loading branch information
jixianglong committed Jul 19, 2021
1 parent 7a2e109 commit 475c417
Show file tree
Hide file tree
Showing 388 changed files with 21,441 additions and 21,224 deletions.
19 changes: 18 additions & 1 deletion .tx/config
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,26 @@ source_file = translations/deepin-draw_en.ts
source_lang = en
type = QT

[deepin-draw.deepin-draw-calligraphypen]
file_filter = deepin-draw-plugins/calligraphypen/translations/deepin-draw-calli_<lang>.ts
source_file = deepin-draw-plugins/calligraphypen/translations/deepin-draw-calli_en.ts
source_lang = en
type = QT

[deepin-draw.deepin-draw-eraser]
file_filter = deepin-draw-plugins/eraser/translations/deepin-draw-eraser_<lang>.ts
source_file = deepin-draw-plugins/eraser/translations/deepin-draw-eraser_en.ts
source_lang = en
type = QT

[deepin-draw.deepin-draw-fillTool]
file_filter = deepin-draw-plugins/fillTool/translations/deepin-draw-fill_<lang>.ts
source_file = deepin-draw-plugins/fillTool/translations/deepin-draw-fill_en.ts
source_lang = en
type = QT

[deepin-draw.deepin-draw-desktop]
file_filter = translations/desktop/desktop_<lang>.ts
source_file = translations/desktop/desktop.ts
source_lang = en
type = QT

174 changes: 30 additions & 144 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,169 +12,55 @@ set(CMAKE_AUTOUIC ON)
project(deepin-draw)

# 是否开启单元测试编译
option(CREATTEST "Compile and generate test program" OFF)
option(DEEPINDRAW_TEST "only compile and generate deepin-draw-test program." OFF)

# 是否开启内存泄露检测
option(SANITIZERS "do sanitizers for code" OFF)
option(DEEPINDRAW_SANITIZERS "add sanitizers flag for code in gcc.it's a gcc function,but not support on mips." OFF)

# 是否启用accessblity(自动化测试)
option(AC_FUNC_ENABLE "make AT enable" ON)
if(AC_FUNC_ENABLE)
# 是否启用accessblity(CI自动化测试.if open, we should add accesibility name for qt widgets.)
option(DEEPINDRAW_AC_FUNC_ENABLE "make CI/AT enable.if open, we should add accesibility name for qt widgets." ON)
if(DEEPINDRAW_AC_FUNC_ENABLE)
add_definitions(-DENABLE_ACCESSIBILITY)
endif()

# 是否启用平板模式(平板适配)
option(TABLET_ENABLE "make tablet enable" OFF)
if(TABLET_ENABLE)
option(DEEPINDRAW_TABLET_ENABLE "do some outlooking changed with code that could make deepin-draw run on tablet system." OFF)
if(DEEPINDRAW_TABLET_ENABLE)
add_definitions(-DENABLE_TABLETSYSTEM)
endif()


set(TOP_PROJECT_DIR ${CMAKE_CURRENT_SOURCE_DIR})
if(CMAKE_BUILD_TYPE MATCHES "Debug")
#DEBUG时不做优化方便调试
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0")
else()
#加速编译优化参数
if (CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "mips64")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -Wl,-O1 -Wl,--as-needed -Wl,-E -fPIE -ffunction-sections -fdata-sections -Wl,--gc-sections -ftree-vectorize -march=loongson3a -mhard-float -mno-micromips -mno-mips16 -flax-vector-conversions -mloongson-ext2 -mloongson-mmi")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3 -Wl,-O1 -Wl,--as-needed -Wl,-E -fPIE -ffunction-sections -fdata-sections -Wl,--gc-sections -ftree-vectorize -march=loongson3a -mhard-float -mno-micromips -mno-mips16 -flax-vector-conversions -mloongson-ext2 -mloongson-mmi")
SET(CMAKE_EXE_LINKER_FLAGS "-pie")
else()
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -Wl,-O1 -Wl,--as-needed -Wl,-E -fPIE -ffunction-sections -fdata-sections -Wl,--gc-sections")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3 -Wl,-O1 -Wl,--as-needed -Wl,-E -fPIE -ffunction-sections -fdata-sections -Wl,--gc-sections")
SET(CMAKE_EXE_LINKER_FLAGS "-pie")
endif()
# if want to support plugins, must generate share drawbaselib instead of static)
option(DEEPINDRAW_LINK_DRAWBASELIB_STATIC "static compile deepin-draw or deepin-draw-test." ON)
if(DEEPINDRAW_LINK_DRAWBASELIB_STATIC)
add_definitions(-DLINK_DRAWBASELIB_STATIC)
endif()

if(SANITIZERS)
set(CMAKE_CXX_FLAGS "-fsanitize=undefined,address,leak -fno-omit-frame-pointer")
set(CMAKE_C_FLAGS "-fsanitize=undefined,address,leak -fno-omit-frame-pointer")
option(DEEPINDRAW_LOAD_TOOL_PLUGINS "if load tool plugins." ON)
if(DEEPINDRAW_LOAD_TOOL_PLUGINS AND NOT DEEPINDRAW_LINK_DRAWBASELIB_STATIC)
add_definitions(-DLOAD_TOOL_PLUGINS)
endif()

# 设置Qt模块
set(QtModule Core Gui Widgets DBus PrintSupport Svg Concurrent LinguistTools)

# 查找Qt相关的库链接
find_package(Qt5 REQUIRED ${QtModule})

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${PROJECT_BINARY_DIR}/config.h @ONLY)

set(SRCDIRS
${CMAKE_CURRENT_SOURCE_DIR}/src
${CMAKE_CURRENT_SOURCE_DIR}/src/drawshape
${CMAKE_CURRENT_SOURCE_DIR}/src/drawshape/drawTools
${CMAKE_CURRENT_SOURCE_DIR}/src/drawshape/drawItems
${CMAKE_CURRENT_SOURCE_DIR}/src/drawshape/drawItems/bzItems
${CMAKE_CURRENT_SOURCE_DIR}/src/frame
${CMAKE_CURRENT_SOURCE_DIR}/src/service
${CMAKE_CURRENT_SOURCE_DIR}/src/utils
${CMAKE_CURRENT_SOURCE_DIR}/src/widgets
${CMAKE_CURRENT_SOURCE_DIR}/src/widgets/dialog
${CMAKE_CURRENT_SOURCE_DIR}/src/frame/AttributesWidgets
${CMAKE_CURRENT_SOURCE_DIR}/src/frame/AttributesWidgets/private
${CMAKE_CURRENT_SOURCE_DIR}/src/icon
${CMAKE_CURRENT_SOURCE_DIR}/src/icons
)

# 包含源码文件夹并获取其下所有源代码文件
foreach(item IN LISTS SRCDIRS)
include_directories(${item})
list(APPEND SRC_CPPS ${item}/*.cpp)
list(APPEND SRC_HEADERS ${item}/*.h)
list(APPEND SRC_QRCS ${item}/*.qrc)
endforeach()
FILE (GLOB allSource ${SRC_CPPS})
FILE (GLOB allHeaders ${SRC_HEADERS})
FILE (GLOB allQrcs ${SRC_QRCS})

FILE(GLOB targetTsFiles ./translations/*.ts)

# 创建翻译文件(将源文件${allSource} ${allHeaders}关联上${targetTsFiles}的ts文件 然后生成${tragetQmFiles}的qm文件)
qt5_create_translation(tragetQmFiles ${allSource} ${allHeaders} ${targetTsFiles})

# 设置不删除生成的文件夹内容文件(设置此项是为了翻译后的文件不被删除)
set_directory_properties(PROPERTIES CLEAN_NO_CUSTOM 1)

add_executable(${PROJECT_NAME} ${allSource} ${allHeaders} ${allQrcs} ${tragetQmFiles})

# Find includes in corresponding build directories
set(CMAKE_INCLUDE_CURRENT_DIR ON)
include_directories(${PROJECT_BINARY_DIR})
include_directories(${PROJECT_SOURCE_DIR})

#------------------------------ 添加第三方库 DTK -------------------------------
# 使用第三方库需要用到的一个包
find_package(PkgConfig REQUIRED)

# 检查第三方库(这里检查了名字为dtkwidget的库和名字为dtkgui的库),然后取名3rd_lib
pkg_check_modules(3rd_lib REQUIRED
dtkwidget dtkgui
)
# 添加第三方库的所有文件夹路径到工程中来(注意 *_INCLUDE_DIRS)
target_include_directories(${PROJECT_NAME} PUBLIC ${3rd_lib_INCLUDE_DIRS})


# 将第三方库链接进来(注意 *_LIBRARIES)
target_link_libraries(${PROJECT_NAME} ${3rd_lib_LIBRARIES})

#------------------------------添加第三方库end-------------------------------------

# 将工程与Qt模块链接起来
qt5_use_modules(${PROJECT_NAME} ${QtModule})


# ------------------------------- install script -------------------------------

#define install destination
set(${CMAKE_INSTALL_PREFIX} usr/bin)
set(PREFIX /usr)
set(BinDir ${PREFIX}/bin)
set(TranslationDir ${PREFIX}/share/deepin-draw/translations/)
set(DbusDir ${PREFIX}/share/dbus-1/services/)
set(DesktopDir ${PREFIX}/share/applications/)
set(ManIconDir ${PREFIX}/share/icons/deepin/apps/scalable)
set(AppIconDir ${PREFIX}/share/icons/hicolor/scalable/apps)
set(MimeFileDir ${PREFIX}/share/mime/packages)
set(MimeTypeDir ${PREFIX}/share/application)
set(HelpFileDir ${PREFIX}/share/deepin-manual/manual-assets/application)

# install Targets:
# * <prefix>/lib/libxxx.so
# * header location after install: <prefix>/include/xxx.h
# * headers can be included by C++ code `#include <xxx.h>`
install(TARGETS ${PROJECT_NAME}
EXPORT ${PROJECT_NAME}Targets
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
RUNTIME DESTINATION /usr/bin
INCLUDES DESTINATION allHeaders)

# install Translation files:
install(FILES ${tragetQmFiles} DESTINATION ${TranslationDir})

# install DBus file:
install(FILES ./com.deepin.Draw.service DESTINATION ${DbusDir})

# install Desktop icon
install(FILES ./deepin-draw.desktop DESTINATION ${DesktopDir})

# install Manual icon
install(FILES ./src/logo/deepin-draw.svg DESTINATION ${ManIconDir})

# install App icon
install(FILES ./src/logo/deepin-draw.svg DESTINATION ${AppIconDir})

# install MimeFile
install(FILES ./mimetype/deepin-draw.xml DESTINATION ${MimeFileDir})
if(DEEPINDRAW_LOAD_TOOL_PLUGINS AND NOT DEEPINDRAW_LINK_DRAWBASELIB_STATIC)
set(PluginDir ${PREFIX}/lib/${CMAKE_LIBRARY_ARCHITECTURE}/deepin-draw/plugins/)
set(PluginTransDir ${TranslationDir}plugins)
endif()

# install Mimetype
install(FILES ./src/service/x-ddf.xml DESTINATION ${MimeTypeDir})
#1. base lib and main executable
add_subdirectory(src)

# install Help File
install(DIRECTORY ./assets/deepin-draw DESTINATION ${HelpFileDir})
#2. test executable
if(DEEPINDRAW_TEST)
add_subdirectory(tests)
endif()

# 添加测试子工程
if(CREATTEST)
add_subdirectory(tests)
#3.tool plugins(the plugins is for deepin-draw,so lib of deepindrawbase(define in ./src) must not be static)
if(DEEPINDRAW_LOAD_TOOL_PLUGINS AND NOT DEEPINDRAW_LINK_DRAWBASELIB_STATIC)
message(support plugins----------------)
add_subdirectory(deepin-draw-plugins)
endif()

3 changes: 3 additions & 0 deletions config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,7 @@
/*#define RADIUS 0*/
/*#define RADIUS_MV 18*/


#define PLUGINPATH "@PluginDir@"
#define PLUGINTRANSPATH "@PluginTransDir@"
#endif /* __CONFIG_H__ */
5 changes: 5 additions & 0 deletions deepin-draw-plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
message("pluginsInstallDir ===== ${PluginDir}")
message("pluginsTransInstallDir ===== ${PluginTransDir}")
add_subdirectory(calligraphypen)
add_subdirectory(fillTool)
add_subdirectory(eraser)
75 changes: 75 additions & 0 deletions deepin-draw-plugins/calligraphypen/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# 定义需要的cmake版本
cmake_minimum_required(VERSION 3.10)

SET(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/plugins)

project("calligraphypen")

# 设置cmake参数
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)

# 设置Qt模块
set(QtModule Core Gui Widgets DBus PrintSupport Svg Concurrent LinguistTools)

# 查找Qt相关的库链接
find_package(Qt5 REQUIRED ${QtModule})

# 定义测试用例文件及测试资源文件
set(AllFileDirs
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/res
)
foreach(item IN LISTS AllFileDirs)
include_directories(${item})
list(APPEND allSourceFiles ${item}/*.cpp)
list(APPEND allSourceFiles ${item}/*.c)
list(APPEND allSourceFiles ${item}/*.h)
list(APPEND allQRCFiles ${item}/*.qrc)
endforeach()
FILE(GLOB allSourceG ${allSourceFiles})
FILE(GLOB allQRCG ${allQRCFiles})

FILE(GLOB targetTsFFiles ./translations/*.ts)
qt5_create_translation(tragetQmFFiles ${allSourceG} ${targetTsFFiles} OPTIONS -no-obsolete)

# 设置不删除生成的文件夹内容文件(设置此项是为了翻译后的文件不被删除)
set_directory_properties(PROPERTIES CLEAN_NO_CUSTOM 1)

add_library(${PROJECT_NAME} SHARED ${allSourceG} ${allQRCG} ${tragetQmFFiles})

#------------------------------ 添加第三方库 DTK -------------------------------

if(INDEPENDENTCMAKELISTS)
# 使用第三方库需要用到的一个包
find_package(PkgConfig REQUIRED)

# 检查第三方库(这里检查了名字为dtkwidget的库和名字为dtkgui的库),然后取名3rd_lib
pkg_check_modules(3rd_lib REQUIRED
dtkwidget dtkgui
)
endif()

# 添加第三方库的所有文件夹路径到工程中来(注意 *_INCLUDE_DIRS)
target_include_directories(${PROJECT_NAME} PUBLIC ${3rd_lib_INCLUDE_DIRS} ${BASE_LIB_INCLUDEDIRS})

# 将第三方库链接进来(注意 *_LIBRARIES)
target_link_libraries(${PROJECT_NAME} ${3rd_lib_LIBRARIES} ${BASE_LIB})

#------------------------------添加第三方库end-------------------------------------

# 将工程与Qt模块链接起来
qt5_use_modules(${PROJECT_NAME} ${QtModule})

# install Translation files:
install(FILES ${tragetQmFFiles} DESTINATION ${PluginTransDir})

install(TARGETS ${PROJECT_NAME}
EXPORT ${PROJECT_NAME}Targets
LIBRARY DESTINATION ${PluginDir}
ARCHIVE DESTINATION lib
RUNTIME DESTINATION ${PluginDir}
INCLUDES DESTINATION allHeaders)
Loading

0 comments on commit 475c417

Please sign in to comment.