Skip to content
Merged
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
11 changes: 11 additions & 0 deletions misc/configs/org.deepin.editor.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,17 @@
"description": "Default text encoding, ASCII and unknown encoding will use the configured default encoding,the default is UTF-8",
"permissions": "readwrite",
"visibility": "private"
},
"log_rules": {
"value": "org.deepin.editor*.debug=false;org.deepin.editor*.info=false;org.deepin.editor*.warning=true",
"serial": 0,
"flags": ["global"],
"name": "log rules",
"name[zh_CN]": "日志规则",
"description": "log rules",
"description[zh_CN]": "日志规则",
"permissions": "readwrite",
"visibility": "public"
}
}
}
6 changes: 3 additions & 3 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ link_directories(${chardet_LIBRARY_DIRS})

# Tell CMake to create the executable
add_executable(deepin-editor ${SRCS} deepin-editor.qrc)
if(CMAKE_BUILD_TYPE STREQUAL "Release")
target_compile_definitions(deepin-editor PRIVATE QT_NO_DEBUG_OUTPUT)
endif()
# 注意:不要在 Release 下定义 QT_NO_DEBUG_OUTPUT——它会把 qCDebug 编译成硬性空操作
# (编译期 IsOutputEnabled=false),导致调试模式动态开到 debug 级也无法输出 qCDebug 日志;
# 分类日志关闭时仅有一次布尔判断开销(Qt 惰性求值),参数不会被计算
target_link_libraries(deepin-editor
${LINK_LIBS}
${chardet_LIBRARY_DIRS}
Expand Down
13 changes: 7 additions & 6 deletions src/common/CSyntaxHighlighter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,26 @@
//
// SPDX-License-Identifier: GPL-3.0-or-later

#include "ddlog.h"

Check warning on line 5 in src/common/CSyntaxHighlighter.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "ddlog.h" not found.
#include "CSyntaxHighlighter.h"
#include <QDebug>

Check warning on line 7 in src/common/CSyntaxHighlighter.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QDebug> not found. Please note: Cppcheck does not need standard library headers to get proper results.

CSyntaxHighlighter::CSyntaxHighlighter(QObject *parent):
SyntaxHighlighter (parent),
m_bHighlight(false)
{
qDebug() << "CSyntaxHighlighter constructor";
qCDebug(appLog) << "CSyntaxHighlighter constructor";
}

CSyntaxHighlighter::CSyntaxHighlighter(QTextDocument *pDocument):
SyntaxHighlighter (pDocument),m_bHighlight(false)
{
qDebug() << "CSyntaxHighlighter constructor with QTextDocument*";
qCDebug(appLog) << "CSyntaxHighlighter constructor with QTextDocument*";
}

void CSyntaxHighlighter::setEnableHighlight(bool isEnable)
{
qDebug() << "CSyntaxHighlighter::setEnableHighlight()" << isEnable;
qCDebug(appLog) << "CSyntaxHighlighter::setEnableHighlight()" << isEnable;
m_bHighlight = isEnable;
// 开关变更后重新高亮,避免旧格式残留至下次文档变更,
// 与 setInvalidCharHighlight 的自动 rehighlight 行为保持一致
Expand All @@ -29,7 +30,7 @@

void CSyntaxHighlighter::setInvalidCharHighlight(bool enable)
{
qDebug() << "CSyntaxHighlighter::setInvalidCharHighlight()" << enable;
qCDebug(appLog) << "CSyntaxHighlighter::setInvalidCharHighlight()" << enable;
m_bInvalidCharHighlight = enable;
if (enable) {
setEnableHighlight(true);
Expand All @@ -40,11 +41,11 @@
void CSyntaxHighlighter::highlightBlock(const QString &text)
{
if (!m_bHighlight) {
qDebug() << "CSyntaxHighlighter::highlightBlock() is disabled";
qCDebug(appLog) << "CSyntaxHighlighter::highlightBlock() is disabled";
return;
}

qDebug() << "CSyntaxHighlighter::highlightBlock()";
qCDebug(appLog) << "CSyntaxHighlighter::highlightBlock()";
KSyntaxHighlighting::SyntaxHighlighter::highlightBlock(text);

// 叠加 \00 无效字符高亮:红色背景 + 白色文字
Expand Down
63 changes: 32 additions & 31 deletions src/common/config.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2023-2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

#include "ddlog.h"

Check warning on line 5 in src/common/config.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "ddlog.h" not found.
#include "config.h"

#include <iconv.h>

Check warning on line 8 in src/common/config.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <iconv.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.

#include <QDebug>

Expand All @@ -25,10 +26,10 @@
*/
bool detectIconvUse2005Standard()
{
qDebug() << "Detecting iconv use GB18030-2005 standard";
qCDebug(appLog) << "Detecting iconv use GB18030-2005 standard";
iconv_t handle = iconv_open("UTF-8", "GB18030");
if (handle == reinterpret_cast<iconv_t>(-1)) {
qWarning() << "Failed to open iconv handle for GB18030";
qCWarning(appLog) << "Failed to open iconv handle for GB18030";
return true;
}

Expand All @@ -43,16 +44,16 @@
iconv_close(handle);

if (ret == static_cast<size_t>(-1)) {
qWarning() << "Failed to convert GB18030 to UTF-8";
qCWarning(appLog) << "Failed to convert GB18030 to UTF-8";
return true;
}

if (!output.contains("\uE816")) {
qInfo() << "Current iconv uses GB18030-2005 standard";
qCInfo(appLog) << "Current iconv uses GB18030-2005 standard";
return true;
}

qInfo() << "Current iconv uses GB18030-2022 standard";
qCInfo(appLog) << "Current iconv uses GB18030-2022 standard";
return false;
}

Expand All @@ -67,67 +68,67 @@
: QObject(parent)
, encoding("UTF-8")
{
qDebug() << "Initializing Config instance";
qCDebug(appLog) << "Initializing Config instance";
#ifdef DTKCORE_CLASS_DConfigFile
dconfig = DConfig::create("org.deepin.editor", "org.deepin.editor");
if (dconfig->isValid()) {
qDebug() << "DConfig is valid";
qCDebug(appLog) << "DConfig is valid";
// 默认提高GB18030识别率
improveGB18030 = !dconfig->value(g_keyDisableImproveGB18030).toBool();
qInfo() << qPrintable("DConfig::ImproveGB18030:") << improveGB18030;
qCInfo(appLog) << qPrintable("DConfig::ImproveGB18030:") << improveGB18030;

patchedIconv = dconfig->value(g_keyEnablePatchedIconv).toBool();
qInfo() << qPrintable("DConfig::enablePatchedIconv:") << patchedIconv;
qCInfo(appLog) << qPrintable("DConfig::enablePatchedIconv:") << patchedIconv;

encoding = dconfig->value(g_keyDefaultEncoding).toByteArray().toUpper();
qInfo() << qPrintable("DConfig::defaultEncoding") << encoding;
qCInfo(appLog) << qPrintable("DConfig::defaultEncoding") << encoding;

connect(dconfig, &DConfig::valueChanged, this, [this](const QString &key) {
qDebug() << "Config value changed for key:" << key;
qCDebug(appLog) << "Config value changed for key:" << key;
if (key == g_keyDisableImproveGB18030) {
this->improveGB18030 = !this->dconfig->value(g_keyDisableImproveGB18030).toBool();
qInfo() << qPrintable("DConfig::ImproveGB18030 changed:") << improveGB18030;
qDebug() << "improveGB18030 changed to" << this->improveGB18030;
qCInfo(appLog) << qPrintable("DConfig::ImproveGB18030 changed:") << improveGB18030;
qCDebug(appLog) << "improveGB18030 changed to" << this->improveGB18030;
} else if (key == g_keyEnablePatchedIconv) {
this->patchedIconv = dconfig->value(g_keyEnablePatchedIconv).toBool();
qInfo() << qPrintable("DConfig::enablePatchedIconv changed:") << patchedIconv;
qDebug() << "patchedIconv changed to" << this->patchedIconv;
qCInfo(appLog) << qPrintable("DConfig::enablePatchedIconv changed:") << patchedIconv;
qCDebug(appLog) << "patchedIconv changed to" << this->patchedIconv;
} else if (key == g_keyDefaultEncoding) {
this->encoding = dconfig->value(g_keyDefaultEncoding).toByteArray().toUpper();
qInfo() << qPrintable("DConfig::defaultEncoding changed:") << encoding;
qDebug() << "encoding changed to" << this->encoding;
qCInfo(appLog) << qPrintable("DConfig::defaultEncoding changed:") << encoding;
qCDebug(appLog) << "encoding changed to" << this->encoding;
}
});

} else {
qWarning() << qPrintable("org.deepin.editor DConfig not valid!");
qCWarning(appLog) << qPrintable("org.deepin.editor DConfig not valid!");
}
#else
qWarning() << "DConfig is not supported by DTK!";
qCWarning(appLog) << "DConfig is not supported by DTK!";
#endif

// 检测当前iconv使用的GB18030编码是否为2005标准(2005标准强制使用上层补丁版本)
iocnvUse2005Standard = detectIconvUse2005Standard();
qDebug() << "Leaving Config::Config";
qCDebug(appLog) << "Leaving Config::Config";
}

Config::~Config()
{
qDebug() << "Destroying Config instance";
qCDebug(appLog) << "Destroying Config instance";
#ifdef DTKCORE_CLASS_DConfigFile
if (dconfig) {
qDebug() << "Deleting dconfig";
qCDebug(appLog) << "Deleting dconfig";
delete dconfig;
}
#endif
qDebug() << "Leaving Config::~Config";
qCDebug(appLog) << "Leaving Config::~Config";
}

Config *Config::instance()
{
qDebug() << "Getting Config singleton instance";
qCDebug(appLog) << "Getting Config singleton instance";
static Config config;
qDebug() << "Leaving Config::instance";
qCDebug(appLog) << "Leaving Config::instance";
return &config;
}

Expand All @@ -136,7 +137,7 @@
*/
bool Config::enableImproveGB18030() const
{
qDebug() << "Entering Config::enableImproveGB18030, returning" << improveGB18030;
qCDebug(appLog) << "Entering Config::enableImproveGB18030, returning" << improveGB18030;
return improveGB18030;
}

Expand All @@ -146,7 +147,7 @@
*/
bool Config::enablePatchedIconv() const
{
qDebug() << "Entering Config::enablePatchedIconv, returning" << (patchedIconv || iocnvUse2005Standard);
qCDebug(appLog) << "Entering Config::enablePatchedIconv, returning" << (patchedIconv || iocnvUse2005Standard);
return patchedIconv || iocnvUse2005Standard;
}

Expand All @@ -155,11 +156,11 @@
*/
QByteArray Config::defaultEncoding() const
{
qDebug() << "Entering Config::defaultEncoding";
qCDebug(appLog) << "Entering Config::defaultEncoding";
if (encoding.isEmpty()) {
qDebug() << "Encoding is empty, returning UTF-8";
qCDebug(appLog) << "Encoding is empty, returning UTF-8";
return QByteArray("UTF-8");
}
qDebug() << "Returning configured encoding:" << encoding;
qCDebug(appLog) << "Returning configured encoding:" << encoding;
return encoding;
}
7 changes: 4 additions & 3 deletions src/common/dbusinterface.cpp
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
// SPDX-FileCopyrightText: 2011-2022 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2011-2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

#include "ddlog.h"

Check warning on line 5 in src/common/dbusinterface.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "ddlog.h" not found.
#include "dbusinterface.h"

#include <QDebug>

Check warning on line 8 in src/common/dbusinterface.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QDebug> not found. Please note: Cppcheck does not need standard library headers to get proper results.

SaveFileInterface::SaveFileInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent)
: QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent)
{
qDebug() << "SaveFileInterface created for" << service << path;
qCDebug(appLog) << "SaveFileInterface created for" << service << path;
}

SaveFileInterface::~SaveFileInterface()
{
qDebug() << "SaveFileInterface destroyed for" << service() << path();
qCDebug(appLog) << "SaveFileInterface destroyed for" << service() << path();
}
Loading
Loading