Skip to content

Commit

Permalink
优化约定选项的取消行为
Browse files Browse the repository at this point in the history
  • Loading branch information
ylsdamxssjxxdd committed Nov 5, 2024
1 parent 97e7e7d commit 9d18149
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 2 deletions.
8 changes: 6 additions & 2 deletions ui/dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions ui/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
39 changes: 39 additions & 0 deletions ui/widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions ui/widget.h
Original file line number Diff line number Diff line change
Expand Up @@ -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内存使用率
Expand Down

0 comments on commit 9d18149

Please sign in to comment.