From 695f6f5a3049a0ea208920a3aa213f17d3b5dbd3 Mon Sep 17 00:00:00 2001
From: JackLee <809262979@qq.com>
Date: Wed, 12 Mar 2025 19:38:35 +0800
Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E4=B8=80=E4=BA=9B=E5=B0=8Fbu?=
=?UTF-8?q?g?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
res.qrc | 1 -
res/qss/message_style.css | 145 ------------------------------------
src/ctaiHistoryTextEdit.cpp | 2 +
src/ctaiHistoryTools.cpp | 2 +-
src/ctaiMathConvert.cpp | 55 +-------------
src/ctaiMathConvert.h | 3 +-
6 files changed, 9 insertions(+), 199 deletions(-)
delete mode 100644 res/qss/message_style.css
diff --git a/res.qrc b/res.qrc
index a47d34d..7a0c5b3 100644
--- a/res.qrc
+++ b/res.qrc
@@ -45,6 +45,5 @@
res/txt/about.txt
res/cacert/cacert.pem
- res/qss/message_style.css
diff --git a/res/qss/message_style.css b/res/qss/message_style.css
deleted file mode 100644
index b51b36f..0000000
--- a/res/qss/message_style.css
+++ /dev/null
@@ -1,145 +0,0 @@
-div.message {
- display: flex;
- justify-content: space-between;
- align-items: flex-start;
- margin: 5px;
- padding: 10px;
- border: 1px solid #ccc;
- background-color: #fff;
- margin-bottom: 10px;
-}
-
-div.header {
- color: #666;
- font-size: 12px;
- margin-bottom: 5px;
-}
-
-span.msg-id {
- color: #0366d6;
- font-weight: bold;
- margin-right: 10px;
-}
-
-div.content {
- margin: 5px 0;
-}
-
-div.button-placeholder {
- height: 25px;
- margin-top: 5px;
-}
-
-code {
- background-color: #f6f8fa;
- padding: 2px 4px;
- border-radius: 3px;
- font-family: monospace;
-}
-
-pre {
- background-color: #f6f8fa;
- padding: 16px;
- border-radius: 6px;
- overflow-x: auto;
-}
-
-h1 { font-size: 2em; margin: 0.5em 0; }
-h2 { font-size: 1.5em; margin: 0.5em 0; }
-h3 { font-size: 1.2em; margin: 0.5em 0; }
-
-a {
- color: #0366d6;
- text-decoration: none;
-}
-
-a:hover {
- text-decoration: underline;
-}
-
-li {
- margin-left: 20px;
-}
-
-pre.python-code {
- background-color: #272822;
- color: #f8f8f2;
- padding: 16px;
- border-radius: 6px;
- font-family: 'Consolas', 'Monaco', monospace;
- font-size: 14px;
- line-height: 1.5;
- overflow-x: auto;
- border-left: 3px solid #66d9ef;
-}
-
-pre.code-block {
- background-color: #f6f8fa;
- padding: 16px;
- border-radius: 6px;
- font-family: 'Consolas', 'Monaco', monospace;
- overflow-x: auto;
- border-left: 3px solid #e1e4e8;
-}
-
-span.math-inline {
- font-family: 'Times New Roman', serif;
- font-size: 16px;
- padding: 0 4px;
-}
-
-div.math-block {
- font-family: 'Times New Roman', serif;
- font-size: 18px;
- margin: 1em 0;
- padding: 1em;
- text-align: center;
- background-color: #f8f9fa;
- border-left: 3px solid #2196f3;
-}
-
-span.fraction {
- display: inline-block;
- vertical-align: middle;
- text-align: center;
- padding: 0 3px;
-}
-
-span.numerator {
- display: block;
- border-bottom: 1px solid;
- padding: 0 3px;
-}
-
-span.denominator {
- display: block;
- padding: 0 3px;
-}
-
-sup {
- font-size: 0.75em;
- vertical-align: super;
-}
-
-sub {
- font-size: 0.75em;
- vertical-align: sub;
-}
-
-.message-content {
- flex: 1;
- margin-right: 10px;
-}
-
-.button-container {
- flex-shrink: 0;
- margin-left: 10px;
- margin: 5px 0;
- text-align: left;
-}
-
-.message-divider {
- border: none;
- border-top: 1px solid #eee;
- margin: 10px 0 5px 0;
-}
\ No newline at end of file
diff --git a/src/ctaiHistoryTextEdit.cpp b/src/ctaiHistoryTextEdit.cpp
index 2fbac46..d400040 100644
--- a/src/ctaiHistoryTextEdit.cpp
+++ b/src/ctaiHistoryTextEdit.cpp
@@ -39,6 +39,8 @@ void ctaiHistoryTextEdit::initMsgHistoryLayout()
history_layout = new QVBoxLayout();
// 历史信息QTextEdit
m_msg_history = new QTextEdit();
+ QString style = "";
+ m_msg_history->document()->setDefaultStyleSheet(style);
m_math_convert = new ctaiMathConvert();
m_msg_history->setUndoRedoEnabled(false); // 关闭撤销历史以节省内存
m_msg_history->setAcceptRichText(true);
diff --git a/src/ctaiHistoryTools.cpp b/src/ctaiHistoryTools.cpp
index b063697..8f5066a 100644
--- a/src/ctaiHistoryTools.cpp
+++ b/src/ctaiHistoryTools.cpp
@@ -83,7 +83,7 @@ void ctaiHistoryTools::slotsSaveMenu()
for(int i=0;i<=ds_save_menu.count()-1;i++){
QAction* action=new QAction(ds_save_menu[i]);
action->setObjectName(QString::number(i));
- connect(action, SIGNAL(triggered(bool)), this, SLOT(on_save_action_slots()));
+ connect(action, SIGNAL(triggered(bool)), this, SLOT(slotsSaveAction()));
save_ver.push_back(action);
m_msg_save_menu->addAction(action);
}
diff --git a/src/ctaiMathConvert.cpp b/src/ctaiMathConvert.cpp
index 234bae9..f7c3489 100644
--- a/src/ctaiMathConvert.cpp
+++ b/src/ctaiMathConvert.cpp
@@ -137,64 +137,17 @@ QString ctaiMathConvert::markdown_to_html(const QString &text)
}
// 转换为HTML
char *html = cmark_render_html(doc, options, NULL);
- // 转换回QString并处理代码块
QString result = QString::fromUtf8(html);
- // 添加基础CSS样式
- const QString css = R"(
-
- )";
- // 在
标签后插入CSS
- result.replace("", "" + css);
- result.replace("