Skip to content

Commit

Permalink
sync: from linuxdeepin/dtkcore
Browse files Browse the repository at this point in the history
Synchronize source files from linuxdeepin/dtkcore.

Source-pull-request: linuxdeepin/dtkcore#392
  • Loading branch information
deepin-ci-robot committed Nov 14, 2023
1 parent 5b38c9c commit 3905872
Show file tree
Hide file tree
Showing 11 changed files with 417 additions and 12 deletions.
11 changes: 11 additions & 0 deletions LICENSES/BSD-3-Clause.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Copyright (c) 2017 - 2022 UnionTech Software Technology Co., Ltd.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
128 changes: 128 additions & 0 deletions cmake/DtkTools/Dtk5DBusMacors.cmake
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()
148 changes: 148 additions & 0 deletions cmake/DtkTools/Dtk6DBusMacors.cmake
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()
2 changes: 1 addition & 1 deletion cmake/DtkTools/DtkSettingsToolsMacros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function(DTK_CREATE_I18N_FROM_JSON _generated_file_list _input_json_file _output
get_filename_component(_input_json_abs_path ${_input_json_file} ABSOLUTE)
get_filename_component(_input_json_abs_dir ${_input_json_abs_path} DIRECTORY)
set (_output_cpp_abs_path ${_input_json_abs_dir}/${_output_cpp_file_name})

if (DTK_SETTINGS_TOOLS_FOUND)
add_custom_command(OUTPUT ${_output_cpp_abs_path}
COMMAND ${DTK_SETTINGS_TOOLS_EXECUTABLE}
Expand Down
1 change: 1 addition & 0 deletions cmake/DtkTools/DtkToolsConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ endif ()

include("${CMAKE_CURRENT_LIST_DIR}/Dtk@[email protected]")
include("${CMAKE_CURRENT_LIST_DIR}/Dtk@[email protected]")
include("${CMAKE_CURRENT_LIST_DIR}/Dtk@[email protected]")

get_target_property(DTK_XML2CPP Dtk@DTK_VERSION_MAJOR@::Xml2Cpp LOCATION)
47 changes: 47 additions & 0 deletions docs/filesystem/dstandardpaths.zh_CN.dox
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和文件名称拼接,返回文件绝对路径
*/
5 changes: 5 additions & 0 deletions dtkcore.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ install(FILES cmake/DtkTools/DtkSettingsToolsMacros.cmake
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/Dtk${DTK_VERSION_MAJOR}Tools"
RENAME Dtk${DTK_VERSION_MAJOR}SettingsToolsMacros.cmake)



install(FILES "cmake/DtkTools/Dtk${DTK_VERSION_MAJOR}DBusMacors.cmake"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/Dtk${DTK_VERSION_MAJOR}Tools")

if (NOT DTK_VERSION_MAJOR)
set(DCONFIG_DEPRECATED_FUNCS [=[
# deprecated since dtk6
Expand Down
Loading

0 comments on commit 3905872

Please sign in to comment.