From 9d18149a2cff3c86a95507e1812ebb6afee21d30 Mon Sep 17 00:00:00 2001 From: sjxx <321389626@qq.com> Date: Tue, 5 Nov 2024 16:02:39 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=BA=A6=E5=AE=9A=E9=80=89?= =?UTF-8?q?=E9=A1=B9=E7=9A=84=E5=8F=96=E6=B6=88=E8=A1=8C=E4=B8=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ui/dialog.cpp | 8 ++++++-- ui/utils.cpp | 1 + ui/widget.cpp | 39 +++++++++++++++++++++++++++++++++++++++ ui/widget.h | 1 + 4 files changed, 47 insertions(+), 2 deletions(-) diff --git a/ui/dialog.cpp b/ui/dialog.cpp index a11005ab..a2854d27 100644 --- a/ui/dialog.cpp +++ b/ui/dialog.cpp @@ -954,8 +954,11 @@ void Widget::set_DateDialog() { QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, date_dialog); // 创建 QDialogButtonBox 用于确定按钮 layout->addWidget(buttonBox); - connect(buttonBox, &QDialogButtonBox::accepted, this, &Widget::set_date); - connect(buttonBox, &QDialogButtonBox::rejected, date_dialog, &QDialog::reject); + connect(buttonBox, &QDialogButtonBox::accepted, this, &Widget::set_date);// 点击确定按钮 + connect(buttonBox, &QDialogButtonBox::rejected, date_dialog, &QDialog::reject);// 点击取消按钮,实现对话框关闭 + connect(buttonBox, &QDialogButtonBox::rejected, this, &Widget::cancel_date);// 点击取消按钮,采取后续操作 + connect(date_dialog, &QDialog::rejected, this, &Widget::cancel_date);// 点击关闭按钮,采取后续操作 + prompt_template_change(); //先应用提示词模板 date_prompt_TextEdit->setText(ui_date_prompt); date_dialog->setWindowTitle(jtr("date")); @@ -1561,6 +1564,7 @@ void Widget::get_date() { ui_stablediffusion_ischecked = stablediffusion_checkbox->isChecked(); ui_interpreter_ischecked = interpreter_checkbox->isChecked(); + //记录自定义模板 if (ui_template == jtr("custom set1")) { custom1_date_system = ui_date_prompt; diff --git a/ui/utils.cpp b/ui/utils.cpp index 4e9cdb4e..7809d143 100644 --- a/ui/utils.cpp +++ b/ui/utils.cpp @@ -380,6 +380,7 @@ void Widget::switch_lan_change() { language_flag = 0; switch_lan_button->setText("zh"); } + apply_language(language_flag); emit ui2bot_language(language_flag); emit ui2tool_language(language_flag); diff --git a/ui/widget.cpp b/ui/widget.cpp index 682e8df2..c427a306 100644 --- a/ui/widget.cpp +++ b/ui/widget.cpp @@ -727,6 +727,45 @@ void Widget::set_date() { emit ui2bot_date(ui_DATES); } +//用户取消约定 +void Widget::cancel_date() +{ + //还原工具选择 + calculator_checkbox->setChecked(ui_calculator_ischecked); + terminal_checkbox->setChecked(ui_terminal_ischecked); + toolguy_checkbox->setChecked(ui_toolguy_ischecked); + controller_checkbox->setChecked(ui_controller_ischecked); + knowledge_checkbox->setChecked(ui_knowledge_ischecked); + stablediffusion_checkbox->setChecked(ui_stablediffusion_ischecked); + interpreter_checkbox->setChecked(ui_interpreter_ischecked); + switch_lan_button->setText(ui_extra_lan); + //复原语言 + if (ui_extra_lan == "zh") { + language_flag = 0; + } else if (ui_extra_lan == "en") { + language_flag = 1; + } + apply_language(language_flag); + emit ui2bot_language(language_flag); + emit ui2tool_language(language_flag); + emit ui2net_language(language_flag); + emit ui2expend_language(language_flag); + extra_TextEdit->setText(ui_extra_prompt); + // 重新判断是否挂载了工具 + if (calculator_checkbox->isChecked() || terminal_checkbox->isChecked() || toolguy_checkbox->isChecked() || knowledge_checkbox->isChecked() || controller_checkbox->isChecked() || stablediffusion_checkbox->isChecked() || interpreter_checkbox->isChecked()) { + if (is_load_tool == false) { + reflash_state("ui:" + jtr("enable output parser"), SIGNAL_SIGNAL); + } + is_load_tool = true; + } else { + if (is_load_tool == true) { + reflash_state("ui:" + jtr("disable output parser"), SIGNAL_SIGNAL); + } + is_load_tool = false; + } + +} + //用户点击设置按钮响应 void Widget::on_set_clicked() { server_process->kill(); diff --git a/ui/widget.h b/ui/widget.h index 020eb76d..682f6a7c 100644 --- a/ui/widget.h +++ b/ui/widget.h @@ -428,6 +428,7 @@ class Widget : public QWidget { void output_scrollBarValueChanged(int value); //输出区滚动条点击事件响应,如果滚动条不在最下面就停止滚动 void set_set(); //设置用户设置内容 void set_date(); //设置用户约定内容 + void cancel_date(); //用户取消约定 void calculator_change(); //选用计算器工具 void interpreter_change(); //选用代码解释器工具 void updateGpuStatus(); //更新gpu内存使用率