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