-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Synchronize source files from linuxdeepin/dtkcore. Source-pull-request: linuxdeepin/dtkcore#392
- Loading branch information
1 parent
5b38c9c
commit a8e01de
Showing
10 changed files
with
417 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
# Copyright 2005-2011 Kitware, Inc. | ||
# Copyright (C) 2022 The Qt Company Ltd. | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
|
||
include(MacroAddFileDependencies) | ||
include(CMakeParseArguments) | ||
|
||
function(dtk_add_dbus_interface _sources _interface _basename) | ||
get_filename_component(_infile ${_interface} ABSOLUTE) | ||
set(_header "${CMAKE_CURRENT_BINARY_DIR}/${_basename}.h") | ||
set(_impl "${CMAKE_CURRENT_BINARY_DIR}/${_basename}.cpp") | ||
set(_moc "${CMAKE_CURRENT_BINARY_DIR}/${_basename}.moc") | ||
|
||
get_source_file_property(_nonamespace ${_interface} NO_NAMESPACE) | ||
if(_nonamespace) | ||
set(_params -N -m) | ||
else() | ||
set(_params -m) | ||
endif() | ||
|
||
get_source_file_property(_classname ${_interface} CLASSNAME) | ||
if(_classname) | ||
set(_params ${_params} -c ${_classname}) | ||
endif() | ||
|
||
get_source_file_property(_include ${_interface} INCLUDE) | ||
if(_include) | ||
set(_params ${_params} -i ${_include}) | ||
endif() | ||
|
||
add_custom_command(OUTPUT "${_impl}" "${_header}" | ||
COMMAND ${DTK_XML2CPP} ${_params} -p ${_basename} ${_infile} | ||
DEPENDS ${_infile} VERBATIM) | ||
|
||
set_source_files_properties("${_impl}" "${_header}" PROPERTIES | ||
SKIP_AUTOMOC TRUE | ||
SKIP_AUTOUIC TRUE | ||
) | ||
|
||
qt5_generate_moc("${_header}" "${_moc}") | ||
|
||
list(APPEND ${_sources} "${_impl}" "${_header}" "${_moc}") | ||
macro_add_file_dependencies("${_impl}" "${_moc}") | ||
set(${_sources} ${${_sources}} PARENT_SCOPE) | ||
endfunction() | ||
|
||
function(dtk_add_dbus_interfaces _sources) | ||
foreach(_current_FILE ${ARGN}) | ||
get_filename_component(_infile ${_current_FILE} ABSOLUTE) | ||
get_filename_component(_basename ${_current_FILE} NAME) | ||
# get the part before the ".xml" suffix | ||
string(TOLOWER ${_basename} _basename) | ||
string(REGEX REPLACE "(.*\\.)?([^\\.]+)\\.xml" "\\2" _basename ${_basename}) | ||
dtk_add_dbus_interface(${_sources} ${_infile} ${_basename}interface) | ||
endforeach() | ||
set(${_sources} ${${_sources}} PARENT_SCOPE) | ||
endfunction() | ||
|
||
function(dtk_generate_dbus_interface _header) # _customName OPTIONS -some -options ) | ||
set(options) | ||
set(oneValueArgs) | ||
set(multiValueArgs OPTIONS) | ||
|
||
cmake_parse_arguments(_DBUS_INTERFACE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) | ||
|
||
set(_customName ${_DBUS_INTERFACE_UNPARSED_ARGUMENTS}) | ||
|
||
get_filename_component(_in_file ${_header} ABSOLUTE) | ||
get_filename_component(_basename ${_header} NAME_WE) | ||
|
||
if(_customName) | ||
if(IS_ABSOLUTE ${_customName}) | ||
get_filename_component(_containingDir ${_customName} PATH) | ||
if(NOT EXISTS ${_containingDir}) | ||
file(MAKE_DIRECTORY "${_containingDir}") | ||
endif() | ||
set(_target ${_customName}) | ||
else() | ||
set(_target ${CMAKE_CURRENT_BINARY_DIR}/${_customName}) | ||
endif() | ||
else() | ||
set(_target ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.xml) | ||
endif() | ||
|
||
add_custom_command(OUTPUT ${_target} | ||
COMMAND ${DTK_XML2CPP} ${_DBUS_INTERFACE_OPTIONS} ${_in_file} -o ${_target} | ||
DEPENDS ${_in_file} VERBATIM | ||
) | ||
endfunction() | ||
|
||
function(dtk_add_dbus_adaptor _sources _xml_file _include _parentClass) # _optionalBasename _optionalClassName) | ||
get_filename_component(_infile ${_xml_file} ABSOLUTE) | ||
|
||
set(_optionalBasename "${ARGV4}") | ||
if(_optionalBasename) | ||
set(_basename ${_optionalBasename} ) | ||
else() | ||
string(REGEX REPLACE "(.*[/\\.])?([^\\.]+)\\.xml" "\\2adaptor" _basename ${_infile}) | ||
string(TOLOWER ${_basename} _basename) | ||
endif() | ||
|
||
set(_optionalClassName "${ARGV5}") | ||
set(_header "${CMAKE_CURRENT_BINARY_DIR}/${_basename}.h") | ||
set(_impl "${CMAKE_CURRENT_BINARY_DIR}/${_basename}.cpp") | ||
set(_moc "${CMAKE_CURRENT_BINARY_DIR}/${_basename}.moc") | ||
|
||
if(_optionalClassName) | ||
add_custom_command(OUTPUT "${_impl}" "${_header}" | ||
COMMAND ${DTK_XML2CPP} -m -a ${_basename} -c ${_optionalClassName} -i ${_include} -l ${_parentClass} ${_infile} | ||
DEPENDS ${_infile} VERBATIM | ||
) | ||
else() | ||
add_custom_command(OUTPUT "${_impl}" "${_header}" | ||
COMMAND ${DTK_XML2CPP} -m -a ${_basename} -i ${_include} -l ${_parentClass} ${_infile} | ||
DEPENDS ${_infile} VERBATIM | ||
) | ||
endif() | ||
|
||
qt5_generate_moc("${_header}" "${_moc}") | ||
set_source_files_properties("${_impl}" "${_header}" PROPERTIES | ||
SKIP_AUTOMOC TRUE | ||
SKIP_AUTOUIC TRUE | ||
) | ||
macro_add_file_dependencies("${_impl}" "${_moc}") | ||
|
||
list(APPEND ${_sources} "${_impl}" "${_header}" "${_moc}") | ||
set(${_sources} ${${_sources}} PARENT_SCOPE) | ||
endfunction() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
# Copyright 2005-2011 Kitware, Inc. | ||
# Copyright (C) 2022 The Qt Company Ltd. | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
|
||
function(dtk_add_dbus_interface _sources _interface _relativename) | ||
get_filename_component(_infile ${_interface} ABSOLUTE) | ||
get_filename_component(_basepath ${_relativename} DIRECTORY) | ||
get_filename_component(_basename ${_relativename} NAME) | ||
set(_header "${CMAKE_CURRENT_BINARY_DIR}/${_relativename}.h") | ||
set(_impl "${CMAKE_CURRENT_BINARY_DIR}/${_relativename}.cpp") | ||
if(_basepath) | ||
set(_moc "${CMAKE_CURRENT_BINARY_DIR}/${_basepath}/moc_${_basename}.cpp") | ||
else() | ||
set(_moc "${CMAKE_CURRENT_BINARY_DIR}/moc_${_basename}.cpp") | ||
endif() | ||
|
||
get_source_file_property(_nonamespace ${_interface} NO_NAMESPACE) | ||
if(_nonamespace) | ||
set(_params -N -m) | ||
else() | ||
set(_params -m) | ||
endif() | ||
|
||
get_source_file_property(_classname ${_interface} CLASSNAME) | ||
if(_classname) | ||
set(_params ${_params} -c ${_classname}) | ||
endif() | ||
|
||
get_source_file_property(_include ${_interface} INCLUDE) | ||
if(_include) | ||
set(_params ${_params} -i ${_include}) | ||
endif() | ||
|
||
add_custom_command(OUTPUT "${_impl}" "${_header}" | ||
COMMAND ${DTK_XML2CPP} ${_params} -p ${_relativename} ${_infile} | ||
DEPENDS ${_infile} ${DTK_XML2CPP} | ||
VERBATIM | ||
) | ||
|
||
set_source_files_properties("${_impl}" "${_header}" PROPERTIES | ||
SKIP_AUTOMOC TRUE | ||
SKIP_AUTOUIC TRUE | ||
) | ||
|
||
qt6_generate_moc("${_header}" "${_moc}") | ||
|
||
list(APPEND ${_sources} "${_impl}" "${_header}") | ||
macro_add_file_dependencies("${_impl}" "${_moc}") | ||
set(${_sources} ${${_sources}} PARENT_SCOPE) | ||
endfunction() | ||
|
||
function(dtk_add_dbus_interfaces _sources) | ||
foreach(_current_FILE ${ARGN}) | ||
get_filename_component(_infile ${_current_FILE} ABSOLUTE) | ||
get_filename_component(_basename ${_current_FILE} NAME) | ||
# get the part before the ".xml" suffix | ||
string(TOLOWER ${_basename} _basename) | ||
string(REGEX REPLACE "(.*\\.)?([^\\.]+)\\.xml" "\\2" _basename ${_basename}) | ||
dtk_add_dbus_interface(${_sources} ${_infile} ${_basename}interface) | ||
endforeach() | ||
set(${_sources} ${${_sources}} PARENT_SCOPE) | ||
endfunction() | ||
|
||
function(dtk_generate_dbus_interface _header) # _customName OPTIONS -some -options ) | ||
set(options) | ||
set(oneValueArgs) | ||
set(multiValueArgs OPTIONS) | ||
|
||
cmake_parse_arguments(_DBUS_INTERFACE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) | ||
|
||
set(_customName ${_DBUS_INTERFACE_UNPARSED_ARGUMENTS}) | ||
|
||
get_filename_component(_in_file ${_header} ABSOLUTE) | ||
get_filename_component(_basename ${_header} NAME_WE) | ||
|
||
if(_customName) | ||
if(IS_ABSOLUTE ${_customName}) | ||
get_filename_component(_containingDir ${_customName} PATH) | ||
if(NOT EXISTS ${_containingDir}) | ||
file(MAKE_DIRECTORY "${_containingDir}") | ||
endif() | ||
set(_target ${_customName}) | ||
else() | ||
set(_target ${CMAKE_CURRENT_BINARY_DIR}/${_customName}) | ||
endif() | ||
else() | ||
set(_target ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.xml) | ||
endif() | ||
|
||
add_custom_command(OUTPUT ${_target} | ||
COMMAND ${DTK_XML2CPP} ${_DBUS_INTERFACE_OPTIONS} ${_in_file} -o ${_target} | ||
DEPENDS ${_in_file} ${DTK_XML2CPP} | ||
VERBATIM | ||
) | ||
endfunction() | ||
|
||
function(dtk_add_dbus_adaptor _sources _xml_file _include) # _optionalParentClass _optionalRelativename _optionalClassName) | ||
get_filename_component(_infile ${_xml_file} ABSOLUTE) | ||
|
||
set(_optionalParentClass "${ARGV3}") | ||
if(_optionalParentClass) | ||
set(_parentClassOption "-l") | ||
set(_parentClass "${_optionalParentClass}") | ||
endif() | ||
|
||
set(_optionalRelativename "${ARGV4}") | ||
if(_optionalRelativename) | ||
set(_relativename ${_optionalRelativename}) | ||
else() | ||
string(REGEX REPLACE "(.*[/\\.])?([^\\.]+)\\.xml" "\\2adaptor" _relativename ${_infile}) | ||
string(TOLOWER ${_relativename} _relativename) | ||
endif() | ||
get_filename_component(_basepath ${_relativename} DIRECTORY) | ||
get_filename_component(_basename ${_relativename} NAME) | ||
|
||
set(_optionalClassName "${ARGV5}") | ||
set(_header "${CMAKE_CURRENT_BINARY_DIR}/${_relativename}.h") | ||
set(_impl "${CMAKE_CURRENT_BINARY_DIR}/${_relativename}.cpp") | ||
if(_basepath) | ||
set(_moc "${CMAKE_CURRENT_BINARY_DIR}/${_basepath}/moc_${_basename}.cpp") | ||
else() | ||
set(_moc "${CMAKE_CURRENT_BINARY_DIR}/moc_${_basename}.cpp") | ||
endif() | ||
|
||
if(_optionalClassName) | ||
add_custom_command(OUTPUT "${_impl}" "${_header}" | ||
COMMAND ${DTK_XML2CPP} -m -a ${_relativename} -c ${_optionalClassName} -i ${_include} ${_parentClassOption} ${_parentClass} ${_infile} | ||
DEPENDS ${_infile} ${DTK_XML2CPP} | ||
VERBATIM | ||
) | ||
else() | ||
add_custom_command(OUTPUT "${_impl}" "${_header}" | ||
COMMAND ${DTK_XML2CPP} -m -a ${_relativename} -i ${_include} ${_parentClassOption} ${_parentClass} ${_infile} | ||
DEPENDS ${_infile} ${DTK_XML2CPP} | ||
VERBATIM | ||
) | ||
endif() | ||
|
||
qt6_generate_moc("${_header}" "${_moc}") | ||
set_source_files_properties("${_impl}" "${_header}" PROPERTIES | ||
SKIP_AUTOMOC TRUE | ||
SKIP_AUTOUIC TRUE | ||
) | ||
macro_add_file_dependencies("${_impl}" "${_moc}") | ||
|
||
list(APPEND ${_sources} "${_impl}" "${_header}") | ||
set(${_sources} ${${_sources}} PARENT_SCOPE) | ||
endfunction() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
include(CMakeFindDependencyMacro) | ||
find_dependency(Dtk@DTK_VERSION_MAJOR@Core REQUIRED) | ||
|
||
set(DTK_VERSION_MAJOR @DTK_VERSION_MAJOR@) | ||
|
||
set (DTK_SETTINGS_TOOLS_EXECUTABLE ${DtkCore_TOOL_DIRS}/dtk-settings) | ||
|
||
if (EXISTS ${DTK_SETTINGS_TOOLS_EXECUTABLE}) | ||
|
@@ -10,4 +12,10 @@ endif () | |
include("${CMAKE_CURRENT_LIST_DIR}/Dtk@[email protected]") | ||
include("${CMAKE_CURRENT_LIST_DIR}/Dtk@[email protected]") | ||
|
||
if("${DTK_VERSION_MAJOR}" STREQUAL "6") | ||
include("${CMAKE_CURRENT_LIST_DIR}/DtkDBusMacorsQt6.cmake") | ||
else() | ||
include("${CMAKE_CURRENT_LIST_DIR}/DtkDBusMacorsQt5.cmake") | ||
endif() | ||
|
||
get_target_property(DTK_XML2CPP Dtk@DTK_VERSION_MAJOR@::Xml2Cpp LOCATION) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/*! | ||
@~chinese | ||
@ingroup dfilesystem | ||
@file include/filesystem/dstandardpaths.h | ||
|
||
@class DStandardPaths | ||
@brief DStandardPaths 类描述了一些标准的文件路径,包括XDG文件路径,locate等 | ||
|
||
@fn static QString DStandardPaths::writableLocation(QStandardPaths::StandardLocation type) | ||
@brief DStandardPaths提供兼容Snap/Dtk标准的路径模式。DStandardPaths实现了Qt的QStandardPaths主要接口。此处返回可写路径 | ||
|
||
@fn static QStringList DStandardPaths::standardLocations (QStandardPaths::StandardLocation type) | ||
@brief DStandardPaths提供兼容Snap/Dtk标准的路径模式。DStandardPaths实现了Qt的QStandardPaths主要接口。此处返回所有Standardpath | ||
|
||
@fn static QString DStandardPaths::locate(QStandardPaths::StandardLocation type, const QString &fileName, QStandardPaths::LocateOptions options = QStandardPaths::LocateFile) | ||
@brief 在 type 的标准位置查找名为 fileName 的文件或目录。选项标志允许您指定是否查找文件或目录。默认情况下,此标志设置为 LocateFile。返回找到的第一个文件或目录的绝对路径,否则返回空字符串。 | ||
|
||
@fn static QStringList DStandardPaths::locateAll(QStandardPaths::StandardLocation type, const QString &fileName, QStandardPaths::LocateOptions options = QStandardPaths::LocateFile) | ||
@brief 在类型的标准位置中按名称 fileName 查找所有文件或目录。选项标志允许您指定是否查找文件或目录。默认情况下,此标志设置为 LocateFile。返回找到的所有文件的列表。 | ||
|
||
@fn static QString DStandardPaths::findExecutable(const QString &executableName, const QStringList &paths = QStringList()) | ||
@brief 同QStandardPaths::findExecutable, 查找可执行文件 | ||
|
||
@fn static void DStandardPaths::setMode(DStandardPaths::Mode mode) | ||
@brief 同QStandardPaths::setTestModeEnabled, 设置是否是测试模式 | ||
|
||
@fn static QString DStandardPaths::homePath() | ||
@brief 返回家目录 | ||
|
||
@fn static QString DStandardPaths::homePath(const uint uid) | ||
@brief 用uid返回家目录 | ||
|
||
@fn static QString DStandardPaths::path(DStandardPaths::XDG type) | ||
@brief 返回对应的xdg目录 | ||
|
||
@fn static QString DStandardPaths::path(DStandardPaths::DSG type) | ||
@brief 返回对应Dsg目录 | ||
|
||
@fn static QStringList DStandardPaths::paths(DStandardPaths::DSG type) | ||
@brief 返回所有DSG下所有目录 | ||
|
||
@fn static QString DStandardPaths::filePath(DStandardPaths::XDG type, QString fileName) | ||
@brief 用xdg和文件名称拼接,返回文件绝对路径 | ||
|
||
@fn static QString DStandardPaths::filePath(DStandardPaths::DSG type, QString fileName) | ||
@brief 用dsg和文件名称拼接,返回文件绝对路径 | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.