From bbd2a869cf5c3ba02728b59b80736502e3b9f8f8 Mon Sep 17 00:00:00 2001 From: Jan Sundermeyer Date: Sun, 21 Apr 2024 16:44:29 +0200 Subject: [PATCH] add cancel button to option dialog --- src/aichatassistant.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/aichatassistant.cpp b/src/aichatassistant.cpp index 1f49f7cd6a..fc61e23a3d 100644 --- a/src/aichatassistant.cpp +++ b/src/aichatassistant.cpp @@ -312,14 +312,19 @@ void AIChatAssistant::slotOptions() hl2->addWidget(cbStream); ly->addLayout(hl2); - auto *btOk=new QPushButton(tr("OK")); - connect(btOk,&QPushButton::clicked,[&](){ + auto *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok + | QDialogButtonBox::Cancel); + + connect(buttonBox, &QDialogButtonBox::accepted,[&](){ config->ai_systemPrompt=leSystemPrompt->toPlainText(); config->ai_temperature=leTemp->text(); config->ai_streamResults=cbStream->isChecked(); dlg.close(); }); - ly->addWidget(btOk); + connect(buttonBox, &QDialogButtonBox::rejected, [&](){ + dlg.close(); + }); + ly->addWidget(buttonBox); dlg.setLayout(ly); dlg.exec(); }