Conversation
Synchronize source files from linuxdeepin/dtkgui. Source-pull-request: linuxdeepin/dtkgui#345
Contributor
Author
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: deepin-ci-robot The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Contributor
Author
deepin pr auto reviewGit Diff 代码审查报告总体评价这次提交主要涉及DTK GUI库的CMake配置更新和Qt版本兼容性改进,特别是针对Qt6.10版本的适配。整体改动合理,但有一些细节可以优化。 具体问题与改进建议1. CMake配置改进问题1: 在 改进建议: # 建议添加明确的版本检查注释
# Only use libxdg under Qt5, as Qt6 has different icon loading mechanisms
if(NOT DTK_DISABLE_LIBXDG AND ${QT_VERSION_MAJOR} STREQUAL "5")问题2: 在多个地方添加了Qt6.10版本的私有模块检查,但没有统一处理。 改进建议: function(find_qt_private_modules)
if(${QT_VERSION_MAJOR} STREQUAL "6" AND ${Qt6Core_VERSION} VERSION_GREATER_EQUAL "6.10.0")
set(QT_NO_PRIVATE_MODULE_WARNING ON PARENT_SCOPE)
find_package(Qt6 REQUIRED COMPONENTS CorePrivate GuiPrivate WaylandClientPrivate)
endif()
endfunction()2. 代码逻辑改进问题1: 在 改进建议: #define THEME_CHANGE_EVENT_ARGS \
(QT_VERSION >= QT_VERSION_CHECK(6, 10, 0) ? QWindowSystemInterfacePrivate::ThemeChangeEvent() \
: QWindowSystemInterfacePrivate::ThemeChangeEvent(nullptr))
void DGuiApplicationHelperPrivate::notifyAppThemeChangedByEvent()
{
THEME_CHANGE_EVENT_ARGS event;
QGuiApplicationPrivate::processThemeChanged(&event);
}问题2: 文档注释中的空格不一致。 改进建议: /*!
\enum DGuiApplicationHelper::ColorType
DGuiApplicationHelper::ColorType 定义了主题类型.
\var DGuiApplicationHelper::ColorType DGuiApplicationHelper::UnknownType
未知主题(浅色主题或深色主题).
\var DGuiApplicationHelper::ColorType DGuiApplicationHelper::LightType
浅色主题.
\var DGuiApplicationHelper::ColorType DGuiApplicationHelper::DarkType
深色主题.
*/3. 性能与安全考虑问题1: 在加载翻译文件时,对每个locale都进行了检查,可能存在性能问题。 改进建议: bool DGuiApplicationHelper::loadTranslator(const QString &fileName, const QList<QLocale> &locales)
{
bool found = false;
QList<QString> localeNames;
for (const QLocale &locale : locales) {
QString path = QString(":/translations/%1_%2.qm").arg(fileName).arg(locale.name());
if (QFile::exists(path)) {
found = true;
continue;
}
if (locale.language() != QLocale::English) {
localeNames << locale.name();
}
}
if (!found && !localeNames.isEmpty()) {
qWarning() << fileName << "can not find qm files for locales" << localeNames;
return false;
}
return true;
}4. 代码格式与风格问题1: 一些地方的缩进和空格不一致。 改进建议:
问题2: 长行没有适当换行。 改进建议: # 不好的写法
target_link_libraries(${BIN_NAME} PRIVATE Qt${QT_VERSION_MAJOR}XdgIconLoader)
# 改进后的写法
target_link_libraries(${BIN_NAME}
PRIVATE
Qt${QT_VERSION_MAJOR}XdgIconLoader
)总结
这些改进将提高代码的可维护性、可读性和性能,同时保持向后兼容性。 |
Contributor
|
Note
详情{
"src/kernel/dguiapplicationhelper.cpp": [
{
"line": " QString socket_key = \"_d_dtk_single_instance_\";",
"line_number": 1484,
"rule": "S106",
"reason": "Var naming | 2ad926d35b"
}
]
} |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Synchronize source files from linuxdeepin/dtkgui.
Source-pull-request: linuxdeepin/dtkgui#345