解决Cmake-GFM空间名冲突
This commit is contained in:
parent
b44855bf6e
commit
cee62df187
@ -63,6 +63,8 @@ include_directories(${JSON}/include)
|
|||||||
find_package(CURL REQUIRED)
|
find_package(CURL REQUIRED)
|
||||||
|
|
||||||
#cmark-gfm
|
#cmark-gfm
|
||||||
|
add_definitions(-DCMARK_GFM_STATIC_DEFINE)
|
||||||
|
add_definitions(-DCMARK_STATIC_DEFINE)
|
||||||
add_subdirectory(${PROJECT_SOURCE_DIR}/3rdparty/cmark-gfm)
|
add_subdirectory(${PROJECT_SOURCE_DIR}/3rdparty/cmark-gfm)
|
||||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/cmark-gfm/src)
|
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/cmark-gfm/src)
|
||||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/cmark-gfm/extensions)
|
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/cmark-gfm/extensions)
|
||||||
|
|||||||
@ -39,6 +39,7 @@ void ctaiHistoryTextEdit::initMsgHistoryLayout()
|
|||||||
history_layout = new QVBoxLayout();
|
history_layout = new QVBoxLayout();
|
||||||
// 历史信息QTextEdit
|
// 历史信息QTextEdit
|
||||||
m_msg_history = new QTextEdit();
|
m_msg_history = new QTextEdit();
|
||||||
|
m_cef_widget=new CefWidget();
|
||||||
m_math_convert = new ctaiMathConvert();
|
m_math_convert = new ctaiMathConvert();
|
||||||
m_msg_history->setUndoRedoEnabled(false); // 关闭撤销历史以节省内存
|
m_msg_history->setUndoRedoEnabled(false); // 关闭撤销历史以节省内存
|
||||||
m_msg_history->setAcceptRichText(true);
|
m_msg_history->setAcceptRichText(true);
|
||||||
@ -46,7 +47,7 @@ void ctaiHistoryTextEdit::initMsgHistoryLayout()
|
|||||||
m_msg_history->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
m_msg_history->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||||
m_msg_history->setObjectName("m_msg_history");
|
m_msg_history->setObjectName("m_msg_history");
|
||||||
m_msg_history->setReadOnly(true);
|
m_msg_history->setReadOnly(true);
|
||||||
history_layout->addWidget(m_msg_history);
|
history_layout->addWidget(m_cef_widget);
|
||||||
history_layout->addWidget(msg_line);
|
history_layout->addWidget(msg_line);
|
||||||
history_layout->setContentsMargins(0, 0, 0, 0);
|
history_layout->setContentsMargins(0, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -37,6 +37,7 @@
|
|||||||
#include "ctai_base.h"
|
#include "ctai_base.h"
|
||||||
#include "ctaiMathConvert.h"
|
#include "ctaiMathConvert.h"
|
||||||
#include "ctaiHistoryTools.h"
|
#include "ctaiHistoryTools.h"
|
||||||
|
#include "QCefWidget/CefWidget.h"
|
||||||
std::mutex m_mutex;
|
std::mutex m_mutex;
|
||||||
class ctaiHistoryTextEdit : public QWidget
|
class ctaiHistoryTextEdit : public QWidget
|
||||||
{
|
{
|
||||||
@ -72,6 +73,7 @@ private:
|
|||||||
void connect_signals(msg_type msg_type_mode); // 连接信号和槽
|
void connect_signals(msg_type msg_type_mode); // 连接信号和槽
|
||||||
void set_default_opts();
|
void set_default_opts();
|
||||||
private:
|
private:
|
||||||
|
CefWidget* m_cef_widget={};
|
||||||
ctaiMathConvert *m_math_convert;
|
ctaiMathConvert *m_math_convert;
|
||||||
QFrame *msg_line;
|
QFrame *msg_line;
|
||||||
QSpacerItem *sparcer_item = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Fixed);
|
QSpacerItem *sparcer_item = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||||
|
|||||||
@ -126,11 +126,11 @@ QString ctaiMathConvert::markdown_to_html(const QString &text)
|
|||||||
CMARK_OPT_FOOTNOTES |
|
CMARK_OPT_FOOTNOTES |
|
||||||
CMARK_OPT_STRIKETHROUGH_DOUBLE_TILDE |
|
CMARK_OPT_STRIKETHROUGH_DOUBLE_TILDE |
|
||||||
CMARK_OPT_TABLE_PREFER_STYLE_ATTRIBUTES |
|
CMARK_OPT_TABLE_PREFER_STYLE_ATTRIBUTES |
|
||||||
CMARK_NODE_TEXT|
|
cmark::CMARK_NODE_TEXT|
|
||||||
CMARK_OPT_FULL_INFO_STRING;
|
CMARK_OPT_FULL_INFO_STRING;
|
||||||
|
|
||||||
// 解析Markdown为AST
|
// 解析Markdown为AST
|
||||||
cmark_node *doc = cmark_parse_document(markdown.constData(), markdown.size(), options);
|
cmark::cmark_node *doc = cmark::cmark_parse_document(markdown.constData(), markdown.size(), options);
|
||||||
if (debug_node_print)
|
if (debug_node_print)
|
||||||
{
|
{
|
||||||
// 递归打印AST节点
|
// 递归打印AST节点
|
||||||
@ -158,13 +158,13 @@ void ctaiMathConvert::replace_symbol(QString &context)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 添加新的辅助方法用于打印AST节点
|
// 添加新的辅助方法用于打印AST节点
|
||||||
void ctaiMathConvert::print_ast_node(cmark_node *node, int level)
|
void ctaiMathConvert::print_ast_node(cmark::cmark_node *node, int level)
|
||||||
{
|
{
|
||||||
if (!node)
|
if (!node)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// 获取节点类型
|
// 获取节点类型
|
||||||
const char *type_str = cmark_node_get_type_string(node);
|
const char *type_str = cmark::cmark_node_get_type_string(node);
|
||||||
|
|
||||||
// 打印缩进和节点类型
|
// 打印缩进和节点类型
|
||||||
QString indent = QString(" ").repeated(level * 2);
|
QString indent = QString(" ").repeated(level * 2);
|
||||||
@ -178,11 +178,11 @@ void ctaiMathConvert::print_ast_node(cmark_node *node, int level)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 递归处理子节点
|
// 递归处理子节点
|
||||||
cmark_node *child = cmark_node_first_child(node);
|
cmark::cmark_node *child = cmark_node_first_child(node);
|
||||||
while (child)
|
while (child)
|
||||||
{
|
{
|
||||||
print_ast_node(child, level + 1);
|
print_ast_node(child, level + 1);
|
||||||
child = cmark_node_next(child);
|
child = cmark::cmark_node_next(child);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,12 +1,7 @@
|
|||||||
#ifndef CTAIMATHCONVERT_H
|
#ifndef CTAIMATHCONVERT_H
|
||||||
#define CTAIMATHCONVERT_H
|
#define CTAIMATHCONVERT_H
|
||||||
|
|
||||||
// 然后包含 cmark-gfm 相关头文件
|
// Qt 相关头文件放在最前面
|
||||||
#include "cmark-gfm.h"
|
|
||||||
#include "cmark-gfm-extension_api.h"
|
|
||||||
#include "cmark-gfm-core-extensions.h"
|
|
||||||
#include <registry.h>
|
|
||||||
// Qt 相关头文件
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
@ -19,6 +14,14 @@
|
|||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
#include <QRegularExpressionMatchIterator>
|
#include <QRegularExpressionMatchIterator>
|
||||||
|
|
||||||
|
// 使用命名空间来隔离 cmark-gfm
|
||||||
|
namespace cmark {
|
||||||
|
#include "cmark-gfm.h"
|
||||||
|
#include "cmark-gfm-extension_api.h"
|
||||||
|
#include "cmark-gfm-core-extensions.h"
|
||||||
|
#include <registry.h>
|
||||||
|
}
|
||||||
|
|
||||||
// LaTeX 相关头文件
|
// LaTeX 相关头文件
|
||||||
#include "latex.h"
|
#include "latex.h"
|
||||||
#include "platform/qt/graphic_qt.h"
|
#include "platform/qt/graphic_qt.h"
|
||||||
@ -55,7 +58,7 @@ private:
|
|||||||
QByteArray svg_to_base64(QPixmap& pix);
|
QByteArray svg_to_base64(QPixmap& pix);
|
||||||
QString markdown_to_html(const QString& text);
|
QString markdown_to_html(const QString& text);
|
||||||
QString fix_img_str_line_height(QString html);
|
QString fix_img_str_line_height(QString html);
|
||||||
void print_ast_node(cmark_node *node, int level);
|
void print_ast_node(cmark::cmark_node *node, int level);
|
||||||
void replace_symbol(QString& context);
|
void replace_symbol(QString& context);
|
||||||
void replace_css(QString& context);
|
void replace_css(QString& context);
|
||||||
TexGuard texGuard;
|
TexGuard texGuard;
|
||||||
|
|||||||
25
src/main.cpp
25
src/main.cpp
@ -19,10 +19,10 @@ int main(int argc, char *argv[])
|
|||||||
config.addCommandLineSwitch("use-alloy-style");
|
config.addCommandLineSwitch("use-alloy-style");
|
||||||
config.addCommandLineSwitch("off-screen-rendering-enabled");
|
config.addCommandLineSwitch("off-screen-rendering-enabled");
|
||||||
config.addCommandLineSwitch("multi-threaded-message-loop");
|
config.addCommandLineSwitch("multi-threaded-message-loop");
|
||||||
//config.addCommandLineSwitch("external-message-pump");
|
config.addCommandLineSwitch("external-message-pump");
|
||||||
//config.addCommandLineSwitch("enable-chrome-runtime");
|
config.addCommandLineSwitch("enable-chrome-runtime");
|
||||||
//config.addCommandLineSwitch("enable-gpu");
|
config.addCommandLineSwitch("enable-gpu");
|
||||||
//config.addCommandLineSwitch("use-views");
|
config.addCommandLineSwitch("use-views");
|
||||||
//config.addCommandLineSwitch("site-per-process");
|
//config.addCommandLineSwitch("site-per-process");
|
||||||
config.addCommandLineSwitch("no-sandbox");
|
config.addCommandLineSwitch("no-sandbox");
|
||||||
//config.addCommandLineSwitch("in-process-gpu");
|
//config.addCommandLineSwitch("in-process-gpu");
|
||||||
@ -30,17 +30,16 @@ int main(int argc, char *argv[])
|
|||||||
config.addCommandLineSwitch("enable-chrome-runtime");
|
config.addCommandLineSwitch("enable-chrome-runtime");
|
||||||
config.addCommandLineSwitch("start-stack-profiler");
|
config.addCommandLineSwitch("start-stack-profiler");
|
||||||
//config.addCommandLineSwitchWithValue("type","gpu-process");
|
//config.addCommandLineSwitchWithValue("type","gpu-process");
|
||||||
//config.addCommandLineSwitchWithValue("ignore-certificate-errors","true");
|
config.addCommandLineSwitchWithValue("ignore-certificate-errors","true");
|
||||||
//config.addCommandLineSwitchWithValue("enable-gpu-rasterizatio","true");
|
config.addCommandLineSwitchWithValue("enable-gpu-rasterizatio","true");
|
||||||
//config.addCommandLineSwitchWithValue("enable-accelerated-video","true");
|
config.addCommandLineSwitchWithValue("enable-accelerated-video","true");
|
||||||
//config.addCommandLineSwitchWithValue("use-fake-ui-for-media-stream","true");
|
config.addCommandLineSwitchWithValue("use-fake-ui-for-media-stream","true");
|
||||||
//config.addCommandLineSwitchWithValue("use-fake-device-for-media-stream","true");
|
config.addCommandLineSwitchWithValue("use-fake-device-for-media-stream","true");
|
||||||
//config.addCommandLineSwitchWithValue("renderer-process-limit", "1");
|
//config.addCommandLineSwitchWithValue("renderer-process-limit", "1");
|
||||||
//config.addCommandLineSwitchWithValue("disable-features", "BlinkGenPropertyTrees,TranslateUI,site-per-process");
|
config.addCommandLineSwitchWithValue("disable-features", "BlinkGenPropertyTrees,TranslateUI,site-per-process");
|
||||||
QCefContext cefContext(&a, argc, argv, &config);
|
QCefContext cefContext(&a, argc, argv, &config);
|
||||||
|
//CefWidget cw;
|
||||||
CefWidget cw;
|
//cw.show();
|
||||||
cw.show();
|
|
||||||
qputenv("QT_QPA_PLATFORM", "windows:fontengine=freetype");
|
qputenv("QT_QPA_PLATFORM", "windows:fontengine=freetype");
|
||||||
// 加载语言包
|
// 加载语言包
|
||||||
QTranslator qtBaseTranslator;
|
QTranslator qtBaseTranslator;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user