diff --git a/src/ctaiHistoryTextEdit.cpp b/src/ctaiHistoryTextEdit.cpp index 9f95803..9b192d8 100644 --- a/src/ctaiHistoryTextEdit.cpp +++ b/src/ctaiHistoryTextEdit.cpp @@ -82,7 +82,7 @@ void ctaiHistoryTextEdit::init_msg_header_layout(msg_type msg_type_mode) header_info_layout->addWidget(m_msg_tokens); header_info_layout->addWidget(m_restart_to_send); header_info_layout->addWidget(m_msg_system_del); - // 3.SYSTEM消息头垂直第二排功能区 + // 3.SYSTEM消息头垂直第二排功能区 header_opts_layout->addWidget(m_msg_tools); // 4.添加到消息头主布局 header_layout->addLayout(header_info_layout); @@ -146,7 +146,6 @@ void ctaiHistoryTextEdit::on_delete_slots() // 发送删除请求信号 emit delete_requested(m_msg_sned_id); } - void ctaiHistoryTextEdit::on_copy_slots() { // 获取文本并复制到剪贴板 @@ -154,7 +153,6 @@ void ctaiHistoryTextEdit::on_copy_slots() QClipboard *clipboard = QApplication::clipboard(); clipboard->setText(text); } -// 保存文件 void ctaiHistoryTextEdit::on_save_file(int index) { QString fileName; @@ -172,26 +170,26 @@ void ctaiHistoryTextEdit::on_save_file(int index) return; } QTextStream out(&file); - switch(index){ - case 0: - temp_current_content=m_msg_history->toPlainText(); + switch (index) + { + case 0: + temp_current_content = m_msg_history->toPlainText(); break; - case 1: - temp_current_content=m_msg_history->toHtml(); + case 1: + temp_current_content = m_msg_history->toHtml(); break; - case 2: - temp_current_content=m_msg_history->toMarkdown(); + case 2: + temp_current_content = m_msg_history->toMarkdown(); break; - case 3: + case 3: break; } - if(!temp_current_content.isEmpty()){ + if (!temp_current_content.isEmpty()) + { out << m_current_content << "\n\n"; - } + } file.close(); } - -// 实现折叠功能的槽函数 void ctaiHistoryTextEdit::on_fold_slots() { m_is_folded = !m_is_folded; @@ -216,8 +214,6 @@ void ctaiHistoryTextEdit::on_display_changed(QString mode) m_msg_history->setHtml(m_math_convert->replace_tags_svg(m_current_content, m_msg_tools->getFontSize().toInt())); } } - -// tokens按钮实现功能的槽函数 void ctaiHistoryTextEdit::on_tokens_slots() { if (!m_msg_tokens_menu) @@ -251,7 +247,6 @@ void ctaiHistoryTextEdit::on_tokens_slots() m_msg_tokens_menu->addAction(m_menu_total_tokens); m_msg_tokens_menu->exec(QCursor::pos()); } - void ctaiHistoryTextEdit::on_sync_text_height() { // 防抖动处理:如果上次更新在100ms内,则延迟处理 @@ -264,7 +259,6 @@ void ctaiHistoryTextEdit::on_sync_text_height() } // 直接使用documentLayout获取高度,避免多次计算 int textHeight = m_msg_history->document()->documentLayout()->documentSize().height(); - if (textHeight > 0) { // 计算实际需要的高度 (包含边距和视口边框) @@ -302,7 +296,7 @@ void ctaiHistoryTextEdit::add_user_message(const model_data &message) QString disp_data; disp_data = QSL(message.send_user_data); m_msg_sned_id = QSL(message.send_user_id); - m_msg_history->setHtml(m_math_convert->replace_tags_svg(disp_data, m_msg_tools->getFontSize().toInt())); + m_msg_history->setText(disp_data); } void ctaiHistoryTextEdit::add_system_message(const model_data &message)