From 0db9b50dfbb416981a4fbfb8aa35ffff693e36a0 Mon Sep 17 00:00:00 2001 From: ZHANGTINGAN Date: Thu, 7 Dec 2023 14:30:17 +0800 Subject: [PATCH] feat: update ui of messageBox use DDialog to replace messageBox 1.after change language 2.delete codegeex session --- src/plugins/codegeex/widgets/askpagewidget.cpp | 17 +++++++++++++++-- .../mainframe/profilesettingwidget.cpp | 14 +++++++------- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/src/plugins/codegeex/widgets/askpagewidget.cpp b/src/plugins/codegeex/widgets/askpagewidget.cpp index 2ff71f854..a2d34ccb7 100644 --- a/src/plugins/codegeex/widgets/askpagewidget.cpp +++ b/src/plugins/codegeex/widgets/askpagewidget.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -93,8 +94,20 @@ void AskPageWidget::onChatFinished() void AskPageWidget::onDeleteBtnClicked() { - CodeGeeXManager::instance()->deleteCurrentSession(); - CodeGeeXManager::instance()->cleanHistoryMessage(); + DDialog *confirmDialog = new DDialog(this); + confirmDialog->setIcon(QIcon::fromTheme("dialog-warning")); + confirmDialog->setMessage(tr("This operation will delete all the content of this session. confirm to delete it?")); + confirmDialog->insertButton(0, tr("cancel")); + confirmDialog->insertButton(1, tr("delete"), false, DDialog::ButtonWarning); + + connect(confirmDialog, &DDialog::buttonClicked, this, [](int index) { + if (index == 1) { + CodeGeeXManager::instance()->deleteCurrentSession(); + CodeGeeXManager::instance()->cleanHistoryMessage(); + } + }); + + confirmDialog->exec(); } void AskPageWidget::onHistoryBtnClicked() diff --git a/src/plugins/option/optioncore/mainframe/profilesettingwidget.cpp b/src/plugins/option/optioncore/mainframe/profilesettingwidget.cpp index e6692b42d..85220f211 100644 --- a/src/plugins/option/optioncore/mainframe/profilesettingwidget.cpp +++ b/src/plugins/option/optioncore/mainframe/profilesettingwidget.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include @@ -24,8 +25,7 @@ class ProfileSettingWidgetPrivate }; ProfileSettingWidget::ProfileSettingWidget(QWidget *parent) - : PageWidget(parent) - , d(new ProfileSettingWidgetPrivate) + : PageWidget(parent), d(new ProfileSettingWidgetPrivate) { readTranslate(); setupUi(); @@ -34,7 +34,7 @@ ProfileSettingWidget::ProfileSettingWidget(QWidget *parent) ProfileSettingWidget::~ProfileSettingWidget() { - if(d) + if (d) delete d; } @@ -74,11 +74,11 @@ void ProfileSettingWidget::saveConfig() file.write(chooseFileName.toUtf8()); file.close(); } - DMessageBox msgBox; - DPushButton *okButton = new DPushButton(tr("Ok")); - msgBox.addButton(okButton, QMessageBox::ButtonRole::NoRole); + + DDialog msgBox; + msgBox.addButton(tr("Ok")); msgBox.setWindowTitle(tr("Restart Required--deep-in unioncode")); - msgBox.setText(tr("The language change will take effect after restart.")); + msgBox.setMessage(tr("The language change will take effect after restart.")); msgBox.exec(); }